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); } } }
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); //数据包处理结束 }
void Client_Received(object sender, ReceivedEventArgs e) { if (Received != null) { Received(this, new EventArgs <String>(e.ToStr())); } }
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; } }
private static void Svr_Received(Object sender, ReceivedEventArgs e) { Console.WriteLine(e.ToStr()); var ss = sender as INetSession; ss.Send("收到 {0}".F(DateTime.Now)); }
/// <summary>已重载。</summary> /// <param name="e"></param> protected override void OnReceive(ReceivedEventArgs e) { if (e.Length == 0) { return; } WriteLog("{0}", e.ToStr()); }
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); } }
void ClientSession_Received(object sender, ReceivedEventArgs e) { XTrace.WriteLine("==========客户端接收:" + e.ToStr()); }
private static void Svr_Received(Object sender, ReceivedEventArgs e) { XTrace.WriteLine(e.ToStr()); }
static void svr_Received(object sender, ReceivedEventArgs e) { XTrace.WriteLine(e.ToStr()); }