Example #1
0
 public void sendPacket(SendBaseGamePacket bp)
 {
     try
     {
         if (this._prepareToClose || this._stream == null)
         {
             return;
         }
         bp.write();
         byte[]      numArray1 = bp.ToByteArray();
         short       num       = Convert.ToInt16(numArray1.Length - 2);
         List <byte> list      = new List <byte>(numArray1.Length + 2);
         list.AddRange((IEnumerable <byte>)BitConverter.GetBytes(num));
         list.AddRange((IEnumerable <byte>)numArray1);
         byte[] buffer    = list.ToArray();
         byte[] numArray2 = new byte[2]
         {
             buffer[2],
             buffer[3]
         };
         if (this.networkDebug)
         {
             ;
         }
         if (buffer.Length > 0)
         {
             this._stream.BeginWrite(buffer, 0, buffer.Length, new AsyncCallback(this.EndSendStaticPacket), (object)null);
         }
     }
     catch (Exception ex)
     {
         CLogger.getInstance().info("[GAME]: read() Exception: \n" + (object)ex);
         this.close();
     }
 }
Example #2
0
 public void sendPacket(SendBaseGamePacket bp)
 {
     try
     {
         bool flag = !this._prepareToClose && this._stream != null;
         if (flag)
         {
             bp.write();
             byte[]      array = bp.ToByteArray();
             short       value = Convert.ToInt16(array.Length - 2);
             List <byte> list  = new List <byte>(array.Length + 2);
             list.AddRange(BitConverter.GetBytes(value));
             list.AddRange(array);
             byte[] array2  = list.ToArray();
             byte[] expr_65 = new byte[]
             {
                 array2[2],
                 array2[3]
             };
             byte[] array3 = list.ToArray();
             byte[] value2 = new byte[]
             {
                 array3[2],
                 array3[3]
             };
             ushort num   = BitConverter.ToUInt16(value2, 0);
             bool   flag2 = this.networkDebug;
             if (flag2)
             {
                 CLogger.getInstance().console("-------------------------------------------------------------------------------");
                 CLogger.getInstance().packet("Send: " + array2.Length);
                 CLogger.getInstance().packet("Opcode [Send Game]: " + num);
                 CLogger.getInstance().console("-------------------------------------------------------------------------------");
                 CLogger.getInstance().sendpacket(Utils.HexDump(array2));
                 CLogger.getInstance().console("-------------------------------------------------------------------------------");
             }
             bool flag3 = array2.Length != 0;
             if (flag3)
             {
                 this._stream.BeginWrite(array2, 0, array2.Length, new AsyncCallback(this.EndSendStaticPacket), null);
             }
         }
     }
     catch (Exception arg)
     {
         CLogger.getInstance().info("[GameClient] read() Exception: \n" + arg);
         this.close();
     }
 }