mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
36 lines
1.3 KiB
C#
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!
|
|
}
|
|
}
|
|
}
|