Пример #1
0
        private void Deserialize(byte[] dataBytes, int dataLen)
        {
            NetAdapter.DeserializeData deserializeData = adapter.Deserialize(dataBytes, dataLen);
            if (deserializeData != null)
            {
                //Debugger.Log("recv pmsg 2->" + deSerializationData.toScript + "^" + deSerializationData.Data);
                if (deserializeData.toScript)
                {
#if JSSCRIPT
                    MessagePool.ScriptSendMessage(null, MessagePool.OnNetMessageArrived, Message.FilterTypeNothing, (string)deSerializationData.Data);
#elif LUASCRIPT
                    //MessagePool.CSSendMessage(null, MessagePool.OnNetMessageArrived, Message.FilterTypeNothing, new RecvData() { node = this, data = deSerializationData });
                    ThreadTask.QueueOnMainThread(() =>
                    {
                        CallLuaRecvFunc(deserializeData);
                        NetMsgPool.RecycleMsg(deserializeData.data);
                        deserializeData.data = null;
                    });
#endif
                }
                else
                {
                    //MessagePool.CSSendMessage(null, csNetGID, Message.FilterTypeNothing, deserializeData.data);
                    NetMsgPool.RecycleMsg(deserializeData.data);
                    deserializeData.data = null;
                }
            }
        }
Пример #2
0
 private static void CallLuaRecvFunc(NetAdapter.DeserializeData data)
 {
     if (protoBufCall != null)
     {
         LuaManager.CallFunc_V(protoBufCall, data.data.get_tid(), data.data.get_gid(), data.data.get_uid(), data.data.get_data(), data.data.get_datalen());
     }
 }
Пример #3
0
 private void CallLuaRecvFunc(NetAdapter.DeserializeData data)
 {
     //Debugger.Log("recv msg call lua func->" + (recvMsgCall == null));
     if (recvMsgCall != null)
     {
         LuaManager.CallFunc_V(recvMsgCall, data.data.get_tid(), data.data.get_gid(), data.data.get_uid(), data.data.get_data(), data.data.get_datalen());
     }
     //Debugger.Log("recv msg call lua func 1");
 }
Пример #4
0
 private void CallLuaRecvFunc(NetAdapter.DeserializeData data)
 {
     if (Config.Detail_Debug_Log())
     {
         Debug.Log("recv server msg push to lua->" + data.data.get_tid() + "^" + data.data.get_gid() + "^" + data.data.get_uid() + "^" + data.data.get_datalen() + "^" + (recvMsgCall == null));
     }
     if (recvMsgCall != null)
     {
         LuaManager.CallFunc_V(recvMsgCall, data.data.get_tid(), data.data.get_gid(), data.data.get_uid(), data.data.get_data(), data.data.get_datalen());
     }
 }
Пример #5
0
        private static IEnumerator HttpGetSendBackProtoBuf(string url)
        {
            WWW www = new WWW(url);

            yield return(www);

            if (www.error != null)
            {
                Debugger.LogError("http get send error->" + www.error);
            }
            else
            {
                if (www.bytes != null)
                {
                    NetAdapter.DeserializeData recvData = adapter.Deserialize(www.bytes, www.bytes.Length);
                    CallLuaRecvFunc(recvData);
                }
            }

            www.Dispose();
        }
Пример #6
0
        private void Deserialize(byte[] dataBytes, int dataLen)
        {
            if (Config.Detail_Debug_Log())
            {
                Debug.Log("---------net client deserialize msg data 1->" + dataBytes + "^" + dataLen);
            }

            if (Config.Detail_Debug_Log())
            {
                Debug.LogError("/////////////////////////////////////////////////////////////////////");
                StringBuilder sb = new StringBuilder();
                if (dataBytes != null)
                {
                    int num = 0;
                    for (int i = 0; i < dataLen; i++)
                    {
                        sb.Append(dataBytes[i].ToString("X2"));
                        sb.Append(" ");
                        if (num >= 10)
                        {
                            sb.Append("\r\n");
                            num = 0;
                        }
                        num++;
                    }

                    Debug.LogError(sb.ToString());
                }
                Debug.LogError("*********************************************************************");
            }

            NetAdapter.DeserializeData deserializeData = adapter.Deserialize(dataBytes, dataLen);

            if (Config.Detail_Debug_Log())
            {
                Debug.Log("---------net client deserialize msg data 2->" + (deserializeData == null));
            }

            if (deserializeData != null)
            {
                if (deserializeData.toScript)
                {
#if JSSCRIPT
                    MessagePool.ScriptSendMessage(null, MessagePool.OnNetMessageArrived, Message.FilterTypeNothing, (string)deSerializationData.Data);
#elif LUASCRIPT
                    if (Config.Detail_Debug_Log())
                    {
                        Debug.Log("---------net client deserialize msg data 3->" + (deserializeData.data == null));

                        if (deserializeData.data != null)
                        {
                            Debug.Log("----------------------net client deserialize msg data 10->" + deserializeData.data.get_tid() + "^" + deserializeData.data.get_gid() + "^" + deserializeData.data.get_uid() + "^" + deserializeData.data.get_datalen());
                        }
                    }


                    ThreadTask.QueueOnMainThread(() =>
                    {
                        if (Config.Detail_Debug_Log())
                        {
                            Debug.Log("---------net client deserialize msg data 4->" + (deserializeData.data == null ? -1 : (deserializeData.data.get_data() == null ? -2 : 1)));
                            if (deserializeData.data != null)
                            {
                                Debug.Log("----------------------net client deserialize msg data 11->" + deserializeData.data.get_tid() + "^" + deserializeData.data.get_gid() + "^" + deserializeData.data.get_uid() + "^" + deserializeData.data.get_datalen());
                            }
                        }

                        CallLuaRecvFunc(deserializeData);
                        NetMsgPool.RecycleMsg(deserializeData.data);
                        deserializeData.data = null;
                    });
#endif
                }
                else
                {
                    NetMsgPool.RecycleMsg(deserializeData.data);
                    deserializeData.data = null;
                }
            }
        }