How to use corona with pubnum to create a simple chat app

Hi all,

I want to create a simple one to one chat app, can anyone tell me how is it possible using corona and pubnum.

Please tell me the api’s that i have to use, I have developed a code that works fine for multicasting but unable to do so for the unicasting.

Please help me, thanks in advance for your useful answers.

Thanks,

sahil sharma

@sahil

just initialize a unique room channel for the 1v1 chat and no one else will be able to join the chat channel.

Nail

@xnailbender,

Thanks, i have tried that and create a channel name xyzchannel, now it is limited to just 2 users and for each pair i have to create a separate channel, is not it possible to create channel at run time and link 2 users over there for private chat, if possible then how user1 will know about the private channel of user2 and link there. Is there any separate group of api’s which will do this task or we have to write the entire code.

@sahil,

I’m guessing you have some sort of public lobby that everyone enters when they join.  When user1 selects user2’s button, it will have user2’s private chat channel reference and send a message to user2 that a private chat has been initiated and proceeds to terminate the public channel and open/join their private channel.

I’m assuming your public lobby has a list of users participating.  Make each users name in the list a button that is touchable.

There are no API’s I’m aware of that do this, yet alone create a lobby.  I’ve created a chat room from scratch that works well, it even has “kick” and “block” abilities.

Hope this helps,

Nail

@ Nail

Yes this is the only solution and i had the same plan but the only problem i am facing is i am not getting the reference to the user2’s pub and sub keys so as to send a message privately. It may be possible in other languages but i am not getting that for LUA.

Is it like that we have to create a local server also in addition to pubnub or what where we keep all the information on registering or what.

sahil

@Sahil

I believe if you want to create a permanent channel for a user, it  will have to be stored and retrieved from a server and verified to be unique.

Another way to issue a user a unique channel would be if ALL users were Game Center Members and you could get their username and add some numbers to it and issue it to them as their private channel.  This would insure all usernames and private channels were unique bypassing the need for a server, but everyone would have to be a GameCenter user.

I don’t understand this…

@Sahil wrote:

“the only problem i am facing is i am not getting the reference to the user2’s pub and sub keys so as to send a message privately.”

The Pub and Sub Keys are the same for all the users in your chat room.  They are for your account and don’t change.

The private “Channel” is what changes and should be unique for each user in some shape or form.

I’ve got to ask you a question.  Have you created a lobby system, or how do your users connect originally?

Nail

@sahil

just initialize a unique room channel for the 1v1 chat and no one else will be able to join the chat channel.

Nail

@xnailbender,

Thanks, i have tried that and create a channel name xyzchannel, now it is limited to just 2 users and for each pair i have to create a separate channel, is not it possible to create channel at run time and link 2 users over there for private chat, if possible then how user1 will know about the private channel of user2 and link there. Is there any separate group of api’s which will do this task or we have to write the entire code.

@sahil,

I’m guessing you have some sort of public lobby that everyone enters when they join.  When user1 selects user2’s button, it will have user2’s private chat channel reference and send a message to user2 that a private chat has been initiated and proceeds to terminate the public channel and open/join their private channel.

I’m assuming your public lobby has a list of users participating.  Make each users name in the list a button that is touchable.

There are no API’s I’m aware of that do this, yet alone create a lobby.  I’ve created a chat room from scratch that works well, it even has “kick” and “block” abilities.

Hope this helps,

Nail

@ Nail

Yes this is the only solution and i had the same plan but the only problem i am facing is i am not getting the reference to the user2’s pub and sub keys so as to send a message privately. It may be possible in other languages but i am not getting that for LUA.

Is it like that we have to create a local server also in addition to pubnub or what where we keep all the information on registering or what.

sahil

@Sahil

I believe if you want to create a permanent channel for a user, it  will have to be stored and retrieved from a server and verified to be unique.

Another way to issue a user a unique channel would be if ALL users were Game Center Members and you could get their username and add some numbers to it and issue it to them as their private channel.  This would insure all usernames and private channels were unique bypassing the need for a server, but everyone would have to be a GameCenter user.

I don’t understand this…

@Sahil wrote:

“the only problem i am facing is i am not getting the reference to the user2’s pub and sub keys so as to send a message privately.”

The Pub and Sub Keys are the same for all the users in your chat room.  They are for your account and don’t change.

The private “Channel” is what changes and should be unique for each user in some shape or form.

I’ve got to ask you a question.  Have you created a lobby system, or how do your users connect originally?

Nail