quantum-space-buddies/Mirror/Runtime/NetworkConnectionToClient.cs
2021-12-27 22:31:23 -08:00

36 lines
1.3 KiB
C#

using System;
namespace Mirror
{
public class NetworkConnectionToClient : NetworkConnection
{
public override string address =>
Transport.activeTransport.ServerGetClientAddress(connectionId);
// unbatcher
public Unbatcher unbatcher = new Unbatcher();
public NetworkConnectionToClient(int networkConnectionId)
: base(networkConnectionId) {}
// Send stage three: hand off to transport
protected override void SendToTransport(ArraySegment<byte> segment, int channelId = Channels.Reliable) =>
Transport.activeTransport.ServerSend(connectionId, segment, channelId);
/// <summary>Disconnects this connection.</summary>
public override void Disconnect()
{
// set not ready and handle clientscene disconnect in any case
// (might be client or host mode here)
isReady = false;
Transport.activeTransport.ServerDisconnect(connectionId);
// IMPORTANT: NetworkConnection.Disconnect() is NOT called for
// voluntary disconnects from the other end.
// -> so all 'on disconnect' cleanup code needs to be in
// OnTransportDisconnect, where it's called for both voluntary
// and involuntary disconnects!
}
}
}