mirror of
https://github.com/smyalygames/monopoly.git
synced 2025-05-18 14:24:12 +02:00
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace Mirror
|
|
{
|
|
public class NetworkConnectionToClient : NetworkConnection
|
|
{
|
|
static readonly ILogger logger = LogFactory.GetLogger<NetworkConnectionToClient>();
|
|
|
|
public NetworkConnectionToClient(int networkConnectionId) : base(networkConnectionId) { }
|
|
|
|
public override string address => Transport.activeTransport.ServerGetClientAddress(connectionId);
|
|
|
|
internal override void Send(ArraySegment<byte> segment, int channelId = Channels.DefaultReliable)
|
|
{
|
|
if (logger.LogEnabled()) logger.Log("ConnectionSend " + this + " bytes:" + BitConverter.ToString(segment.Array, segment.Offset, segment.Count));
|
|
|
|
// validate packet size first.
|
|
if (ValidatePacketSize(segment, channelId))
|
|
{
|
|
Transport.activeTransport.ServerSend(connectionId, channelId, segment);
|
|
}
|
|
}
|
|
|
|
/// <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);
|
|
RemoveObservers();
|
|
}
|
|
}
|
|
}
|