Exemplo n.º 1
0
        public void StartServerChatroom(string topic)
        {
            Chatroom chatroom = base.JoinTopic(topic);

            chatroom.Topic = topic;

            ServerChatRoom serverChatRoom = new ServerChatRoom(chatroom);

            tcpChatrooms.Add(topic, serverChatRoom);

            bool started = true;

            do
            {
                try
                {
                    serverChatRoom.StartServer(nextPort);
                    started = true;
                }
                catch (IOException e)
                {
                    started = false;
                    Console.WriteLine(e.ToString());
                }
                nextPort++;
            } while (!started);
        }
Exemplo n.º 2
0
 public override object Clone()
 {
     ServerChatRoom clone = new ServerChatRoom(ip,concretCR.topic);
     clone.concretCR = concretCR;
     clone.commSock = commSock;
     return clone;
 }
Exemplo n.º 3
0
        public override object Clone()
        {
            ServerChatRoom clone = new ServerChatRoom(ip, concretCR.topic);

            clone.concretCR = concretCR;
            clone.commSock  = commSock;
            return(clone);
        }
Exemplo n.º 4
0
        public override object Clone()
        {
            ServerChatRoom clone = new ServerChatRoom(ip, concretCR.getTopic());

            clone.concretCR  = concretCR;
            clone.commSocket = commSocket;
            return(clone);
        }
Exemplo n.º 5
0
 public void createTopic(string name)
 {
     lock(topicsChatRoom)
     {
         if (topicsChatRoom.Contains(name))
         {
             throw new TopicExistsException("The topic exists already");
         }
         else
         {
             Console.WriteLine(nextPort);
             ServerChatRoom scr = new ServerChatRoom(ip, name);
             topicsChatRoom.Add(name, scr);
             ParameterizedThreadStart ts = new ParameterizedThreadStart(scr.startServer);
             Thread t = new Thread(ts);
             t.Start(nextPort++);
         }
     }
 }
Exemplo n.º 6
0
 public void createTopic(string name)
 {
     lock (topicsChatRoom)
     {
         if (topicsChatRoom.Contains(name))
         {
             throw new TopicExistsException("The topic exists already");
         }
         else
         {
             Console.WriteLine(nextPort);
             ServerChatRoom scr = new ServerChatRoom(ip, name);
             topicsChatRoom.Add(name, scr);
             ParameterizedThreadStart ts = new ParameterizedThreadStart(scr.startServer);
             Thread t = new Thread(ts);
             t.Start(nextPort++);
         }
     }
 }
Exemplo n.º 7
0
 public void createTopic(string topic)
 {
     lock (topicTable)
     {
         //Check if the topic exists
         if (topicTable.Contains(topic))
         {
             Console.WriteLine("Topic '" + topic + "'already exists");
         }
         else
         {
             //If the topic doesn't exist the ServerChatRoom is launched
             ServerChatRoom chatRoom = new ServerChatRoom(ip, topic);
             topicTable.Add(topic, chatRoom);
             ParameterizedThreadStart ts = new ParameterizedThreadStart(chatRoom.startServer);
             Thread t = new Thread(ts);
             t.Start(nextPort++);
             //The port has been changed for new connection
         }
     }
 }