Example #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;
                }
            }
        }
Example #2
0
 void OnApplicationQuit()
 {
     NetworkManager.CloseAll();
     LuaCThread.CloseAll();
     LuaManager.Dispose();
     LuaContext.DisposeAll();
     LuaLoader.GetInstance().Clean();
     MessagePool.ScriptSendMessage("", MessagePool.OnApplicationQuit, Message.FilterTypeNothing, "OnApplicationQuit");
 }
Example #3
0
        private void DoOver()
        {
            Debugger.LogError(">>>>>>>>>>>>>>>>>>>>>>Update Over<<<<<<<<<<<<<<<<<<<<<<<<<<");

            if (doCheckUF != null)
            {
                doCheckUF(1f);
            }

            SetFileLocate();

            over      = true;
            canUpdate = false;

            vfc         = null;
            versionInfo = null;
            if (needUpdateList != null)
            {
                needUpdateList.Clear();
                needUpdateList = null;
            }

            streamingAssetVersionInfo = null;

            if (doUpdateUIOver != null)
            {
                doUpdateUIOver();
                curFileSize = 0;
            }

            if (reMs != null)
            {
                reMs.Dispose();
                reMs = null;
            }

            //load newer lua
            LuaLoader.GetInstance().Reset();

            MessagePool.CSSendMessage(null, MessagePool.UpdateResOver, Message.FilterTypeNothing, "");

            //test
            Dictionary <string, RelationData> .Enumerator e = nameToRelation.GetEnumerator();
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            while (e.MoveNext())
            {
                sb.Append(e.Current.Key);
                sb.Append("\r\n");
            }

            Debug.Log("all version files->" + sb.ToString());
        }
Example #4
0
 private void onError(object sender, EventArgs eventArgs)
 {
     socketStatus = SocketStatus.NotConnet;
     MessagePool.ScriptSendMessage("Socket", MessagePool.SocketEvent, 3, netClientId.ToString());
     Debugger.LogError("Net Error" + ToString());
 }
Example #5
0
 private void onConnected(object sender, EventArgs eventArgs)
 {
     socketStatus = SocketStatus.Ready;
     MessagePool.ScriptSendMessage("Socket", MessagePool.SocketEvent, 1, netClientId.ToString());
     Debugger.Log("Net Connect Success->" + ToString());
 }
Example #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;
                }
            }
        }
Example #7
0
 void OnApplicationPause()
 {
     MessagePool.ScriptSendMessage("", MessagePool.OnApplicationPause, Message.FilterTypeNothing, "OnApplicationPause");
 }
Example #8
0
 void OnApplicationFocus()
 {
     MessagePool.ScriptSendMessage("", MessagePool.OnApplicationFocus, Message.FilterTypeNothing, "OnApplicationFocus");
 }
Example #9
0
        public static void Init()
        {
            bool atlasDataInited = false;
            bool labelDataInited = false;
            bool fontInited      = false;

            if (!uiRootTrans)
            {
                GameObject go = GameObject.Find("UI Root");
                if (go == null)
                {
                    Debugger.LogError("UI Root is null");
                    return;
                }

                Object.DontDestroyOnLoad(go);

                uiRootTrans = go.transform;

                Transform camTrans = uiRootTrans.Find("Camera");
                if (camTrans == null)
                {
                    Debugger.LogError("Cam trans is null");
                    return;
                }

                _camera   = camTrans.GetComponent <Camera>();
                _uiCamera = camTrans.GetComponent <UICamera>();
            }
            else
            {
                fontInited = true;
            }

            System.Action checkOver = () =>
            {
                if (atlasDataInited && labelDataInited && fontInited)
                {
                    List <string> atlases;
                    if (!uiInfo.TryGetValue(UIATLASENAMES, out atlases))
                    {
                        Debugger.LogError(UIATLASDATAFILE + " has no field->" + UIATLASENAMES);
                        return;
                    }

                    List <string> textures;
                    if (!uiInfo.TryGetValue(UITEXTURENAMES, out textures))
                    {
                        Debugger.LogError(UIATLASDATAFILE + " has no field->" + UITEXTURENAMES);
                        return;
                    }

                    UIFrame.Init(atlases, textures);
                    uiInfo.Remove(UIATLASENAMES);
                    uiInfo.Remove(UITEXTURENAMES);

                    Debugger.Log("UI Init Over");
                    MessagePool.CSSendMessage(null, MessagePool.UIInitOver, Message.FilterTypeNothing, null);
                }
            };

            if (!fontInited)
            {
                ResLoader.LoadByName("MSYH", (asset, param) =>
                {
                    if (asset == null)
                    {
                        Debugger.Log("init font failed");
                        return;
                    }

                    comFont = ((GameObject)asset).GetComponent <UIFont>();
                    if (comFont == null)
                    {
                        Debugger.Log("font data not contains UIFont");
                        return;
                    }

                    UIFrame.SetFont(comFont);

                    fontInited = true;

                    checkOver();
                }, null);
            }

            ResLoader.AsynReadBytesByName(UIATLASDATAFILE, (arr, param) =>
            {
                if (arr == null)
                {
                    Debugger.LogError("init UI atlas data failed");
                    return;
                }

                ZLText zlt = new ZLText(arr);
                uiInfo     = zlt.ReadAll();
                zlt.Dispose();

                atlasDataInited = true;

                checkOver();
            }, null, true);

            ResLoader.AsynReadUTF8ByName(UILABELTEXTFILE, (str, param) =>
            {
                if (str == null)
                {
                    Debugger.LogError("init UI label text data failed");
                    return;
                }

                string[] lines = null;
                int index      = str.IndexOf("\r\n");
                if (index >= 0)
                {
                    lines = str.Split(new string[] { "\r\n" }, System.StringSplitOptions.None);
                }
                else
                {
                    lines = str.Split(new string[] { "\n" }, System.StringSplitOptions.None);
                }

                labelTextData.AddRange(lines);
                labelDataInited = true;

                checkOver();
            }, null, true);
        }