group chat

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

Post Reply
jason_
Posts: 5
Joined: 25 Aug 2011, 14:38

group chat

Post by jason_ »

What's the best way to implement a group chat functionality?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

Hi. Well, it depends of if you want or not everyone to see everyone's else chat.

If you want everyone to be able to see everyone's else chat, well... that's not advisable... but i think the best way will still be only 1 room for handling everyone. To improve the performance you would need to disable some of the events and limit the max rate an user can send a msg.

If you only want to group people in smaller rooms, but still be able to change between rooms, the best way is to have many rooms (with not too much users each) and all in the same room group (in case you want to receive updates from the other rooms such as user enter and leave, etc).

But this also depends of what other features will you add to the chat...
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
jason_
Posts: 5
Joined: 25 Aug 2011, 14:38

Post by jason_ »

Thanks for the reply. my intention is to have a tab for public chat, a tab for private chat and a tab for a group chat where a specific group of users can chat separately from the public chat.
jamalsoueidan
Posts: 153
Joined: 15 Aug 2011, 16:33

Post by jamalsoueidan »

There is two options you can go for.

The easy one is.

10 tabs for 10 rooms, some rooms for only 2 and other rooms for 20 users.

So people who want to talk alone can join room with limit 2 users.

This is easy task and you can do it easily.


The hard part to make it dynamic, then you need more time and code :)
The best thing to do is to start with the easy task, when you are done with the interface and working chat rooms.

BY THEN you can start working on advanced chat while your other simple chat is LIVE online :D
---------------------------------------------------
Jamal Soueidan
http://linkedin.com/in/jamalsoueidan
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

hi. So for the public tab, you can create rooms with around 20 - 30 people.
For the private tab, you dont really need to create a room, as you can easily send private messages to users between different rooms.
For the group tab, you create smaller rooms and, if the group chat is private, you set a password to that room, so only people known people can enter.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
jason_
Posts: 5
Joined: 25 Aug 2011, 14:38

Post by jason_ »

Is there a way to join two rooms at the same time and listen to public chat events on both rooms?
jamalsoueidan
Posts: 153
Joined: 15 Aug 2011, 16:33

Post by jamalsoueidan »

Yes, you just subscribe to the other room or zone :D
---------------------------------------------------
Jamal Soueidan
http://linkedin.com/in/jamalsoueidan
jason_
Posts: 5
Joined: 25 Aug 2011, 14:38

Post by jason_ »

for some reason I'm only able to get PUBLIC_MESSAGE events from one room even after I joined and subscribed to a second room. Any thoughts?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

Hum... Sorry on mobile now. Can you post the steps u're doing?
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
jamalsoueidan
Posts: 153
Joined: 15 Aug 2011, 16:33

Post by jamalsoueidan »

Example:

getApi().subscribeRoomGroup(user, "roomName");
---------------------------------------------------
Jamal Soueidan
http://linkedin.com/in/jamalsoueidan
jason_
Posts: 5
Joined: 25 Aug 2011, 14:38

Post by jason_ »

Cool. I'm able to recieve public messages from two different rooms using subscribeRoomGroup() method.

My next question is how do I figure out which room the chat message is coming from?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

Hi. Please check the docs before posting.
In the PUBLIC_MESSAGE event details, you can see that there is a property called Room, which is the Room object from where this public message was originated.

I know it says that it is "An object representing the Room at which the message is targeted.", but that's because when you send a public message, you choose to which of the joined rooms you want to send it to.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Post Reply