Basic Networking done

This commit is contained in:
2022-01-26 19:10:12 +05:30
parent d852b2bb2c
commit 891318680d
1111 changed files with 105855 additions and 780 deletions

View 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!
}
}
}