using FishNet.Managing;
using FishNet.Managing.Logging;
using FishNet.Managing.Server;
using FishNet.Serializing;
using System;
namespace FishNet.Connection
{
///
/// A container for a connected client used to perform actions on and gather information for the declared client.
///
public partial class NetworkConnection : IEquatable
{
#region Public.
///
/// Returns true if this connection is a clientHost.
///
public bool IsHost => (NetworkManager == null) ? false : (NetworkManager.IsServer && (this == NetworkManager.ClientManager.Connection));
///
/// Returns if this connection is for the local client.
///
public bool IsLocalClient => (NetworkManager == null) ? false : (NetworkManager.ClientManager.Connection == this);
#endregion
///
/// Returns the address of this connection.
///
///
public string GetAddress()
{
if (!IsValid)
return string.Empty;
if (NetworkManager == null)
return string.Empty;
return NetworkManager.TransportManager.Transport.GetConnectionAddress(ClientId);
}
///
/// Kicks a connection immediately while invoking OnClientKick.
///
/// Reason client is being kicked.
/// How to print logging as.
/// Optional message to be debug logged.
public void Kick(KickReason kickReason, LoggingType loggingType = LoggingType.Common, string log = "")
{
NetworkManager.ServerManager.Kick(this, kickReason, loggingType, log);
}
///
/// Kicks a connection immediately while invoking OnClientKick.
///
/// Reader to clear before kicking.
/// Reason client is being kicked.
/// How to print logging as.
/// Optional message to be debug logged.
public void Kick(Reader reader, KickReason kickReason, LoggingType loggingType = LoggingType.Common, string log = "")
{
NetworkManager.ServerManager.Kick(this, reader, kickReason, loggingType, log);
}
}
}