/**********************************************************
  *
  *  接收队列处理模块
  *
  *********************************************************/
 //推送数据
 private void ReceivedThreadStart()
 {
     while (true)
     {
         recvbuffblockEvent.WaitOne();
         if (ReceivedEvent != null)
         {
             icPacket packet = null;
             lock (Synrecv)
             {
                 if (recvbuff.Count > 0)
                 {
                     packet = recvbuff.Dequeue();
                 }
                 else
                 {
                     recvbuffblockEvent.Reset();
                 }
             }
             if ((packet != null) && (packet.data != null))
             {
                 ReceivedobjEventArgs e = new ReceivedobjEventArgs(packet.data);
                 e.Appid    = packet.Appid;
                 e.Serverid = packet.Serverid;
                 ReOriginData(e);
                 ReceivedEvent(e);
             }
         }
         else
         {
             recvbuffblockEvent.Reset();
         }
     }
 }
Example #2
0
 protected override void ReOriginData(ReceivedobjEventArgs e)
 {
     base.ReOriginData(e);
     PacketManaged data = (PacketManaged)e.Data;
     if (data.SerializedData != null)
     {
         MemoryStream stream = new MemoryStream(data.SerializedData);
         data.UnSerializedData = rformatter.Deserialize(stream);
         data.SerializedData = null;
     }
 }
        protected override void ReOriginData(ReceivedobjEventArgs e)
        {
            base.ReOriginData(e);
            PacketManaged data = (PacketManaged)e.Data;

            if (data.SerializedData != null)
            {
                MemoryStream stream = new MemoryStream(data.SerializedData);
                data.UnSerializedData = rformatter.Deserialize(stream);
                data.SerializedData   = null;
            }
        }
 /// <summary>
 /// 主动从接受缓存读取数据。对多线程安全。当ReceivedEvent未设置时启用,如果没数据,或设置了ReceivedEvent,将自动阻塞线程
 /// </summary>
 /// <returns>接受到的数据包</returns>
 public ReceivedobjEventArgs GetData()
 {
     getrecvbuffblockEvent.WaitOne();
     if (ReceivedEvent == null)
     {
         icPacket packet = null;
         lock (Synrecv)
         {
             if (recvbuff.Count > 0)
             {
                 packet = recvbuff.Dequeue();
             }
             else
             {
                 getrecvbuffblockEvent.Reset();
             }
         }
         if ((packet != null) && (packet.data != null))
         {
             ReceivedobjEventArgs e = new ReceivedobjEventArgs(packet.data);
             e.Appid    = packet.Appid;
             e.Serverid = packet.Serverid;
             ReOriginData(e);
             return(e);
         }
         else
         {
             return(null);
         }
     }
     else
     {
         getrecvbuffblockEvent.Reset();
         return(null);
     }
 }
Example #5
0
        protected virtual void ReOriginData(ReceivedobjEventArgs e)
        {

        }
Example #6
0
 /**********************************************************
  * 
  *  接收队列处理模块
  * 
  *********************************************************/
 //推送数据
 private void ReceivedThreadStart()
 {
     while (true)
     {
         recvbuffblockEvent.WaitOne();
         if (ReceivedEvent != null)
         {
             icPacket packet = null;
             lock (Synrecv)
             {
                 if (recvbuff.Count > 0)
                     packet = recvbuff.Dequeue();
                 else
                     recvbuffblockEvent.Reset();
             }
             if ((packet != null) && (packet.data != null))
             {
                 ReceivedobjEventArgs e = new ReceivedobjEventArgs(packet.data);
                 e.Appid = packet.Appid;
                 e.Serverid = packet.Serverid;
                 ReOriginData(e);
                 ReceivedEvent(e);
             }
         }
         else
            recvbuffblockEvent.Reset();
     }
 }
Example #7
0
 /// <summary>
 /// 主动从接受缓存读取数据。对多线程安全。当ReceivedEvent未设置时启用,如果没数据,或设置了ReceivedEvent,将自动阻塞线程
 /// </summary>
 /// <returns>接受到的数据包</returns>
 public ReceivedobjEventArgs GetData()
 {
     getrecvbuffblockEvent.WaitOne();
     if (ReceivedEvent == null)
     {
         icPacket packet = null;
         lock (Synrecv)
         {
             if (recvbuff.Count > 0)
                 packet = recvbuff.Dequeue();
             else
                 getrecvbuffblockEvent.Reset();
         }
         if ((packet != null) && (packet.data != null))
         {
             ReceivedobjEventArgs e = new ReceivedobjEventArgs(packet.data);
             e.Appid = packet.Appid;
             e.Serverid = packet.Serverid;
             ReOriginData(e);
             return e;
         }
         else
         {
             return null;
         }
     }
     else
     {
         getrecvbuffblockEvent.Reset();
         return null;
     }
 }
 protected virtual void ReOriginData(ReceivedobjEventArgs e)
 {
 }
Example #9
0
 void cc_ReceivedEvent(ReceivedobjEventArgs e)
 {
     //             if (this.InvokeRequired)
     //             {
     //                 InvokeReceivedEvent ivo = new InvokeReceivedEvent(this.cc_ReceivedEvent);
     //                 this.Invoke(ivo, e);
     //             }
     //             else
     //             {
         handlereceivedata(((testpacket)e.Data));
     /*            }*/
 }