Game chat and database update

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

TwineApps
Posts: 80
Joined: 10 Nov 2016, 18:39

Game chat and database update

Postby TwineApps » 24 Jul 2017, 11:58

Hi,

In my game it's possible remove a user from the clan, when a user is removed, need notify in the client chat of all users that are that room, which of these ways is the best?

1) At the end of the request to expel a member of the clan, I make another request to download the notifications;
(It's bad, because it only works for those who make the request, and not for all other online users)

2) At the end of the request, I download all the updated chat;
(It's bad, because it only works for those who make the request, and not for all other online users)

3) Generates the client notification, and sends this message to all members of the clan online, and the server updates the chat in the db;

4) From the server I enter the notification in the db, the server select the room, and send this notification to the whole room.

If there are better ways to update both databases and chats for online users, do not hesitate to comment them, thanks for your attention.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Game chat and database update

Postby Lapo » 24 Jul 2017, 13:27

Hi,

Code: Select all

In my game it's possible remove a user from the clan, when a user is removed, need notify in the client chat of all users that are that room, which of these ways is the best?


I would choose number 4

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
TwineApps
Posts: 80
Joined: 10 Nov 2016, 18:39

Re: Game chat and database update

Postby TwineApps » 24 Jul 2017, 15:28

Can you send me an example to do this?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Game chat and database update

Postby Lapo » 25 Jul 2017, 06:53

To do what exactly? How to send a message to all user in a Room?
The extension send() method takes a list of Users, so you can pass Room.getUserList() directly in there.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
TwineApps
Posts: 80
Joined: 10 Nov 2016, 18:39

Re: Game chat and database update

Postby TwineApps » 25 Jul 2017, 11:35

I have to take the room of the user who made the request, and then send all the users in the room a message.

How do I get the user's room?
How do I send a server-side message to all users in the room?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Game chat and database update

Postby Lapo » 25 Jul 2017, 11:55

I'd recommend to make the server side docs your best friend :)
All these questions are answered there: http://docs2x.smartfoxserver.com/api-do ... oc/server/

How do I get the user's room?

user.getLastJoinedRoom();

How do I send a server-side message to all users in the room?

As I explained in my previous response: the extension send() method takes a list of Users, so you can pass Room.getUserList() directly in there.
Lapo

--

gotoAndPlay()

...addicted to flash games
TwineApps
Posts: 80
Joined: 10 Nov 2016, 18:39

Re: Game chat and database update

Postby TwineApps » 25 Jul 2017, 13:09

Why can't I pass Room.getUserList () in send () ?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Game chat and database update

Postby Lapo » 25 Jul 2017, 13:35

TwineApps wrote:Why can't I pass Room.getUserList () in send () ?

You can do that. The send method takes a List<User> as the 3rd parameter and Room.getUserList() gives you a List<User>

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 58 guests