Beispiel #1
0
        public JoinRoomModule()
        {
            this.Post("/api/24", ctx =>
            {
                var args  = Serializer.Deserialize <JoinRoomArgs>(this.Request.Body);
                var token = this.Request.Headers["playertoken"].FirstOrDefault();
                var game  = GameManager.GetGameFromToken(token);

                if (string.IsNullOrEmpty(args.RoomId))
                {
                    args.RoomId = "$service-room$";
                }

                var room = game.Rooms.FirstOrDefault(r => r.Id == args.RoomId);

                string joinKey = null;

                switch (game.GameId)
                {
                default:
                    joinKey = JoinInfo.Create(
                        encryptionKey: GameManager.EncryptionKey,
                        serverId: "serverId",
                        gameId: 128,
                        gameConnectId: game.GameId,
                        gameCodeId: "gameCodeId",
                        serverType: room.RoomType,
                        roomId: args.RoomId,
                        roomData: new byte[] { },
                        extendedRoomId: game.GameId + "/" + room.RoomType + "/" + args.RoomId,
                        connectUserId: token.Split(':')[1],
                        playerIoToken: token,
                        visible: true,
                        roomFlags: 0,
                        partnerId: "",
                        userId: 1234,
                        gameCodeVersion: 1);
                    break;
                }

                return(PlayerIO.CreateResponse(token, true, new JoinRoomOutput()
                {
                    Endpoints = new List <ServerEndpoint>()
                    {
                        GameManager.GameServerEndPoint
                    },
                    JoinKey = joinKey
                }));
            });
        }
Beispiel #2
0
        public CreateJoinRoomModule()
        {
            this.Post("/api/27", ctx =>
            {
                var args  = Serializer.Deserialize <CreateJoinRoomArgs>(this.Request.Body);
                var token = this.Request.Headers["playertoken"].FirstOrDefault();
                var game  = GameManager.GetGameFromToken(token);

                if (string.IsNullOrEmpty(args.RoomId))
                {
                    args.RoomId = "$service-room$";
                }

                args.RoomId.Replace(" ", "-");
                string joinKey = null;

                // PW01 is the override room.
                if (args.RoomId == "PW01")
                {
                    joinKey = JoinInfo.Create(
                        encryptionKey: GameManager.EncryptionKey,
                        serverId: "serverId",
                        gameId: 128,
                        gameConnectId: game.GameId,
                        gameCodeId: "gameCodeId",
                        serverType: args.RoomType,
                        roomId: GameManager.ForceWorldId ?? args.RoomId,
                        roomData: new byte[] { },
                        extendedRoomId: game.GameId + "/" + args.RoomType + "/" + GameManager.ForceWorldId ?? args.RoomId,
                        connectUserId: token.Split(':')[1],
                        playerIoToken: token,
                        visible: true,
                        roomFlags: 0,
                        partnerId: "",
                        userId: 1234,
                        gameCodeVersion: 1);

                    return(PlayerIO.CreateResponse(token, true, new CreateJoinRoomOutput()
                    {
                        RoomId = GameManager.ForceWorldId ?? args.RoomId,
                        Endpoints = new List <ServerEndpoint>()
                        {
                            GameManager.GameServerEndPoint
                        },
                        JoinKey = joinKey
                    }));
                }
                else
                {
                    joinKey = JoinInfo.Create(
                        encryptionKey: GameManager.EncryptionKey,
                        serverId: "serverId",
                        gameId: 128,
                        gameConnectId: game.GameId,
                        gameCodeId: "gameCodeId",
                        serverType: args.RoomType,
                        roomId: args.RoomId,
                        roomData: new byte[] { },
                        extendedRoomId: game.GameId + "/" + args.RoomType + "/" + args.RoomId,
                        connectUserId: token.Split(':')[1],
                        playerIoToken: token,
                        visible: true,
                        roomFlags: 0,
                        partnerId: "",
                        userId: 1234,
                        gameCodeVersion: 1);

                    return(PlayerIO.CreateResponse(token, true, new CreateJoinRoomOutput()
                    {
                        RoomId = args.RoomId,
                        Endpoints = new List <ServerEndpoint>()
                        {
                            GameManager.GameServerEndPoint
                        },
                        JoinKey = joinKey
                    }));
                }
            });
        }