Example #1
0
 /// <summary>
 /// 消息处理过程
 /// </summary>
 public void ProcessMsg(IMsgPack msg)
 {
     if (onProcessMsg != null)
     {
         onProcessMsg.ProcessMsg(msg);
     }
 }
Example #2
0
 /// <summary>
 /// 同步发送消息
 /// </summary>
 public void SendMsgSync(IMsgPack msg)
 {
     if (MsgHandler == null)
     {
         MsgHandler = new MsgHandlerBase(this, this);
     }
     MsgHandler.SendMsgSync(msg);
 }
Example #3
0
 /// <summary>
 /// 同步发送消息
 /// </summary>
 public void SendMsgSync(IMsgPack msg)
 {
     if (msg == null)
     {
         return;
     }
     if (msg.Sender == null)
     {
         msg.Sender = Owner;
     }
     MsgEngine.Instance.SendMsgSync(msg);
 }
Example #4
0
 protected void SendMsg(HandlerLink link, IMsgPack msg)
 {
     while (link != null)
     {
         if (link.Handler != null)
         {
             try {
                 link.Handler.ProcessMsg(msg);
             } catch (System.Exception e) {
                 this.LOG("SendMsg: " + e.Message);
             }
         }
         link = link.Next;
     }
 }
Example #5
0
        // 通信結果解析.通信結果として返ってきたクラス(Roc〜)を特定する.
        private static List <KeyValuePair <ServerClassCode, IMsgPack> > ParseResultObjects(System.Object[] result)
        {
            var resFullCache = new List <KeyValuePair <ServerClassCode, IMsgPack> >();

            if (result.Length <= 1)
            {
                return(resFullCache);               // RocResultCode しかない場合
            }

            ServerClassCode classCode;

            System.Object[] objList;
            for (int i = 1; i < result.Length; i++)
            {
                IMsgPack ro = null;
                try{
                    objList   = (System.Object[])result[i];
                    classCode = ServerClassCodeHelper.Parse(Convert.ToInt32(objList[0])); // 通信結果クラスをenumで特定して、
                    ro        = classCode.CreateInstance();                               // 特定したenumを基にクラスを生成.
                }catch {
                    Debug.LogError("[NetResponse] Parse Error!! : class code");
                    continue;
                }
                if (ro == null)
                {
                    Debug.LogError("[NetResponse] Parse Error!! : source = " + Convert.ToInt32(objList[0]).ToString() + ", class code = " + classCode.ToString());
                    continue;
                }

                try{
                    ro.Parse(objList);                          // ここで中身の解析.
                }catch {
                    Debug.LogError("[NetResponse] Parse Error!! : " + classCode.ToString());
                    continue;
                }

                var res = new KeyValuePair <ServerClassCode, IMsgPack>(classCode, ro);
                resFullCache.Add(res);
                Debug.Log("Parse RO : " + classCode.ToString());
            }

            return(resFullCache);
        }
Example #6
0
 /// <summary>
 /// 消息处理过程
 /// </summary>
 public virtual void ProcessMsg(IMsgPack msg)
 {
     if (msg.MsgID == MsgConst.GameDestory)
     {
         this.LOG("MsgEngine: Msg GameDestory.");
         //If we are running in the editor
                         #if UNITY_EDITOR
         //Stop playing the scene
         UnityEditor.EditorApplication.isPlaying = false;
                         #else
         Application.Quit();
                         #endif
     }
     else if (msg.MsgID == MsgConst.GameEnd)
     {
         this.LOG("MsgEngine: Msg GameEnd.");
         SendMsg(new MsgBase(MsgConst.GameDestory));
     }
 }
Example #7
0
        IEnumerator MessageQueue()
        {
            WaitUntil waitUnitl = new WaitUntil(ExistNewMsg);
            int       wref      = 0;

            while (true)
            {
                if (IsPause || MsgQueue.Count == 0)
                {
                    wref = 0;
                    if (waitUnitl == null)
                    {
                        waitUnitl = new WaitUntil(ExistNewMsg);
                    }
                    yield return(waitUnitl);
                }
                else
                {
                    wref++;
                    if (wref > SpeedRatio)
                    {
                        if (IsDestroying)
                        {
                            yield break;
                        }
                        else
                        {
                            yield return(null);
                        }
                        wref = 0;
                    }
                }

                IMsgPack msg = MsgQueue.Dequeue();
                object   o   = MsgHandlerMap [msg.MsgID];
                if (o != null)
                {
                    SendMsg(o as HandlerLink, msg);
                }

                //StartCoroutine(SendMessage(MsgQueue.Dequeue()));
            }
        }
Example #8
0
        public override void ProcessMsg(IMsgPack msg)
        {
            DropDragMsg dragMsg = null;

            switch (msg.MsgID)
            {
            case (int)DropDragMsgID.drg_Start:
                break;

            case (int)DropDragMsgID.drg_Draging:
                break;

            case (int)DropDragMsgID.drg_End:
                dragMsg = msg as DropDragMsg;
                if (dragMsg.rayTarget == gameObject)
                {
                    dragMsg.gameObject.transform.SetParent(this.transform);
                    // 发送一个接受消息
                    msg.MsgID = (int)DropDragMsgID.drg_AccetDrop;
                    SendMsg(msg);
                }
                break;
            }
        }
Example #9
0
 // 消息处理
 public override void ProcessMsg(IMsgPack msg)
 {
     if (msg.MsgID == (int)DialogMsgID.show)
     {
         DialogMsg v = (DialogMsg)msg;
         if (v is DialogShowMsg)
         {
             // 如果设置了事件,将事件加入事件表中
             System.Action <GameObject> onEvent = ((DialogShowMsg)v).onCloseEvent;
             if (onEvent != null && !dialogCloseEvent.ContainsKey(v.name))
             {
                 dialogCloseEvent.Add(v.name, onEvent);
             }
         }
         ShowDialog(v.name);
     }
     else if (msg.MsgID == (int)DialogMsgID.hide)
     {
         DialogMsg v = (DialogMsg)msg;
         HideDialog(v.name);
     }
     else if (msg.MsgID == (int)DialogMsgID.close)
     {
         DialogMsg v = (DialogMsg)msg;
         CloseDialog(v.name);
     }
     else if (msg.MsgID == (int)DialogMsgID.add)
     {
         DialogAddMsg v = (DialogAddMsg)msg;
         AddDialog(v.name, v.prebs);
     }
     else if (msg.MsgID == (int)DialogMsgID.closed)
     {
         ClosedDialog(((DialogClosedMsg)msg).dlg);
     }
 }
Example #10
0
 public override void ProcessMsg(IMsgPack msg)
 {
     this.LOG(msg.Sender.GetType().Name + ": MsgID = " + msg.MsgID);
 }
Example #11
0
 public override void ProcessMsg(IMsgPack msg)
 {
     throw new System.NotImplementedException();
 }
Example #12
0
 public override void ProcessMsg(IMsgPack msg)
 {
 }
Example #13
0
 /// <summary>
 /// 消息处理过程
 /// </summary>
 public abstract void ProcessMsg(IMsgPack msg);
Example #14
0
 /// <summary>
 /// 同步发送消息 (此处不在做参数正确性检查,请在消息处理器中确保msg的合法性)
 /// </summary>
 public void SendMsgSync(IMsgPack msg)
 {
     SendMsg(GetHandlerLink(msg.MsgID), msg);
 }
Example #15
0
 /// <summary>
 /// 发送消息 (此处不在做参数正确性检查,请在消息处理器中确保msg的合法性)
 /// </summary>
 public void SendMsg(IMsgPack msg)
 {
     MsgQueue.Enqueue(msg);
 }