static private PackProtocol ( byte buffer, NetPacketType type, byte firstParam, byte secondParam ) : int | ||
buffer | byte | |
type | NetPacketType | |
firstParam | byte | |
secondParam | byte | |
return | int |
/// <summary> /// Sends a generic pong packet. /// </summary> internal SocketError SendPong(NetPeer peer, byte pingSeq, byte drop) { lock (sendLock) { var length = NetEncoding.PackProtocol(sendBuffer, NetPacketType.Pong, pingSeq, drop); return(TrySend(peer.EndPoint, sendBuffer, length)); } }
/// <summary> /// Sends a generic ping packet. /// </summary> internal SocketError SendPing(NetPeer peer, long curTime) { lock (sendLock) { var length = NetEncoding.PackProtocol(sendBuffer, NetPacketType.Ping, peer.GeneratePing(curTime), peer.GenerateLoss()); return(TrySend(peer.EndPoint, sendBuffer, length)); } }
/// <summary> /// Accepts a remote request and sends an affirmative reply. /// </summary> internal SocketError SendAccept(NetPeer peer) { lock (sendLock) { var length = NetEncoding.PackProtocol(sendBuffer, NetPacketType.Accept, 0, 0); return(TrySend(peer.EndPoint, sendBuffer, length)); } }
/// <summary> /// Notifies a peer that we are disconnecting. May not arrive. /// </summary> internal SocketError SendKick(NetPeer peer, NetCloseReason reason, byte userReason = 0) { // Skip the packet if it's a bad reason (this will cause error output) if (NetUtil.ValidateKickReason(reason) == NetCloseReason.INVALID) { return(SocketError.Success); } lock (sendLock) { var length = NetEncoding.PackProtocol(sendBuffer, NetPacketType.Kick, (byte)reason, userReason); return(TrySend(peer.EndPoint, sendBuffer, length)); } }
/// <summary> /// Sends a kick (reject) message to an unconnected peer. /// </summary> internal SocketError SendReject( IPEndPoint destination, NetCloseReason reason) { // Skip the packet if it's a bad reason (this will cause error output) if (NetUtil.ValidateKickReason(reason) == NetCloseReason.INVALID) { return(SocketError.Success); } lock (this.sendLock) { int length = NetEncoding.PackProtocol( this.sendBuffer, NetPacketType.Kick, (byte)reason, 0); return(this.TrySend(destination, this.sendBuffer, length)); } }