Sign In Register

How can we help you today?

Start a new topic
Answered

Global Chat

We're trying to implement a global chat for all online users. We looked at doing this by adding all users to a single team, but it looks like that requires each user receiving a list of every online player and there isn't a clear system to remove players from a team because they went offline. 


Has a global chat system ever been implemented before and is there a system to support it?


Is there a reasonable way to make the team chat provide the service without passing massive amounts of useless data to the client?


Best Answer

Hi Michael, 


I believe this can be achieved through the following: 

First of all you will create a team instance for the purpose of Global Chat. To manage player membership within this team, i.e online players only, you will place cloud code within both your Registration, Authentication and Disconnect Requests. 


The former will contain calls to Join the relevant team through cloud code, the documentation for which can be found here.

For the removal of players from from the team, you can send an EndSessionRequest to end the player session from Unity explicitly and within the Requests cloud code,  handle the removal of the given player from the Team which using cloud code the particular call for which can be found here


Happy to assist further - Patrick. 


Pretty sure its the client that has to listen for a chat event, so not sure what you mean by useless data.


In cloud code, check the team short_code (ie GLOBAL), and if it matches, suppress the output. Then you won't have to worry about getting a ton of info sent to the client when user first subscribes to the team.

Useless data was referring to the list of all players currently on the channel, in this case all online users.


I'll try suppressing the output. Thanks.

2 follow-up questions:


1. how do I suppress the output on the team join message? I can't find it in messages.


2. Even if the list of all players is not sent, is it still compiled? In our experience, anything compiling something in the range of several thousand items in the database will trip the 30 second limit and cause the whole operation to fail. In this case, that means it would never reach the broadcast. Or it might fail halfway through the broadcasting and only half our users receive the message.

To suppress, you can call a LogEventRequest that does the Join team request, and just have it not return anything but the data you want returned. Alternatively, you can auto-subscribe them to the Team during registration (which could cause issues with #2, so I suggest LogEventRequest).

Yes, it would still be compiled, I don't think it matters that much in your scenario. From my eyes, even if it does timeout, it doesn't really matter that much unless called during Registration/Account requests (see above). In other words, it may timeout building the response, but you'd still get added to the team anyways, so the output isn't needed that much.
Appendum: timing out would only occur for the join team response query, don't think it applies at all to the broadcast, as the client is the one listening for the message, not the server pushing it. I could be wrong in my understanding of this architecture though.

 

Alright, I think that will work. Will let you know.

When gamesparks is broadcasting a message, does it need to send that message to every player individually and if so, can that process timeout?

As I mentioned a little bit ago, I believe the architecture is that the client is listening in, and that the server is just making the info available (and not actually pushing data to the client), but please open a ticket with support for specifics on how the back-end will work.

 

(and let us know if I was incorrect ;)  )

 

Answer

Hi Michael, 


I believe this can be achieved through the following: 

First of all you will create a team instance for the purpose of Global Chat. To manage player membership within this team, i.e online players only, you will place cloud code within both your Registration, Authentication and Disconnect Requests. 


The former will contain calls to Join the relevant team through cloud code, the documentation for which can be found here.

For the removal of players from from the team, you can send an EndSessionRequest to end the player session from Unity explicitly and within the Requests cloud code,  handle the removal of the given player from the Team which using cloud code the particular call for which can be found here


Happy to assist further - Patrick. 


1 person likes this

Addition / Removal based on authentication and EndSession, doh! Seems obvious now lol


1 person likes this

Thanks Patrick, I'll give this a try.


Would the disconnect request be referring to the cloud code under System/Player Disconnected?

What he was referring to, it is under Analytics: EndSessionRequest. The same name for cloud code: Requests > EndSessionRequest. Although that may work as well. Test it out :)

Okay, cool. I found that one already. Time to give this a shot.

Login to post a comment