public LobbyManager(ClientMessaging clientMessaging, ConnectedPlayers connectedPlayers) { _clientMessaging = clientMessaging; _clientMessaging.RegisterMessaging((short)NetworkMessages.OpenScene, OpenScene); _clientMessaging.RegisterMessaging((short)NetworkMessages.StartGame, StartGameClient); SetupPlayers(connectedPlayers); }
public ClientConnectedPlayers(ClientMessaging clientMessaging, string name) : base(name) { _clientMessaging = clientMessaging; _clientMessaging.RegisterMessaging((short)NetworkMessages.GetPlayerFromClient, SendPlayerBack); _clientMessaging.RegisterMessaging((short)NetworkMessages.AddPlayerOnClient, AddPlayerClient); _clientMessaging.RegisterMessaging((short)NetworkMessages.RemovePlayerOnClient, RemovePlayerClient); _clientMessaging.RegisterMessaging((short)NetworkMessages.UpdatePlayerOnClient, UpdatePlayerClient); }
public void RegisterToMessageOnClient <T>(NetworkMessages msgCode, Action <MessageBase> callback) where T : MessageBase, new() { var code = (short)msgCode; if (_registeredCallbacks.ContainsKey(code)) { _registeredCallbacks[code].Add(callback); } else { _registeredCallbacks.Add(code, new List <Action <MessageBase> >() { callback }); } _clientMessaging.RegisterMessaging(code, CallBack <T>); }