mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-06 17:58:05 +02:00
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
89 lines
2.3 KiB
C#
89 lines
2.3 KiB
C#
using System;
|
|
using System.Net;
|
|
|
|
namespace Robust.Shared.Network
|
|
{
|
|
/// <summary>
|
|
/// Arguments for NetChannel events.
|
|
/// </summary>
|
|
[Virtual]
|
|
public class NetChannelArgs : EventArgs
|
|
{
|
|
/// <summary>
|
|
/// The channel causing the event.
|
|
/// </summary>
|
|
public readonly INetChannel Channel;
|
|
|
|
/// <summary>
|
|
/// Constructs a new instance.
|
|
/// </summary>
|
|
/// <param name="channel">The channel causing the event.</param>
|
|
public NetChannelArgs(INetChannel channel)
|
|
{
|
|
Channel = channel;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Arguments for incoming connection event.
|
|
/// </summary>
|
|
public sealed class NetConnectingArgs : EventArgs
|
|
{
|
|
public bool IsDenied => DenyReason != null;
|
|
|
|
public string? DenyReason { get; private set; }
|
|
|
|
public NetUserData UserData { get; }
|
|
|
|
/// <summary>
|
|
/// The IP of the incoming connection.
|
|
/// </summary>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructs a new instance.
|
|
/// </summary>
|
|
/// <param name="data">The user data of the incoming connection.</param>
|
|
/// <param name="ip"></param>
|
|
/// <param name="authType">The type of authentication to use when connecting.</param>
|
|
public NetConnectingArgs(NetUserData data, IPEndPoint ip, LoginType authType)
|
|
{
|
|
UserData = data;
|
|
IP = ip;
|
|
AuthType = authType;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Arguments for a failed connection attempt.
|
|
/// </summary>
|
|
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; }
|
|
}
|
|
}
|