Send Private Message to a list of Users

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

Moderators: Lapo, Bax

Post Reply
wulei
Posts: 19
Joined: 19 Aug 2013, 17:42

Send Private Message to a list of Users

Post by wulei »

Hi everyone !

I didn't find any answers to my problem in this forum

I am disappointed by the private message request:

why don't change this
*

Code: Select all

public PrivateMessageRequest(
	string message,
	int recipientId,
	ISFSObject parameters
)
*
into this
*

Code: Select all

public PrivateMessageRequest(
	string message,
	int[] recipientsIds,
	ISFSObject parameters
)
*
?

First I want a client be able to sent a private message to several users in one shot (concept of private discussions), instead of sending a burst of requests to the server for one private message in the discussions.

Second i want the server be able to intercept each message to add some data like the current time and some others. I saw this topic http://forums.smartfoxserver.com/viewto ... ers#p62548 where it seems to be not possible.


Finally have I to do my own extension ? Or is there any other alternative ?
Thanks for helping and any answers

PS:
1. Is there a way to use "ISFSObject parameters" in private message request to ask the server to broadcast the message to the concerned clients ?

2. why don't turn public and private message requests into a single request like :

Code: Select all

public MessageRequest(
	string message, // The text
	int[] recipientsIds, // The concerned users limited to a definable number
	bool IsPublic, //Is this a private or public message
	ISFSObject parameters // How to use this
)
3. or just defined via a request a list of users referenced by an id. The id is assigned by the server.
Then the message request can be like that:

Code: Select all

public MessageRequest(
	string message, // The text
	int GroupOfUsers_ID, // The id of the group of users
	bool IsPublic, //Is this a private or public message
	ISFSObject parameters // How to use this
)
4. How in this case the server can maintain a reference on an instance like a group of users ?
Via a database, text files, or in memory like using static variables ?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Send Private Message to a list of Users

Post by Lapo »

The idea is that a private message is sent to one other recipient.
A multi-user private discussion sounds like a pretty strange idea, at least it's a very custom request. Which is understandable.

Normally you would gather those people in a Room and let them chat together with Public messages.

In any case, let's talk about solutions. You can use the ObjectMessage instead which supports a custom list of users.
Second i want the server be able to intercept each message to add some data like the current time and some others. I saw this topic http://forums.smartfoxserver.com/viewto ... ers#p62548 where it seems to be not possible.
That thread is 1+ year old. It is now possible to intercept and manipulate most common requests by using a SystemController Filter.
Details here:
http://docs2x.smartfoxserver.com/Advanc ... er-filters
Lapo
--
gotoAndPlay()
...addicted to flash games
wulei
Posts: 19
Joined: 19 Aug 2013, 17:42

Re: Send Private Message to a list of Users

Post by wulei »

Thanks for reply !
I will try that.

So rooms can be deemed as channel of discussion ?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Send Private Message to a list of Users

Post by Lapo »

Absolutely, that's what they were created in the first place :)
You can setup a room for a number of user to play a game, to chat about something specific etc...

One-to-one discussion can be done even without a Room, if you so desire. For more users a Room is definitely the best choice. Also you can join as many Rooms as you need, so multiple separate discussions can be handled as well.
Lapo
--
gotoAndPlay()
...addicted to flash games
wulei
Posts: 19
Joined: 19 Aug 2013, 17:42

Re: Send Private Message to a list of Users

Post by wulei »

Thanks again, i really appreciate your help

So i can use rooms and groups of rooms for multiple purposes like:
- group of rooms named : virtual_places_group (restricted to one registration at the same time for each user),
- group of rooms named : channels_of_discussion (several registrations for each user, and each room has its own capacity controlled by the server)
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Send Private Message to a list of Users

Post by Lapo »

I am not sure what the registration is referring to exactly, but yes they can be used like that.
For more detail I would recommend the documentation:
http://docs2x.smartfoxserver.com/Develo ... chitecture
Lapo
--
gotoAndPlay()
...addicted to flash games
wulei
Posts: 19
Joined: 19 Aug 2013, 17:42

Re: Send Private Message to a list of Users

Post by wulei »

I am not sure but is this correct ?
- a client can subscribed / unsubscribed to a room
- a client can subscribed / unsubscribed to a group of rooms

edit: Just forget about it, i just understand
  • A client can join several rooms
    A client can subscribed to several Groups of rooms
Registration was about the subscribing of a client to a room or group :D
Sincerely thanks for you answer !
wulei
Posts: 19
Joined: 19 Aug 2013, 17:42

Re: Send Private Message to a list of Users

Post by wulei »

PS :
And the last strange question but not least :
Is a client is able to
  • subscribe another client to a group of rooms
    make a client join a room
if the logic allows it ?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Send Private Message to a list of Users

Post by Lapo »

wulei wrote:A client can join several rooms
Yes
A client can subscribed to several Groups of rooms
Yes
Is a client is able to subscribe another client to a group of rooms
No, it would violate security. Only server side code can do that
Is a client is able to make a client join a room.
Same as above
Lapo
--
gotoAndPlay()
...addicted to flash games
wulei
Posts: 19
Joined: 19 Aug 2013, 17:42

Re: Send Private Message to a list of Users

Post by wulei »

Ok
Thanks a lot for answers and help
Post Reply