Client receive the second message before the 1st message

Sep 8, 2012 at 11:14 AM

Hi ,

In my app, some time server send two message to client ,

But the client receive the 2nd message and then receive 1st message,

How can I solve it,

Regards,

Coordinator
Sep 8, 2012 at 11:15 AM

Which protocol are you using? Did you implement your protocol correctly?

Sep 8, 2012 at 11:35 AM

Hi kj , I'm use TCP

Coordinator
Sep 8, 2012 at 11:37 AM

What;s your application level protocol? You are sure to use TCP.

 

WebSocket or Command Line?

Coordinator
Sep 8, 2012 at 11:37 AM

I  mean the format of the data you send from server to client?

Sep 8, 2012 at 11:44 AM

Hi kj,

I use WebSocket ( HTML5 ) as my client side,

And the server host on IIS,

I use complete Supper web socket without any change,

Regards

Coordinator
Sep 8, 2012 at 11:46 AM

Your question should be asked on SuperWebSocket's website instead of SuperSocket.

Which version of SuperWebSocket are you using?

Coordinator
Sep 8, 2012 at 11:47 AM

How do you know the problem?

Sep 8, 2012 at 12:04 PM

On client side, when receive the message, I'm show it on screen and I see the problem,

On server side , I swap the code sending message to client and I the problem again, but change server side code just for detect problem because It will change the server logic,

Regards,

Coordinator
Sep 8, 2012 at 12:06 PM

Which version of SuperWebSocket are you using?

And How do you send the message? Could show me the code?

Sep 8, 2012 at 12:07 PM

Now , I set break point for debug and wait about 2 minutes before send the 2nd message , client will receive correctly,

Sep 8, 2012 at 12:12 PM

I use SuperWebSocket 0.6  with SuperSocket 1.4 SP5

Coordinator
Sep 8, 2012 at 12:14 PM

Could you show me the sending code?

Sep 8, 2012 at 12:16 PM

The code :

            string JsonMessage_SlotInfo = "";

            CustomJObject.BuildJsonDataSucessWithRootKey(ref JsonMessage_SlotInfo, MessageDefine.RootKeyValue.ChangeSlotStatusResult);
           
            CustomJObject.FinalizeJsonData(ref JsonMessage_SlotInfo);

            ObjHostedMap.HostedUser.Send(JsonMessage_SlotInfo);

 

 

            string JsonMessageHostedMapInfo = "";
            Json_GetHostedMap_FullSuccessMessage(ref JsonMessageHostedMapInfo, ObjHostedMap.HostedUser.UserId);

            List<MapSlot> LstMapSlot = ObjHostedMap.GetListPlayerSlotHasPlayerJoinIn();

            for (int i = 0; i < LstMapSlot.Count; i++)
            {
                if (LstMapSlot[i].UserId != ExcludeUserId)
                    {
                        LstMapSlot[i].UserInstance.Send(JsonMessageHostedMapInfo);
                    }
            }

 

And Send method is :

public void Send(string Message)
        {
            this.WssInstance.SendResponseAsync(Message); // WssInstance is  WebSocketSession
        }

Coordinator
Sep 8, 2012 at 12:21 PM

Your sending is async, so the order cannot be ensured.

Sep 8, 2012 at 12:28 PM

Thanks kj,  I'm change to SendResponse  and solve the problem,

Regards,