/// <summary>
        /// 分配返回数据
        /// </summary>
        private void Process()
        {
            //取出请求ID
            Console.WriteLine("DataSrvAdapter处理线程运行中");
            SrvDataSource source = null;

            while (!queue.IsEmpty)
            {
                Console.WriteLine("DataSrvAdapter接收数处理中");
                if (queue.TryDequeue(out source))
                {
                    var buf = source.Message as IByteBuffer;
                    if (buf != null)
                    {
                        source.ID = buf.ReadLongLE();
                        byte[] rev = new byte[buf.ReadableBytes];
                        buf.ReadBytes(rev);
                        source.Message = rev;
                        Console.WriteLine("DataSrvAdapter接收数据:" + (rev.Length + 8));
                        Console.WriteLine("DataSrvAdapter接收数据通信ID:" + source.ID);
                        if (SrvDataNotify != null)
                        {
                            SrvDataNotify(this, source);
                        }
                        else
                        {
                            block.Add(source);
                        }
                        buf.Release();
                    }
                }
            }
        }
Beispiel #2
0
 private void SimpleClient_DataNotity(object sender, object msg, string flage = null)
 {
     if (DataNotify != null)
     {
         DataNotify(this, msg, flage);
         Console.WriteLine("客户端推送数据");
     }
     else
     {
         SrvDataSource source = new SrvDataSource()
         {
             Context = sender, Message = msg
         };
         queue.Add(source);
     }
 }
Beispiel #3
0
 private void SimpleServer_DataNotity(object sender, object msg, string flage = null)
 {
     if (DataNotify != null)
     {
         DataNotify(sender, msg, NettySrvFlage);
     }
     else
     {
         SrvDataSource item = new SrvDataSource()
         {
             Context = sender,
             Message = msg,
             Flage   = NettySrvFlage
         };
         queue.Add(item);
     }
 }
 private void Server_DataNotify(object sender, object msg, string flage)
 {
     if (DataNotify != null)
     {
         Console.WriteLine("NettySrvManager推送数据");
         DataNotify(sender, msg, flage);
     }
     else
     {
         SrvDataSource source = new SrvDataSource()
         {
             Context = sender,
             Message = msg,
             Flage   = flage
         };
         block.Add(source);
     }
 }
        private void Singleton_DataNotify(object sender, object msg, string flage = null)
        {
            //事件收回数据,不影响网络传输
            SrvDataSource source = new SrvDataSource()
            {
                Context = sender,
                Message = msg,
                Flage   = flage
            };

            Console.WriteLine("DataSrvAdapter数据注入集合");
            queue.Enqueue(source);
            Interlocked.Increment(ref ReqCount);
            if (!IsControlRun)
            {
                Console.WriteLine("DataSrvAdapter调度线程运行中");
                AdapterThread();
            }
        }