Please direct all Support Questions and Concerns to Support@PubNub.com
www.pubnub.com - PubNub Real-time Push Service in the Cloud.
PubNub is a Massively Scalable Real-time Service for Web and Mobile Games. This is a cloud-based service for broadcasting Real-time messages to thousands of web and mobile clients simultaneously.
Be sure to check out the sample code in the platform examples directories for complete code examples!
require "pubnub"
require "crypto"
require "PubnubUtil"
local pubnub_obj = pubnub.new({
publish_key = "demo",
subscribe_key = "demo",
secret_key = "demo",
ssl = false,
origin = "pubsub.pubnub.com"
})
pubnub_obj:publish({
channel = channel,
message = text,
callback = function(r) --textout(r)
end,
error = function(r) textout(r)
end
})
pubnub_obj:signal({
channel = channel,
message = text,
callback = function(r) --textout(r)
end,
error = function(r) textout(r)
end
})
})
pubnub_obj:subscribe({
channel = channel,
connect = function()
textout('Connected to channel ')
textout(channel)
end,
callback = function(message)
--print(message.data.message)
textout(message)
end,
error = function()
textout("Oh no!!! Dropped 3G Conection!")
end,
})
multiplayer:unsubscribe({
channel = channel,
})
textout( 'Disconnected from ' .. channel )
function detailedHistory(channel, count, reverse)
pubnub_obj:history({
channel = channel,
count = count,
reverse = reverse,
callback = function(response)
textout(response)
end,
error = function (response)
textout(response)
end
})
end
local my_channel = 'hello_world'
detailedHistory( my_channel, 5, false )
pubnub_obj:time(function(time)
-- PRINT TIME
print("PUBNUB SERVER TIME: " .. time)
end)
uuid = pubnub_obj.uuid
print("PUBNUB UUID: ", uuid)
function here_now(channel)
pubnub_obj:here_now({
channel = channel,
limit = limit,
callback = function(response)
textout(response)
end,
error = function (response)
textout(response)
end
})
end
local my_channel = 'hello-corona-demo-channel'
here_now( my_channel )
function presence( channel)
pubnub_obj:where_how({
channel = channel,
callback = function(message)
for i,v in pairs(message.payload.channels) do textout(i .. " " .. v) end
end,
error = function()
textout("Oh no!!! Dropped 3G Conection!")
end
})
end
local my_channel = 'hello_world'
presence(my_channel)