示例#1
0
        public void RoomIdTooLongTest()
        {
            Exception expectedException = null;

            try
            {
                string worldid;
                IdParser.TryParse("http://domain.com/PWthisroomnameiswaytoolongtoprocessefficientlyomgz12", out worldid);
            }
            catch (Exception ex)
            {
                expectedException = ex;
            }

            Assert.IsNull(expectedException);
        }
示例#2
0
        /// <summary>
        /// Logs in and connects to the specified room.
        /// </summary>
        /// <param name="email">The email.</param>
        /// <param name="password">The password.</param>
        /// <param name="worldId">The room id of the world to join</param>
        /// <param name="CreateRoom">if set to <c>true</c> secure API requests will be used.</param>
        /// <returns>
        /// Connection.
        /// </returns>
        public Connection LogOn(string email, string password, string inWorldId, bool createRoom = true)
        {
            var client = base.LogOn(GameId, email, password);

            string worldId;

            // Parse the world id (if it exists in another format)

            if (!IdParser.TryParse(inWorldId, out worldId))
            {
                throw new FormatException("The world id is invalid.");
            }

            if (createRoom)
            {
                string roomPrefix;

                switch (worldId.Substring(2))
                {
                case "BW":
                    roomPrefix = "Beta";
                    break;

                case "PW":
                    roomPrefix = "Everybodyedits";
                    break;

                default:
                    throw new FormatException("World ID must start with PW or BW when creating a new room.");
                }

                var serverVersion = client.BigDB.Load("config", "config")["version"];
                return(client.Multiplayer.CreateJoinRoom(
                           worldId,
                           roomPrefix + serverVersion,
                           true,
                           null,
                           null));
            }

            return(client.Multiplayer.JoinRoom(worldId, null));
        }