コード例 #1
0
        void OnReceived(Object sender, ReceivedEventArgs e)
        {
            var session = sender as ISocketSession;

            if (session == null)
            {
                var ns = sender as INetSession;
                if (ns == null)
                {
                    return;
                }
                session = ns.Session;
            }

            if (NetConfig.Current.ShowReceiveString)
            {
                var line = e.ToStr();
                XTrace.WriteLine(line);

                if (BizLog != null)
                {
                    BizLog.Info(line);
                }
            }
        }
コード例 #2
0
ファイル: ApiServer.cs プロジェクト: wwkkww1983/AhnqIot
        public void Process(ISocketSession session, ReceivedEventArgs e)
        {
            string package = e.ToStr();
            var    client  = session;

            var id = Guid.NewGuid().ToString();

            //缓存客户端会话
            RemoteSessionHelper.RemoteSessionCache.AddOrUpdate(id,
                                                               key => null,
                                                               (key, oldValue) =>
            {
                if (!oldValue.Disposed)
                {
                    oldValue.Dispose();
                }
                return(client);
            });
            //将数据包封装后放到redis中
            var dataPackage = new DataPacket {
                Id = id, Data = package, Date = DateTime.Now
            };                                                                                 //对当前接受数据进行封装

            _redisClient.ListAdd(RedisKeyString.PackageList, dataPackage, DataType.Protobuf);
            //数据包处理结束
        }
コード例 #3
0
 void Client_Received(object sender, ReceivedEventArgs e)
 {
     if (Received != null)
     {
         Received(this, new EventArgs <String>(e.ToStr()));
     }
 }
コード例 #4
0
ファイル: MQServer.cs プロジェクト: yuyu2you/X_NET20
        protected override void OnReceive(ReceivedEventArgs e)
        {
            base.OnReceive(e);

            var str = e.ToStr();

            var act = str.Substring(null, "+");

            str = str.Substring("+");

            switch (act)
            {
            case "Name":
                OnName(str);
                break;

            case "Public":
                OnPublic(str);
                break;

            case "Subscribe":
                OnSubscribe(str);
                break;

            case "Message":
                OnMessage(str);
                break;

            default:
                WriteLog("MQ会话收到:{0} {1}", act, str);
                break;
            }
        }
コード例 #5
0
        private static void Svr_Received(Object sender, ReceivedEventArgs e)
        {
            Console.WriteLine(e.ToStr());

            var ss = sender as INetSession;

            ss.Send("收到 {0}".F(DateTime.Now));
        }
コード例 #6
0
ファイル: LogServer.cs プロジェクト: yuyu2you/X_NET20
            /// <summary>已重载。</summary>
            /// <param name="e"></param>
            protected override void OnReceive(ReceivedEventArgs e)
            {
                if (e.Length == 0)
                {
                    return;
                }

                WriteLog("{0}", e.ToStr());
            }
コード例 #7
0
        void ServerSession_Received(object sender, ReceivedEventArgs e)
        {
            var str = e.ToStr();

            XTrace.WriteLine("----------服务端接收:" + str);
            if (str.StartsWith("echo:"))
            {
                var session = sender as ISocketSession;
                session.Send(str);
            }
        }
コード例 #8
0
 void ClientSession_Received(object sender, ReceivedEventArgs e)
 {
     XTrace.WriteLine("==========客户端接收:" + e.ToStr());
 }
コード例 #9
0
 private static void Svr_Received(Object sender, ReceivedEventArgs e)
 {
     XTrace.WriteLine(e.ToStr());
 }
コード例 #10
0
ファイル: Program.cs プロジェクト: zzmzaizai/X
 static void svr_Received(object sender, ReceivedEventArgs e)
 {
     XTrace.WriteLine(e.ToStr());
 }