private void PushSharedGameState()
        {
            while (!_gameManager.SharedGameState.Board.Availability)
            {
            }
            PushSharedGameState pushInstruction = new PushSharedGameState()
            {
                SharedGameState = _gameManager.SharedGameState,
            };

            byte[] rawBytes = _protocol.ToLowerLayer(pushInstruction);
            this.Send(rawBytes);
        }
Example #2
0
        private void OtherInstruction(byte[] frame)
        {
            RemoteInstruction instruction = JsonSerializer.Deserialize <RemoteInstruction>(frame);

            switch (instruction.Type)
            {
            case RemoteInstructionType.PushSharedGameState:
                PushSharedGameState pushInstruction = Newtonsoft.Json.JsonConvert.DeserializeObject <PushSharedGameState>(Encoding.UTF8.GetString(frame));
                // Newtonsoft.Json does not deserialize properly, so to reverse the stack explicitly.
                pushInstruction.SharedGameState.BoardHistory = new Stack <string>(pushInstruction.SharedGameState.BoardHistory);
                pushInstruction.SharedGameState.BoardRedo    = new Stack <string>(pushInstruction.SharedGameState.BoardRedo);
                _gameState.OverwriteState(pushInstruction.SharedGameState);
                break;
            }
        }