Forum Mobile Send Message in UserJoined

Anything specifically relating to droid or iOS development with Unity can go here.

Send Message in UserJoined

Postby frank84 » October 21st, 2016, 9:31 pm

We are using the Oct 19 Unity SDK (3.2). On the server, the UserJoined() method loads a single database object and then sends a success message back to the player. On the server side we are seeing the success message being sent. On the client side we always see the CreateJoinRoom success callback get called but do not always receive the message. I can only assume that the success message is somehow arriving before the CreateJoinRoom success callback is fired or the Send() call silently fails from the server. This fails about 50% of the time.

Is this expected behavior? Should I not be calling Send() on the server in UserJoined() and instead first wait for the client to verify that it received the CreateJoinRoom success callback? I am seeing this behavior in the Unity 5.4.1p4 editor as well as on an iPhone 6S running iOS 10.0.2 and built with Xcode 8.0.
frank84
 
Posts: 27
Joined: November 23rd, 2013, 2:09 am

Re: Send Message in UserJoined

Postby Henrik » October 22nd, 2016, 8:31 am

When you load an object inside UserJoined, it's an asynchronous call, which means that it just continues executing and returns true, and the server allows the user in, and sends a message back to the client that it joined the room. Meanwhile, the BigDB load happens, and whenever that is successful, it sends a message back to the client. Since these two events are independent, there's no way to guarantee one message to arrive before the other, which is why you are seeing the 50% success rate.

The recommended flow is to let the client wait for the CreateJoinRoom() success callback, setup the message handlers, and then send a message to the server that it is ready, and when the server gets that, it can do the BigDB load and send some data back to the client. That way you are guaranteed to get the right timeline of events that you wanted in the first place.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm


Return to Mobile