Hi Chris,
I'm stuck trying to do a coronium.user.push. Hoping that you can point me in the right direction.
Here's what I am doing (and if there is a better way, please let me know!!):
I am pulling the users.objectId by doing a search on the email address which is stored in _users with this call to the server:
Client:
mc:run("notification", {to = receipents[i].to}, pusher)
Server (notification.lua):
local in_data=coronium.input()
local answer = coronium.user.getUsers({email=
in_data.to},{objectId = 1})
coronium.output(answer)
The results go to my push function:
Client:
local function pusher(event)
print("pusher function") -- make sure we reached the function and know where to fix stuff.
table.print_r(event.result)
if event.result[1].objectId then
local temp = event.result[1].objectId
mc:run("pusher", {to = temp})
else
print("problem with data back in pusher", event.error)
end
end
Sample results:
pusher function
table: 033CB338 {
[1] => table: 033CB338 {
[objectId] => "a0a1572b02"
}
}
error: Server Error - Check Logs
errorCode: 500
So we know I am getting the objectId which is passed to the server pusher.lua file:
pusher.lua (server)
local in_data=coronium.input()
local pushData = {
message = "You have received a new message",
}
answer = coronium.user.push(pushData)
if not answer.error then
coronium.output( "push sent")
else
coronium.output(answer.error)
end.
error.log
2016/02/06 17:34:57 [error] 7502#0: *283666 lua entry thread aborted: runtime error: /usr/local/coronium/lib/mod_user.lua:439: attempt to index field 'result' (a nil value)
stack traceback:
coroutine 0:
/usr/local/coronium/lib/mod_user.lua: in function 'push'
/home/coronium/lua/push.lua:10: in function </home/coronium/lua/pusher.lua:1>, client: 150.252.229.176, server: , request: "POST /1/code/pusher HTTP/1.1", host: "ec2-54-88-76-212.compute-1.amazonaws.com"
Any advice?
Thank you,
Brian