Example #1
0
 private void OnRecvControlData()
 {
     //bool flag = (bool)o;
     PrintInfo("开始接收游戏控制信息...");
     while (!this.m_isNormalExit)
     {
         int    num;
         byte[] numArray;
         try
         {
             num      = (int)this.Reader.ReadUInt16();
             numArray = this.Reader.ReadBytes(num);
         }
         catch (Exception ex)
         {
             PrintInfo(ex.Message);
             if (!this.m_isNormalExit)
             {
                 this.CloseGameCleaning();
             }
             return;
         }
         PrintInfo(string.Format("[control] From MC:{0}", (object)Others.ByteToString(numArray, 0, num)));
         this.HandleMcControlMessage(numArray);
     }
 }
Example #2
0
        //public byte[] HandleSkinMessage(byte[] content)//GameState.gameid, username, profile.getId().toString() Skin
        //{
        //    OtherEnterWorldMsg otherEnterWorldMsg = new OtherEnterWorldMsg();
        //    new SimpleUnpack(content).Unpack(ref otherEnterWorldMsg);
        //    //skinMode  DEFAULT=0 SLIM=1


        //    return SimplePack.Pack((ushort)520, otherEnterWorldMsg.Name, System.Windows.Forms.Application.ExecutablePath + "\\cache\\skin\\", System.Windows.Forms.Application.ExecutablePath + "\\cache\\skin\\", 0);
        //}
        public void SendControlData(byte[] message)
        {
            if (this.NeedChaCha)
            {
                this.send_ccx.Process(message);
            }

            byte[] array = ((IEnumerable <byte>)BitConverter.GetBytes((ushort)message.Length)).Concat <byte>((IEnumerable <byte>)message).ToArray <byte>();
            PrintInfo(string.Format("[control] To MC:{0}", (object)Others.ByteToString(array, 0, Math.Min(64, array.Length))));
            try
            {
                this.Writer.Write(array);
                this.Writer.Flush();
            }
            catch (Exception ex)
            {
                PrintInfo(ex.Message);
                PrintInfo("向MC发送控制信息失败");
            }
        }