private void HandleAction(SocketMessage sm, SocketContainer argContainer) { //Before we connect we request an id to the master server... if (sm.msg is SocketCommand) { SocketCommand cmd = sm.msg.CastType <SocketCommand>(); if (cmd != null) { switch (cmd.Command) { /*case SocketCommands.CreateConnId: * myLogger.Log("Starting new CLIENT connection with ID: {0}", sm.id); * Id = sm.id; * * Send(SocketManager.ConfirmConnId(Id), argContainer); //??? * OnConnectedCallback?.Invoke(); * break;*/ case SocketCommands.ReturnClientIDAfterAccept: myLogger.Log("Starting new CLIENT connection with ID: {0}", sm.id); Id = sm.id; break; case SocketCommands.CloseInstance: myLogger.Log("Client is closing connection..."); Stop(false); break; default: myLogger.Log("Unknown ClientCallbackion to take! Case: {0}", cmd.Command); break; } } else { myLogger.Log("Empty string received by client!"); } } else { ReceivedServerMessageCallback?.Invoke(sm.msg, argContainer); } }
private void HandleAction(SocketMessage sm, SocketContainer argContainer) { //string val = sm.StringValue; if (sm.msg is SocketCommand) { SocketCommand cmd = sm.msg.CastType <SocketCommand>(); if (cmd != null) { switch (cmd.Command) { case SocketCommands.CloseClients: CloseAllClients(sm.id); break; case SocketCommands.ClosedClient: //closedClients.Add(sm.id); SocketManager.PoliteClose(sm.id); //Tell to the client that it has been disconnected from it routingTable.Remove(sm.id); CloseServerAfterClientsClose(dispose); break; case SocketCommands.Stop: CloseAllClients(sm.id); break; case SocketCommands.UnpoliteStop: object d = cmd.Metadata["Dispose"]; Stop(d != null && ((bool)d)); break; default: DoServerError(string.Format("Cannot de-encrypt the message! Unrecognized 'enum' case: {0}", cmd.Command), sm.id); break; } } } else { //If not is a command, then send the object to other clients... SendToClient(sm, sm.DestsId); } }