protected Message ProcessIncomingEnvelope(Envelope env)
        {
            this.IncomingEnvelopes.Enqueue(env);
            Identifier messageNumber = new Identifier(SubSystem.ProcessID, SubSystem.GetNextSeqNumber());

            if (env.Message.GetType() == typeof(ResultMessage))
            {
                Logger.Info("Received a result message in RespondTurns convo");
                playerAppState = SubSystem.appState as PlayerAppState;

                ResultMessage message = env.Message as ResultMessage;
                playerAppState.lastShotHit = message.getHit();
                playerAppState.turn        = message.getMyTurn();
                playerAppState.end         = message.getEnd();
                playerAppState.won         = message.getWin();
                playerAppState.gameId      = message.getGameId();
                playerAppState.lastX       = message.getXcord();
                playerAppState.lastY       = message.getYcord();
                playerAppState.SetTurn();
                playerAppState.ColorButtonResult(playerAppState.turn, playerAppState.lastX, playerAppState.lastY, playerAppState.lastShotHit); //Setting gameScreen according to shot.

                return(new AckMessage(playerAppState.gameId, 1, messageNumber, this.ConversationId));
            }
            else
            {
                Logger.Error("Received an error message in RespondTurns convo");
                return(new ErrorMessage());
            }
        }
Example #2
0
 protected override void ProcessValidResponse(Envelope env)
 {
     if (env.Message.GetType() == typeof(ResultMessage))
     {
         Logger.Info("Received a result message in Shot convo");
         var message = env.Message as ResultMessage;
         appState.turn        = message.getMyTurn();
         appState.end         = message.getEnd();
         appState.won         = message.getWin();
         appState.lastShotHit = message.getHit();
         appState.lastX       = message.getXcord();
         appState.lastY       = message.getYcord();
         appState.SetTurn();
         appState.ColorButtonResult(appState.turn, appState.lastX, appState.lastY, appState.lastShotHit); //Setting gameScreen according to shot.
     }
     if (env.Message.GetType() == typeof(ErrorMessage))
     {
         Logger.Error("Received an error message in Shot convo");
         var message = env.Message as ErrorMessage;
     }
 }