Exemplo n.º 1
0
        private AbstractSessionEvent Convert(SessionEventMessage message)
        {
            AbstractSessionEvent sessionEvent = null;

            switch ((SessionEventMessage.OnlineSessionEventType)message.EventType)
            {
            case SessionEventMessage.OnlineSessionEventType.KickPlayerEvent:
                sessionEvent = JsonConvert.DeserializeObject <KickPlayerEvent>(message.JsonEvent);
                break;

            case SessionEventMessage.OnlineSessionEventType.TerminateOnlineSessionEvent:
                sessionEvent = JsonConvert.DeserializeObject <TerminateSessionEvent>(message.JsonEvent);
                break;

            case SessionEventMessage.OnlineSessionEventType.StartOnlineGameEvent:
                sessionEvent = JsonConvert.DeserializeObject <StartGameEvent>(message.JsonEvent);
                break;

            case SessionEventMessage.OnlineSessionEventType.PlayerReadyEvent:
                sessionEvent = JsonConvert.DeserializeObject <PlayerReadyEvent>(message.JsonEvent);
                break;

            case SessionEventMessage.OnlineSessionEventType.EndOnlineGameEvent:
                sessionEvent = JsonConvert.DeserializeObject <EndOnlineGameEvent>(message.JsonEvent);
                break;

            case SessionEventMessage.OnlineSessionEventType.PlayerForfeitEvent:
                sessionEvent = JsonConvert.DeserializeObject <PlayerForfeitEvent>(message.JsonEvent);
                break;

            case SessionEventMessage.OnlineSessionEventType.InvitationEvent:
                sessionEvent = JsonConvert.DeserializeObject <InvitationEvent>(message.JsonEvent);
                break;

            case SessionEventMessage.OnlineSessionEventType.MatchMakingSearchingEvent:
                sessionEvent = JsonConvert.DeserializeObject <MatchMakingSearchingEvent>(message.JsonEvent);
                break;

            case SessionEventMessage.OnlineSessionEventType.MatchMakingSyncEvent:
                sessionEvent = JsonConvert.DeserializeObject <MatchMakingSyncEvent>(message.JsonEvent);
                break;

            case SessionEventMessage.OnlineSessionEventType.MatchMakingGameInvitation:
                sessionEvent = JsonConvert.DeserializeObject <MatchMakingGameInvitation>(message.JsonEvent);
                break;
            }
            if (sessionEvent != null)
            {
                sessionEvent.SendToServer = false;
            }

            return(sessionEvent);
        }
Exemplo n.º 2
0
        private SessionEventMessage Convert(AbstractSessionEvent sessionEvent)
        {
            var message = new SessionEventMessage()
            {
                EventType       = (int)sessionEvent.Type,
                JsonEvent       = JsonConvert.SerializeObject(sessionEvent),
                OnlineSessionId = OnlineSession.Instance?.SessionId ?? "",
                UserToken       = User.Instance.UserToken,
                Broadcast       = sessionEvent.Broadcast
            };

            return(message);
        }
Exemplo n.º 3
0
 private void HandleEvent(SessionEventMessage message)
 {
     _eventReceived = true;
 }
        /// <summary>
        /// Send the data to the websocket endpoint
        /// </summary>
        /// <param name="message"></param>
        private void Send(SessionEventMessage message)
        {
            var obj = JsonConvert.SerializeObject(message);

            _ws.Send(obj);
        }