// This file is provided under The MIT License as part of RiptideNetworking. // Copyright (c) Tom Weiland // For additional information please see the included LICENSE.md file or view it on GitHub: // https://github.com/RiptideNetworking/Riptide/blob/main/LICENSE.md using System; namespace Riptide { /// Contains event data for when a client connects to the server. public class ServerConnectedEventArgs : EventArgs { /// The newly connected client. public readonly Connection Client; /// Initializes event data. /// The newly connected client. public ServerConnectedEventArgs(Connection client) { Client = client; } } /// Contains event data for when a connection fails to be fully established. public class ServerConnectionFailedEventArgs : EventArgs { /// The connection that failed to be established. public readonly Connection Client; /// Initializes event data. /// The connection that failed to be established. public ServerConnectionFailedEventArgs(Connection client) { Client = client; } } /// Contains event data for when a client disconnects from the server. public class ServerDisconnectedEventArgs : EventArgs { /// The client that disconnected. public readonly Connection Client; /// The reason for the disconnection. public readonly DisconnectReason Reason; /// Initializes event data. /// The client that disconnected. /// The reason for the disconnection. public ServerDisconnectedEventArgs(Connection client, DisconnectReason reason) { Client = client; Reason = reason; } } /// Contains event data for when a message is received. public class MessageReceivedEventArgs : EventArgs { /// The connection from which the message was received. public readonly Connection FromConnection; /// The ID of the message. public readonly ushort MessageId; /// The received message. public readonly Message Message; /// Initializes event data. /// The connection from which the message was received. /// The ID of the message. /// The received message. public MessageReceivedEventArgs(Connection fromConnection, ushort messageId, Message message) { FromConnection = fromConnection; MessageId = messageId; Message = message; } } /// Contains event data for when a connection attempt to a server fails. public class ConnectionFailedEventArgs : EventArgs { /// The reason for the connection failure. public readonly RejectReason Reason; /// Additional data related to the failed connection attempt (if any). public readonly Message Message; /// Initializes event data. /// The reason for the connection failure. /// Additional data related to the failed connection attempt (if any). public ConnectionFailedEventArgs(RejectReason reason, Message message) { Reason = reason; Message = message; } } /// Contains event data for when the client disconnects from a server. public class DisconnectedEventArgs : EventArgs { /// The reason for the disconnection. public readonly DisconnectReason Reason; /// Additional data related to the disconnection (if any). public readonly Message Message; /// Initializes event data. /// The reason for the disconnection. /// Additional data related to the disconnection (if any). public DisconnectedEventArgs(DisconnectReason reason, Message message) { Reason = reason; Message = message; } } /// Contains event data for when a non-local client connects to the server. public class ClientConnectedEventArgs : EventArgs { /// The numeric ID of the client that connected. public readonly ushort Id; /// Initializes event data. /// The numeric ID of the client that connected. public ClientConnectedEventArgs(ushort id) => Id = id; } /// Contains event data for when a non-local client disconnects from the server. public class ClientDisconnectedEventArgs : EventArgs { /// The numeric ID of the client that disconnected. public readonly ushort Id; /// Initializes event data. /// The numeric ID of the client that disconnected. public ClientDisconnectedEventArgs(ushort id) => Id = id; } }