Hi Lapo,
during my successful development journey with SFS2X, I came across a problem I couldn't solve. And at this near-finished stage, I somehow need to solve it without breaking all the code there is.
The situation
Players can form clubs. Each club has an own room. Players are automatically joined into that room on login and cannot leave it. They can chat publicly in that room.
The server keeps a little chat history in each club room: it registers for "public message" SFSEvents and keeps the last 20 messages of the room in one room variable. Updates to this variable are not sent to the clients so that only new joining players can fill their initial chat window from that variable.
Sometimes special events should happen involving certain clubs. Like a club vs. club challenge triggered by the server. The server should then notify both club rooms about this challenge.
The problem
I can't for the love of all foxes get the server to send a normal public message into a room without needing user to send it with! But there is no user triggering this event in this case - it's only the server. And I need it to be a public message so it can be picked up by the chat history event handler, so new joining players also can see that special event.
Sending individual messages to all players of one room won't help with the chat history.
How can I do this?
Thanks a ton,
Niklas
(Disclaimer: I simplified the problem and all the side effects a little for this explanation - I'm actually desperately needing a "server public message", that would be the easiest fix here...)
Server sending *public messages* into a room?
Re: Server sending *public messages* into a room?
Hi,
A public message is supposed to be sent by someone in the Room. If not the receivers won't know who actually sent the message. Makes sense?
What you're looking for is either a Moderator or Admin Message. Both of which are available from the server side, as:
Cheers
I can't for the love of all foxes get the server to send a normal public message into a room without needing user to send it with!
A public message is supposed to be sent by someone in the Room. If not the receivers won't know who actually sent the message. Makes sense?
What you're looking for is either a Moderator or Admin Message. Both of which are available from the server side, as:
- SFSApi.sendModeratorMessage()
SFSApi.sendAdminMessage()
Cheers
Re: Server sending *public messages* into a room?
Hi Lapo,
Sort of, but why can't the public message originate from "the server" instead of a person in the room? The server is omnipresent, it doesn't need to be in a room, it IS the room!
It's like a public room message for all the participants of a room. But without a real person sending it.
I saw moderator and admin messages but they both can only be sent to users, not to a room... So I guess it really isn't possible to send a public server message to one distinct room?
Cheers
A public message is supposed to be sent by someone in the Room. If not the receivers won't know who actually sent the message. Makes sense?
Sort of, but why can't the public message originate from "the server" instead of a person in the room? The server is omnipresent, it doesn't need to be in a room, it IS the room!
It's like a public room message for all the participants of a room. But without a real person sending it.
I saw moderator and admin messages but they both can only be sent to users, not to a room... So I guess it really isn't possible to send a public server message to one distinct room?
Cheers
Re: Server sending *public messages* into a room?
A public message must be sent by a User joined in the Room. There's no way to override this. The client side API need the User Id of the sender to be able to reference the necessary objects passed in the SFSEvent.PUBLIC_MESSAGE.
To accomplish what you're asking you would need to create an NPC on the server side, join it in the Room and then send a public message.
Using and Admin or Moderator message seems more convenient, plus it provides a separate event which is useful to handle the message in a customized way, if necessary.
Cheers
To accomplish what you're asking you would need to create an NPC on the server side, join it in the Room and then send a public message.
Using and Admin or Moderator message seems more convenient, plus it provides a separate event which is useful to handle the message in a customized way, if necessary.
Cheers
Re: Server sending *public messages* into a room?
Hi Lapo,
thank you for the explanation! I'll go with the admin/mod messages then, good hint with the separate event! This way I should be able to add it to the message history as it is.
Best,
Niklas
thank you for the explanation! I'll go with the admin/mod messages then, good hint with the separate event! This way I should be able to add it to the message history as it is.
Best,
Niklas
Who is online
Users browsing this forum: No registered users and 46 guests