Page 1 of 1

Public message and Private message

Posted: 05 May 2016, 16:29
by near
Hi,
Sorry for my English :P
I have some problem with chat message.
I want create a chat that can send message to All in the zone , to Party (inside some room), or to one user.
Only party work fine.
This code is similar to mine...but not equal

1)I have did sending message to all in this way:

Code: Select all

 string msg="Hello";
            nomeStanzaPerChat = "Word";
            SFSObject objOut = new SFSObject();
            objOut.PutUtfString("ns", nomeStanzaPerChat);
            List<Room> rooms = sfs.RoomManager.GetRoomList();
            for (int i = 0; i < rooms.Count; i++)
            {               
                sfs.Send(new PublicMessageRequest(msg, objOut, rooms[i]));
            }
I have tried to send the message to all room but only user in same room of the sender receive this message.

2)private message:

Code: Select all

 string name=//some name
                    User userDestinatario = sfs.UserManager.GetUserByName(name);
                    nomeStanzaPerChat = "whisper";
                    SFSObject objOut = new SFSObject();
                    objOut.PutUtfString("ns", nomeStanzaPerChat);
                    sfs.Send(new PrivateMessageRequest(messaggioChat, userDestinatario.Id, objOut));
For example:
if users "a","b" and "c" are inside the lobby room if "a" send a private message to "b", "b" receive this message correctly and "b" can send to "a" the replace.
If "a" join inside an other room," a" can send to "b" the message, and" b "receive the message but if "b" send to" a" a message, he can't find him.
I have these two problems.
Can you help me?

N.

Re: Public message and Private message

Posted: 06 May 2016, 10:14
by Lapo
Hi,
public messages work only within a single Room. In other words, you can only reach people that are in the same Room with you. Those in other Rooms will not receive it.

To be able to send a message to every one you will need send a ModeratorMessage like this:

Code: Select all

var mode = new MessageRecipientMode(MessageRecipientMode.TO_ZONE);
sfs.send( new MoModeratorMessageRequest("Hello everyone", mode) );


The MessageRecipientMode allows to choose different groups of users, including the whole Zone.
More on this in the documentation:
http://docs2x.smartfoxserver.com/api-do ... quest.html

Keep in mind that in order to send a ModeratorMessage your user must be a moderator.
http://docs2x.smartfoxserver.com/Advanc ... ge-manager

Hope it helps

Re: Public message and Private message

Posted: 06 May 2016, 10:26
by Lapo
Correction to previous post.
If you're sending the message from server side then you can use this from your Extension:

Code: Select all

getApi().sendModeratorMessage(user, "Message", null, getParentZone().getSessionList());
cheers

Re: Public message and Private message

Posted: 06 May 2016, 21:15
by near
thank you for replay i try this method.
but...for my second problem do you have some solution too? :D

Re: Public message and Private message

Posted: 06 May 2016, 21:25
by near
P.S. vedo dai tuoi dati visibili sul forum che sei italiano e il bello รจ che lo sapevo, visto che il professore del mio corso di sviluppo videogiochi con unity ce lo aveva accennato ma lo avevo dimenticato che voi di smartfox siete di provenienza italiana. Mi fa ridere che mi sono impegnata a scrivere in inglese quando potevo fare meno fatica ahah.
Vabbe XD

Re: Public message and Private message

Posted: 07 May 2016, 07:31
by Lapo
yes... but for this forum we use english anyways so that everybody can understand :)

About your 2nd question:
if users "a","b" and "c" are inside the lobby room if "a" send a private message to "b", "b" receive this message correctly and "b" can send to "a" the replace.
If "a" join inside an other room," a" can send to "b" the message, and" b "receive the message but if "b" send to" a" a message, he can't find him.
Yes, Private messages work when the two users can "see" each other. In other words when they share at least one Room in common. If you need to send messages between Rooms regardless of Rooms I would suggest the Buddy List API. This allows every player to add other users to their friend's list and then send them messages at any time, without the need to be in the same Room.

If you're working in Unity we have an example you can take a look at:
http://docs2x.smartfoxserver.com/Exampl ... -messenger

This is the documentation about the Buddy List API:
http://docs2x.smartfoxserver.com/Advanc ... y-list-api

cheers

Re: Public message and Private message

Posted: 07 May 2016, 11:41
by near
Thank you.
I'll study the buddy list example and I' ll try to study English too, so I can understand better the documentation and messages in the forum :D.
English is my enemy :(
Bye and thank you again.