/// <summary> /// Handles the event of a client reconnecting. /// </summary> public void handleClientReconnected(short clientID) { connectedClients.Add(clientID); //Add client back to list of connected clients if (NetworkIdentity.isServer) { ServerBehaviour.Instance.sendMessage(MessageFactory.createClientReconnectionEventMessage(clientID), clientID, true); } OnClientReconnected.Invoke(clientID); //Notify observers }
/// <summary> /// Handles the event of a client disconnecting. /// </summary> public void handleClientDisconnected(short clientID) { if (connectedClients.Remove(clientID)) //Client was connected { if (NetworkIdentity.isServer) { ServerBehaviour.Instance.sendMessage(MessageFactory.createClientDisconnectionEventMessage(clientID), clientID, true); } OnClientDisconnected.Invoke(clientID); //Notify observers } }
/// <summary> /// Handles the event of a new client connecting. /// </summary> public void handleClientConnected(short clientID) { if (NetworkIdentity.isServer) { //Notify other clients of new client ServerBehaviour.Instance.sendMessage(MessageFactory.createClientConnectionEventMessage(clientID), clientID, true); //Notify new client of existing clients foreach (short client in connectedClients) { ServerBehaviour.Instance.sendMessage(MessageFactory.createClientConnectionEventMessage(client), true); } } connectedClients.Add(clientID); OnClientConnected.Invoke(clientID); //Notify oberservers }
public static void InvokeClientConnectionEvent(ClientConnectionEventArgs args) { ClientConnectionEvent?.Invoke(args); }