예제 #1
0
        /// <summary>
        /// Leaves the current joined session
        /// </summary>
        public void Leave()
        {
            if (session == null)
            {
                throw new InvalidOperationException("There is no session currently joined which can be left");
            }

            messageManager.Dispose();
            session.Dispose();
            session = null;
        }
예제 #2
0
        /// <summary>
        /// Joins the passed universe group
        /// </summary>
        /// <param name="universeGroup">The desired universe group to join</param>
        /// <param name="name">The nickname which will be used in the universe</param>
        /// <param name="team">Team to join in the universe</param>
        /// <returns>Returns a session of the universe</returns>
        public UniverseSession Join(UniverseGroup universeGroup, string name, Team team)
        {
            if (!connector.IsConnected)
            {
                throw new ObjectDisposedException("Connection to Flattiverse was closed");
            }

            if (universeGroup == null || string.IsNullOrWhiteSpace(name) || team == null)
            {
                throw new ArgumentNullException("Value is null");
            }

            if (session != null)
            {
                throw new InvalidOperationException("Close the current session first before joining a new one");
            }

            messageManager.UniverseGroup = universeGroup;
            session = new UniverseSession(this, universeGroup, name, team);

            return(session);
        }