예제 #1
0
 override public void ParseSendData()
 {
     lock (SendData)
     {
         if (SendData.Length - SendDataIndex < 4)
         {
             return;
         }
         SendData.Seek(SendDataIndex, SeekOrigin.Begin);
         int length = (SendData.ReadByte() << 24) + (SendData.ReadByte() << 16) + (SendData.ReadByte() << 8) + SendData.ReadByte();
         if (length + 8 > SendData.Length - SendDataIndex)
         {
             return;
         }
         byte[] data   = new byte[length];
         byte[] header = new byte[24];
         SendData.Seek(SendDataIndex, SeekOrigin.Begin);
         SendData.Read(header, 0, 24);
         SendData.Read(data, 0, length);
         SendDataIndex = SendData.Position;
         if (SendData.Length == SendDataIndex)
         {
             SendData      = new MemoryStream();
             SendDataIndex = 0;
         }
         try
         {
             CNameObjDict co = ParseAMF3(data);
             OutPut("\r\nSendData:\r\n" + co.ToString());
         }
         catch (Exception e) { OutPut("send err:" + e.Message); }
     }
 }
예제 #2
0
 public override bool ParseStream(NetworkStream ns)
 {
     try
     {
         if (!ns.DataAvailable)
         {
             return(false);
         }
         int    len  = (ns.ReadByte() << 24) + (ns.ReadByte() << 16) + (ns.ReadByte() << 8) + ns.ReadByte();
         byte[] data = new byte[len];
         byte[] head = new byte[4];
         ns.Read(head, 0, 4);
         ns.Read(data, 0, len);
         MyAuxiliary.OutPut(Inspector.Inspect(data));
         if (data[0] == 10 && data[1] == 11 && data[2] == 1 && data[3] == 7)
         {
             CNameObjDict co = ((CNameObjDict)CAmf3Helper.GetObject(data));
             MyAuxiliary.OutPut(co.ToString());
             ParseData(co);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
     return(true);
 }
예제 #3
0
 override public void ParseReceiveData()
 {
     lock (ReceiveData)
     {
         if (ReceiveData.Length - ReceiveIndex < 4)
         {
             return;
         }
         ReceiveData.Seek(ReceiveIndex, SeekOrigin.Begin);
         int length = (ReceiveData.ReadByte() << 24) + (ReceiveData.ReadByte() << 16) + (ReceiveData.ReadByte() << 8) + ReceiveData.ReadByte();
         if (length + 8 > ReceiveData.Length - ReceiveIndex)
         {
             return;
         }
         byte[] data   = new byte[length];
         byte[] header = new byte[8];
         ReceiveData.Seek(ReceiveIndex, SeekOrigin.Begin);
         ReceiveData.Read(header, 0, 8);
         ReceiveData.Read(data, 0, length);
         ReceiveIndex = ReceiveData.Position;
         if (ReceiveData.Length == ReceiveIndex)
         {
             ReceiveData  = new MemoryStream();
             ReceiveIndex = 0;
         }
         try
         {
             CNameObjDict co = ParseAMF3(data);
             if (co.ContainsKey("callback"))
             {
                 if (((CNameObjDict)co["callback"])["callbackName"].ToString() == "re.chat.getMsg")
                 {
                     return;
                 }
             }
             OutPut("\r\nReceiveData:\r\n" + co.ToString());
         }
         catch { }
     }
 }
예제 #4
0
 public void ParseUser(CNameObjDict co)
 {
     g.OutPut(co.ToString());
 }