コード例 #1
0
ファイル: GameCore.cs プロジェクト: rkdrnf/photonserver
        public async Task HandleConfirmJoinOperation(GamePeer peer, OperationRequest operationRequest, SendParameters sendParameters)
        {
            var joinRequest = new ConfirmJoinRequest(peer.Protocol, operationRequest);
            if (!peer.ValidateOperation(joinRequest, sendParameters))
            {
                return;
            }

            //string playerInfoStr = await WebHelper.RequestPlayerInfo(joinRequest.UserKey);
            string playerInfoStr = "{ \"username\": \"test\", \"game_money\": 2000 }";

            PlayerInfo info = JsonConvert.DeserializeObject<PlayerInfo>(playerInfoStr);

            PeerManager.Instance.OnPeerJoin(peer, new PeerInfo(peer, joinRequest.RoomID, joinRequest.UserKey));

            var room = FindRoom(joinRequest.RoomID);

            if (room != null)
            {
                room.ExecutionFiber.Enqueue(() => room.Join(peer, joinRequest, sendParameters, info));
            }
            else
            {
                var response = new OperationResponse(CommonOperationCode.ConfirmJoin,
                new Dictionary<byte, object> { { (byte)CommonParameterKey.Success, false } });
                peer.SendOperationResponse(response, sendParameters);
            }
        }
コード例 #2
0
ファイル: GameCore.cs プロジェクト: rkdrnf/photonserver
        public async Task HandleConfirmJoinOperation(GamePeer peer, OperationRequest operationRequest, SendParameters sendParameters)
        {
            var joinRequest = new ConfirmJoinRequest(peer.Protocol, operationRequest);

            if (!peer.ValidateOperation(joinRequest, sendParameters))
            {
                return;
            }

            //string playerInfoStr = await WebHelper.RequestPlayerInfo(joinRequest.UserKey);
            string playerInfoStr = "{ \"username\": \"test\", \"game_money\": 2000 }";

            PlayerInfo info = JsonConvert.DeserializeObject <PlayerInfo>(playerInfoStr);

            PeerManager.Instance.OnPeerJoin(peer, new PeerInfo(peer, joinRequest.RoomID, joinRequest.UserKey));

            var room = FindRoom(joinRequest.RoomID);

            if (room != null)
            {
                room.ExecutionFiber.Enqueue(() => room.Join(peer, joinRequest, sendParameters, info));
            }
            else
            {
                var response = new OperationResponse(CommonOperationCode.ConfirmJoin,
                                                     new Dictionary <byte, object> {
                    { (byte)CommonParameterKey.Success, false }
                });
                peer.SendOperationResponse(response, sendParameters);
            }
        }
コード例 #3
0
ファイル: GameRoom.cs プロジェクト: rkdrnf/photonserver
        public void Join(GamePeer peer, ConfirmJoinRequest joinReq, SendParameters sendParameters, PlayerInfo info)
        {
            if (CanJoin(peer))
            {
                Player newPlayer = playerManager.AddPlayer(peer, info);

                BroadcastMessageHandler += peer.OnBroadcastMessage;
                peer.OnLeaveHandler     += OnPeerLeave;

                OnJoin(peer);
            }
            else
            {
                var response = new OperationResponse(CommonOperationCode.ConfirmJoin,
                                                     new Dictionary <byte, object> {
                    { (byte)CommonParameterKey.Success, false }
                });

                peer.SendOperationResponse(response, sendParameters);
            }
        }
コード例 #4
0
ファイル: GameRoom.cs プロジェクト: rkdrnf/photonserver
        public void Join(GamePeer peer, ConfirmJoinRequest joinReq, SendParameters sendParameters, PlayerInfo info)
        {
            if (CanJoin(peer))
            {
                Player newPlayer = playerManager.AddPlayer(peer, info);

                BroadcastMessageHandler += peer.OnBroadcastMessage;
                peer.OnLeaveHandler += OnPeerLeave;

                OnJoin(peer);
            }
            else
            {
                var response = new OperationResponse(CommonOperationCode.ConfirmJoin,
                new Dictionary<byte, object> { { (byte)CommonParameterKey.Success, false } });

                peer.SendOperationResponse(response, sendParameters);
            }
        }