在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):pubnub/lua开源软件地址(OpenSource Url):https://github.com/pubnub/lua开源编程语言(OpenSource Language):Lua 99.7%开源软件介绍(OpenSource Introduction):[email protected]Please direct all Support Questions and Concerns toPubNub 3.6 Real-time Cloud Push API - for Corona and Moaiwww.pubnub.com - PubNub Real-time Push Service in the Cloud.GET YOUR PUBNUB KEYS HEREPubNub 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"
})
Publishpubnub_obj:publish({
channel = channel,
message = text,
callback = function(r) --textout(r)
end,
error = function(r) textout(r)
end
}) Signalpubnub_obj:signal({
channel = channel,
message = text,
callback = function(r) --textout(r)
end,
error = function(r) textout(r)
end
})
}) Subscribepubnub_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,
}) Unsubscribemultiplayer:unsubscribe({
channel = channel,
})
textout( 'Disconnected from ' .. channel ) Detailed Historyfunction 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 ) Timepubnub_obj:time(function(time)
-- PRINT TIME
print("PUBNUB SERVER TIME: " .. time)
end) UUIDuuid = pubnub_obj.uuid
print("PUBNUB UUID: ", uuid) here_nowfunction 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 ) Presence/where-nowfunction 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)
[email protected]Please direct all Support Questions and Concerns to |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论