コード例 #1
0
    public static void Update()
    {
        if (unHandMsgList != null)
        {
            while (unHandMsgList.Count > 0)
            {
                Pt pt = null;
                if (unHandMsgList.Count > 0)
                {
                    lock (unHandMsgList)
                    {
                        byte[] bts         = unHandMsgList.Dequeue();
                        byte[] bytes_cmdid = new byte[2];
                        byte[] bytes_seq   = new byte[4];
                        byte[] bytes_body  = new byte[bts.Length - 6];
                        ByteAr_b.PickBytes(bts, bytes_cmdid.Length, bytes_cmdid, 0);
                        ByteAr_b.PickBytes(bts, bytes_seq.Length, bytes_seq, 2);
                        ByteAr_b.PickBytes(bts, bytes_body.Length, bytes_body, bytes_cmdid.Length + bytes_seq.Length);

                        ushort head = ByteAr_b.b2us(bytes_cmdid);
                        if (msgStructDic.ContainsKey(head))
                        {
                            pt     = msgStructDic[head].createNew();
                            pt.seq = ByteAr_b.b2ui(bytes_seq);
                            pt.fromBinary(bytes_body);
                        }
                    }
                }

                if (pt != null)
                {
                    if (screen_Debug_Log_S2C)
                    {
                        GameSys.LogInternal("[S] to [C] :" + Convert.ToString(pt.GetID(), 16), false);
                    }
                    if (editor_Debug_Log_S2C)
                    {
                        Debug.Log("[S] to [C] :" + Convert.ToString(pt.GetID(), 16));
                    }
                    MsgHander.ProcComand(pt);
                }
            }
        }
    }