public LoadingManager(ModdableChessGame game) { game.Components.GetOrRegister <LocalPlayerInformation>((int)ComponentKeys.LocalPlayerInformation, LocalPlayerInformation.Create) .Connection.EnterStateMessenger.Subscribe(new SimpleListener <int>(OnConnectionChange)); gameStateRefresher = new ReadyCheckSender(game, 5, (r) => SendGameStateRefresh(r)); gameStateRefresher.InitialWaitPeriod = gameStateRefresher.ResendPeriod; onGameStateReceived = game.Components.GetOrRegister <Message <NetworkGameState> > ((int)ComponentKeys.LoadingGameStateReceived, Message <NetworkGameState> .Create); game.Components.GetOrRegister <Command <NetworkGameState> > ((int)ComponentKeys.LoadingGameStateSend, Command <NetworkGameState> .Create).Handler = SendGameState; game.Components.GetOrRegister <Command> ((int)ComponentKeys.LoadingGameStateStopRefreshing, Command.Create).Handler = StopRefreshGameState; onErrorReceived = game.Components.GetOrRegister <Message> ((int)ComponentKeys.LoadingErrorReceived, Message.Create); game.Components.GetOrRegister <Command> ((int)ComponentKeys.LoadingErrorSend, Command.Create).Handler = SendError; onExitReceived = game.Components.GetOrRegister <Message> ((int)ComponentKeys.LoadingExitReceived, Message.Create); readySender = new ReadyCheckSender(game, 5, (r) => SendReadyState(r)); game.Components.GetOrRegister <Command <bool> > ((int)ComponentKeys.LoadingReadySend, Command <bool> .Create).Handler = ReadyStateChange; NetworkTracker.ClientMsgCallbacks.loadingGameStateReply = OnReceivedGameState; NetworkTracker.ClientMsgCallbacks.loadingErrorRelay = OnReceivedError; NetworkTracker.ClientMsgCallbacks.loadingExitReceived = OnReceivedExit; }
public ClientLobbyInit(ModdableChessGame game) { sender = new ReadyCheckSender(game, 5, (r) => SendMessage(r)); NetworkTracker.ClientMsgCallbacks.lobbyInitAllReady = OnAllReady; game.Components.GetOrRegister <LocalPlayerInformation>((int)ComponentKeys.LocalPlayerInformation, LocalPlayerInformation.Create) .Connection.EnterStateMessenger.Subscribe(new SimpleListener <int>(OnConnectionChange)); game.Components.GetOrRegister <Command <bool> >((int)ComponentKeys.LobbyInitSendReady, Command <bool> .Create).Handler = OnSendReadyCommand; allReadyMessage = game.Components.GetOrRegister <Message>((int)ComponentKeys.LobbyInitAllReadyReceived, Message.Create); }
public BoardController(Game game) { db = game.Components.Get <GameDatabase>((int)ComponentKeys.GameDatabase); opponentActionReceived = game.Components.GetOrRegister <Message <TurnAction> > ((int)ComponentKeys.OpponentTurnActionReceived, Message <TurnAction> .Create); game.Components.GetOrRegister <Command <TurnAction> > ((int)ComponentKeys.SendTurnAction, Command <TurnAction> .Create).Handler = SendTurnAction; eotReadyCheck = new ReadyCheckSender(game, 5, (r) => SendEoTReadyRefresh(r)); eotReadyCheck.InitialWaitPeriod = eotReadyCheck.ResendPeriod; eotStateReceived = game.Components.GetOrRegister <Message <ServerEndOfTurnState> > ((int)ComponentKeys.EndOfTurnStateReceived, Message <ServerEndOfTurnState> .Create); game.Components.GetOrRegister <Command <EndOfTurnState> > ((int)ComponentKeys.SendEndOfTurnState, Command <EndOfTurnState> .Create).Handler = SendEndOfTurnState; game.Components.GetOrRegister <Command> ((int)ComponentKeys.StopRefreshEndOfTurnState, Command.Create).Handler = StopSendingEoTRefresh; NetworkTracker.ClientMsgCallbacks.boardActionReceived = OnOpponentActionReceived; NetworkTracker.ClientMsgCallbacks.boardEndOfTurnReceived = OnEoTStateReceived; }
public LobbyMessages(ModdableChessGame game) { netMods = new List <NetworkModInfo>(); game.Components.GetOrRegister <LocalPlayerInformation>((int)ComponentKeys.LocalPlayerInformation, LocalPlayerInformation.Create) .Connection.EnterStateMessenger.Subscribe(new SimpleListener <int>(OnConnectionChange)); turnOrderReceived = game.Components.GetOrRegister <Message <LobbyTurnOrderChoice> > ((int)ComponentKeys.LobbyTurnOrderChoiceReceived, Message <LobbyTurnOrderChoice> .Create); game.Components.GetOrRegister <Command <LobbyTurnOrderChoice> > ((int)ComponentKeys.LobbyTurnOrderChoiceNotify, Command <LobbyTurnOrderChoice> .Create).Handler = SendPickedTurnOrder; modListReceived = game.Components.GetOrRegister <Message <List <NetworkModInfo> > > ((int)ComponentKeys.NetworkModListReceived, Message <List <NetworkModInfo> > .Create); game.Components.GetOrRegister <Command <List <LocalModInfo> > > ((int)ComponentKeys.NetworkModListSendRequest, Command <List <LocalModInfo> > .Create).Handler = SendModList; modPickReceived = game.Components.GetOrRegister <Message <bool, string> > ((int)ComponentKeys.NetworkPickedModReceived, Message <bool, string> .Create); game.Components.GetOrRegister <Command <bool, string> > ((int)ComponentKeys.NetworkPickedModSendRequest, Command <bool, string> .Create).Handler = SendPickedMod; readySender = new ReadyCheckSender(game, 5, (s) => SendReadyNotice(s)); readyRelayReceived = game.Components.GetOrRegister <Message <bool> > ((int)ComponentKeys.LobbyOtherPlayerReadyReceived, Message <bool> .Create); exitMessageReceived = game.Components.GetOrRegister <Message <LobbyExitState> > ((int)ComponentKeys.LobbyExitMessageReceived, Message <LobbyExitState> .Create); game.Components.GetOrRegister <Command <bool> > ((int)ComponentKeys.LobbyReadyNoticeSendRequest, Command <bool> .Create).Handler = ReadyStatusChange; NetworkTracker.ClientMsgCallbacks.lobbyPickedTurnOrderRelay = ReceivedPickedTurnOrder; NetworkTracker.ClientMsgCallbacks.lobbyModsListRelay = ReceiveModList; NetworkTracker.ClientMsgCallbacks.lobbyModsPickRelay = ReceiveModPick; NetworkTracker.ClientMsgCallbacks.lobbyReadyNoticeRelay = ReceiveReadyRelay; NetworkTracker.ClientMsgCallbacks.lobbyExitMessageReceived = ReceivedExitMessage; }