using System;
using System.Net;
namespace Robust.Shared.Network
{
///
/// Arguments for NetChannel events.
///
[Virtual]
public class NetChannelArgs : EventArgs
{
///
/// The channel causing the event.
///
public readonly INetChannel Channel;
///
/// Constructs a new instance.
///
/// The channel causing the event.
public NetChannelArgs(INetChannel channel)
{
Channel = channel;
}
}
///
/// Arguments for incoming connection event.
///
public sealed class NetConnectingArgs : EventArgs
{
public bool IsDenied => DenyReason != null;
public string? DenyReason { get; private set; }
public NetUserData UserData { get; }
///
/// The IP of the incoming connection.
///
public NetUserId UserId => UserData.UserId;
public string UserName => UserData.UserName;
public IPEndPoint IP { get; }
public LoginType AuthType { get; }
public void Deny(string reason)
{
DenyReason = reason;
}
///
/// Constructs a new instance.
///
/// The user data of the incoming connection.
///
/// The type of authentication to use when connecting.
public NetConnectingArgs(NetUserData data, IPEndPoint ip, LoginType authType)
{
UserData = data;
IP = ip;
AuthType = authType;
}
}
///
/// Arguments for a failed connection attempt.
///
public sealed class NetConnectFailArgs : EventArgs
{
public NetConnectFailArgs(string reason)
{
Reason = reason;
}
public string Reason { get; }
}
public sealed class NetDisconnectedArgs : NetChannelArgs
{
public NetDisconnectedArgs(INetChannel channel, string reason) : base(channel)
{
Reason = reason;
}
public string Reason { get; }
}
}