public override void Process(Nc2sMessagePacket packet) { AsyncUserToken userToken = packet.Session as AsyncUserToken; userToken.SendAsync(new Ns2cMessagePacket() { ClientID = packet.ClientID, MessageID = packet.MessageID, message = packet.Message, SendTime = packet.SendTime, }); }
public void Send(Packet iPacket) { lock (sendSync) { AsyncUserToken oAsyncUserToken = null; if (AsyncSocketUserTokenUsed.TryGetValue(iPacket.OwnerID1, out oAsyncUserToken)) { ByteArray oByteArray = new ByteArray(); iPacket.Serialization(oByteArray, true); oAsyncUserToken.SendAsync(oByteArray.Bytes); } } }
public override void Process(DaemonPacket packet) { AsyncUserToken socketToken = packet.Session as AsyncUserToken; if (socketToken.IsClient) { Heart.Delayed(packet.TimeNow); } else { socketToken.SendAsync(new DaemonPacket() { TimeNow = packet.TimeNow }); } }
protected bool OnSendAsync(SocketAsyncEventArgs eventArgs) { AsyncUserToken socketToken = eventArgs.UserToken as AsyncUserToken; socketToken.ActiveDateTime = DateTime.Now; if (eventArgs.SocketError == SocketError.Success) { return(socketToken.SendAsync(true)); //调用子类回调函数 } else { CloseSocket(socketToken); return(false); } }