private static void HandleReservation(IMultiplayerSessionConnectionContext sessionConnectionContext)
        {
            IMultiplayerSessionConnectionState nextState = sessionConnectionContext.Reservation.ReservationState == MultiplayerSessionReservationState.Reserved
                ? new SessionReserved()
                : new SessionReservationRejected() as IMultiplayerSessionConnectionState;

            sessionConnectionContext.UpdateConnectionState(nextState);
        }
示例#2
0
        public virtual void Disconnect(IMultiplayerSessionConnectionContext sessionConnectionContext)
        {
            sessionConnectionContext.ClearSessionState();
            sessionConnectionContext.Client.Stop();

            Disconnected newConnectionState = new Disconnected();

            sessionConnectionContext.UpdateConnectionState(newConnectionState);
        }
        private static void HandleReservation(IMultiplayerSessionConnectionContext sessionConnectionContext)
        {
            IMultiplayerSessionConnectionState nextState = sessionConnectionContext.Reservation.ReservationState switch
            {
                MultiplayerSessionReservationState.RESERVED => new SessionReserved(),
                _ => new SessionReservationRejected(),
            };

            sessionConnectionContext.UpdateConnectionState(nextState);
        }
示例#4
0
        private static void EstablishSessionPolicy(IMultiplayerSessionConnectionContext sessionConnectionContext, IClient client)
        {
            string policyRequestCorrelationId = Guid.NewGuid().ToString();

            MultiplayerSessionPolicyRequest requestPacket = new MultiplayerSessionPolicyRequest(policyRequestCorrelationId);

            client.Send(requestPacket);

            EstablishingSessionPolicy nextState = new EstablishingSessionPolicy(policyRequestCorrelationId);

            sessionConnectionContext.UpdateConnectionState(nextState);
        }
        public void UpdateStateShouldRaiseEvent()
        {
            // Arrange
            IClient             client             = Substitute.For <IClient>();
            IMultiplayerSession multiplayerSession = new MultiplayerSessionManager(client);
            IMultiplayerSessionConnectionContext connectionContext = (IMultiplayerSessionConnectionContext)multiplayerSession;
            IMonitor <IMultiplayerSession>       monitor           = multiplayerSession.Monitor();

            // Act
            connectionContext.UpdateConnectionState(TestConstants.TEST_CONNECTION_STATE);

            // Assert
            monitor.Should().Raise("ConnectionStateChanged");
        }
示例#6
0
        private void AwaitSessionReservation(IMultiplayerSessionConnectionContext sessionConnectionContext, string reservationCorrelationId)
        {
            AwaitingSessionReservation nextState = new AwaitingSessionReservation(reservationCorrelationId);

            sessionConnectionContext.UpdateConnectionState(nextState);
        }
示例#7
0
        private void ChangeState(IMultiplayerSessionConnectionContext sessionConnectionContext)
        {
            SessionJoined nextState = new SessionJoined();

            sessionConnectionContext.UpdateConnectionState(nextState);
        }
示例#8
0
        private void AwaitReservationCredentials(IMultiplayerSessionConnectionContext sessionConnectionContext)
        {
            AwaitingReservationCredentials nextState = new AwaitingReservationCredentials();

            sessionConnectionContext.UpdateConnectionState(nextState);
        }