mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-30 21:17:09 +01:00
CHANGED TO MIRROR
This commit is contained in:
35
Assets/Mirror/Runtime/NetworkConnectionToClient.cs
Normal file
35
Assets/Mirror/Runtime/NetworkConnectionToClient.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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!
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user