Forum General No Message Receive On Game Joined

Any issues or discussions relating to Unity development are welcome here.

No Message Receive On Game Joined

Postby Deathline » March 19th, 2017, 1:20 pm

Hey PIO Dev's,

I've Problem since 2 Days i work again with PIO. Everything is very cool but my Problem when im Join the Game.
And Serverside im try to send my Client a Message, that im successfully Joined. The Client wont receive it.

Serverside:
Code: Select all
            Message msg = Message.Create("Join", player.ConnectUserId.Remove(0, 6));
            foreach (Player p in Players)
            {
                p.Send("Join", player.ConnectUserId.Remove(0, 6));
            }


When i send the Message like an half Second later, the client will receive it.

And on The Client, the first thing i do is link the Message Handler to reduce the time until i can successfully receive Messages.

Code: Select all
        client.Multiplayer.CreateJoinRoom("BaseMap", "BaseMap", false, null, null, delegate (Connection Connection) {
            Debug.Log("Success");
            Connection.AddOnMessage(handleMessage);
            SceneManager.LoadScene(2);
        });


Is their anyway i can fix this. Without add a Waittime on the First until i can Send the Joined Message.
I hope anyone know how i can fix this.

Thanks in advance.


Edit:

After some Tests it works sometimes. HowTo Reproduce it:
I found out when login with the Same Account within 5 Minutes 2 Times u didnt get the Login Message.
After a DevServer Crash u get again for 1 Player the Login Message.
When More then 1 Player login in at the Same Time it wont work.
And if u dont declare the DisconnectHandler it also wont work.

Can anyone please tell me if it works by him.? Or how i get fixed this Bug?


//Edit2: In The Live Cluster it works on a Chance of around 90%.
Deathline
 
Posts: 14
Joined: August 14th, 2011, 11:27 am

Re: No Message Receive On Game Joined

Postby Henrik » March 19th, 2017, 8:56 pm

In which piece of serverside code are you trying to send a message to the client that just joined?

If you do it inside UserJoined, that's not going to work, because you're sending the message before the callback in CreateJoinRoom gets to run, which means you probably haven't setup any message handlers yet, so the message is just going to get lost. The reason it works a percentage of the time is pure luck.

Best practice is to first setup your message handlers, then send a message to the server that you're ready, and then the server can send back whatever game state the client might need.
Henrik
.IO
 
Posts: 1822
Joined: January 4th, 2010, 1:53 pm

Re: No Message Receive On Game Joined

Postby Deathline » March 19th, 2017, 10:00 pm

Yeah i already know that, thats the Problem.

But i've seen in the Demos from u. U also try to send from the "PlayerJoined" Method to the new Joined Player.

(Didnt testet before because the SDK for Unity3D Serverside doesnt work.)

I've fixed this on another Way. Like Player Send to Server -> I'm Joined. Server to Player -> "Here is your Data."

But thanks for ur answer.
Deathline
 
Posts: 14
Joined: August 14th, 2011, 11:27 am

Re: No Message Receive On Game Joined

Postby Henrik » June 15th, 2017, 11:49 pm

Hey Deathline,

We've fixed this issue in the Unity client library now, so if you setup your message handlers in the CreateJoinRoom callback, you will receive all messages in the correct order, even those sent from AllowUserJoin and UserJoined on the serverside.
Henrik
.IO
 
Posts: 1822
Joined: January 4th, 2010, 1:53 pm


Return to General



cron