Hello
My task is to create a chat App and I m using PubNub to do this.
Now I would like to create a Lobby (where people can see Who is online) [I don’t know how to show who is online on the room]
And then i would like to create a sort of private chat when people click on the name of someone that is online
[I don’t know how to create another room where only 2 utents can chat without other]
This is my work at the moment
require "pubnub" multiplayer = pubnub.new({ publish\_key = "mypubkey", subscribe\_key = "mysubkey", secret\_key = "myseckey", ssl = true, origin = "pubsub.pubnub.com" }) CHAT\_CHANNEL = 'mammamia' local testo = display.newText("testo" , 90 , 100 , "Helvetica" , 24) local mex = display.newText("mex" , 90 , 200 , "Helvetica" , 24) local platformName = system.getInfo("platformName") local name = system.getInfo("name") local deviceID = system.getInfo("deviceID") local prova1 = display.newText("prova1" , 90 , 450 , "Helvetica" , 24) prova1.name = "prova1" local prova2 = display.newText("prova2" , 170 , 450 , "Helvetica" , 24) prova2.name = "prova2" local prova3 = display.newText("prova3" , 250 , 450 , "Helvetica" , 24) prova3.name = "prova3" function connect() multiplayer:subscribe({ channel = CHAT\_CHANNEL, connect = function() mex.text = "Connected!" end, callback = function(message) testo.text = message.msgtext end, error = function(message) print(" Connection Error ") end }) end mex:addEventListener("touch" , connect) function disconnect() multiplayer:unsubscribe({ channel = CHAT\_CHANNEL }) mex.text = "disconnected" end testo:addEventListener("touch" , disconnect) function send\_a\_message(text) multiplayer:publish({ channel = CHAT\_CHANNEL, message = { msgtext = text }, callback = function(info) end }) end function invia(event) if event.phase == "began" then if event.target.name == "prova1" then send\_a\_message(prova1.text) end if event.target.name == "prova2" then send\_a\_message(prova2.text) end if event.target.name == "prova3" then send\_a\_message(prova3.text) end end end prova1:addEventListener("touch" , invia) prova2:addEventListener("touch" , invia) prova3:addEventListener("touch" , invia)
I m a beginner but I m learning very much properties in this field
Can someone gives me some Example or Tutorial or Tips that I can follow… In this way I can understand how pubnub works.
Thanks Really much Guys