Example #1
0
        protected virtual OperationResponse HandleJoinLobby(MasterClientPeer peer, JoinLobbyRequest operation, SendParameters sendParameters)
        {
            try
            {
                // special handling for game properties send by AS3/Flash (Amf3 protocol) clients
                if (peer.Protocol.ProtocolType == ProtocolType.Amf3V152 || peer.Protocol.ProtocolType == ProtocolType.Json)
                {
                    Utilities.ConvertAs3WellKnownPropertyKeys(operation.GameProperties, null);
                }

                peer.GameChannelSubscription = null;

                var subscription = this.GameList.AddSubscription(peer, operation.GameProperties, operation.GameListCount);
                peer.GameChannelSubscription = subscription;
                peer.SendOperationResponse(new OperationResponse(operation.OperationRequest.OperationCode), sendParameters);


                // publish game list to peer after the response has been sent
                var gameList = subscription.GetGameList();
                var e = new GameListEvent { Data = gameList };
                var eventData = new EventData((byte)EventCode.GameList, e);
                peer.SendEvent(eventData, new SendParameters());

                return null;
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return null;
            }
        }
Example #2
0
 private void PublishGameList(PeerBase peer)
 {
     var e = new GameListEvent { Data = this.GameList.GetAllGames(MasterServerSettings.Default.MaxGamesInLobbyList) };
     var eventData = new EventData((byte)EventCode.GameList, e);
     peer.SendEvent(eventData, new SendParameters());
 }