Beispiel #1
0
        public bool CreateRoom(string room_name)
        {
            string groupName;
            int    newport;

            if (RoomSet.Contains(room_name))
            {
                return(false);
            }
            RoomSet.Add(room_name);
            while (true)
            {
                groupName = RandomString(12);
                if (!GroupSet.Contains(groupName))
                {
                    break;
                }
            }
            sessions[room_name] = groupName;
            Console.WriteLine(groupName);
            GroupSet.Add(groupName);
            while (true)
            {
                newport = random.Next(1000, 65000);
                if (!PortSet.Contains(newport) && !PortInUse(newport))
                {
                    break;
                }
            }
            PortSet.Add(newport);
            ports.Add(groupName, newport);
            try
            {
                LastScreen.Add(groupName, new Part[10, 10]);
                messages.Add(groupName, new List <Message>());
            }
            catch { }
            StreamServer streamServer = new StreamServer(newport);

            servers.Add(groupName, streamServer);
            streamServer.Init();
            streamServer.ConnectToServer();
            return(true);
        }