示例#1
0
        protected void ListenForMessage()
        {
            byte[] message = new byte[4096];
            int    bytesRead;

            while (stream.CanRead)
            {
                bytesRead = 0;
                try
                {
                    bytesRead = stream.Read(message, 0, 4096);
                }
                catch
                {
                    break;
                }

                if (bytesRead == 0)
                {
                    break;
                }

                string signal = encoder.GetString(message, 0, bytesRead);
                Console.WriteLine(message);

                MessageArgs myArgs = new MessageArgs(signal);
                OnNewMessageRecived(this, myArgs);
            }
            if (client != null)
            {
                try
                {
                    var args = new MessageArgs("Disconnected from cloud");
                    OnNewSignalization(this, args);
                    client.GetStream().Close();
                    client.Close();
                    client = null;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                    Console.WriteLine("Exception in disconnecting from cloud");
                }
            }
        }
示例#2
0
        protected void ListenForMessage(object client)
        {
            TcpClient     clientSocket = (TcpClient)client;
            NetworkStream stream       = clientSocket.GetStream();

            byte[] message = new byte[4096];
            int    bytesRead;

            while (stream.CanRead)
            {
                bytesRead = 0;
                try
                {
                    bytesRead = stream.Read(message, 0, 4096);
                }
                catch
                {
                    break;
                }

                if (bytesRead == 0)
                {
                    break;
                }

                string signal = encoder.GetString(message, 0, bytesRead);

                MessageArgs myArgs = new MessageArgs(signal);
                myArgs.ID = clientSocket;
                OnNewMessageRecived(this, myArgs);
            }
            if (serverSocket != null)
            {
                try
                {
                    clientSocket.GetStream().Close();
                    clientSocket.Close();
                }
                catch
                {
                }
            }
        }
示例#3
0
文件: Node.cs 项目: sopel30/tsst
        private void newMessageRecived(object myObject, MessageArgs myArgs)
        {
            addLog(logs, Constants.NEW_MSG_RECIVED + " " + myArgs.Message, Constants.LOG_INFO);
<<<<<<< HEAD

            string[] fromWho = myArgs.Message.Split('%');
            if (fromWho[0].Contains("C"))
            {
                string forwarded = switchTable.forwardMessage(myArgs.Message);

                try
                {
                    string port = forwarded.Split('^')[0];
                    string slot = forwarded.Split('^')[1].Split('&')[0];
                    STM.ElementAt(portsOutTemp.IndexOf(port)).reserveSlot(Convert.ToInt32(slot), forwarded.Split('^')[1].Split('&')[1]);
                    addLog(logs, "slot reserved ", Constants.LOG_INFO);
                    addLog(logs, Constants.FORWARD_MESSAGE + " " + forwarded, Constants.LOG_INFO);
                }
                catch(Exception e)
                {
                    //addLog(logs, "slot reserved before/not empty", Constants.LOG_ERROR);
                    addLog(logs, Constants.INVALID_PORT, Constants.LOG_ERROR);
                }
            }

            else if (fromWho[1].Split('/').Length>1)
            {
                string[] slots = SynchronousTransportModule.getSlots(fromWho[1].Split(':')[1]);
                try
                {
                    int i = 0;
                    foreach (string s in slots)
                    {
                        if (s.Length != 0)
                        {
                            string forwarded = switchTable.forwardMessage(fromWho[0]+"%"+fromWho[1].Split('&')[0]+"."+i+"&"+s);
                            addLog(logs, forwarded, Constants.LOG_INFO);
                            string port = forwarded.Split('^')[0];
                            string slot = forwarded.Split('^')[1].Split('&')[0];
                            if (!port.Contains("C"))
                            {
                                STM.ElementAt(portsOutTemp.IndexOf(port)).reserveSlot(Convert.ToInt32(slot), forwarded.Split('^')[1].Split('&')[1]);
                                addLog(logs, "slot reserved ", Constants.LOG_INFO);
                                addLog(logs, Constants.FORWARD_MESSAGE + " " + forwarded, Constants.LOG_INFO);
                            }
                            else
                            {
                                cloud.sendMessage(forwarded);
                            }
                        }
                        i++;
                    }

                }
                catch
                {
                    addLog(logs, Constants.INVALID_PORT, Constants.LOG_ERROR);
                }
            }

            /*
            string[] forwarded = switchTable.forwardMessage(myArgs.Message);
            if (forwarded != null) //czyli nie przyszla pusta stmka
            { 
=======
            string[] forwarded = switchTable.forwardMessage(myArgs.Message);
            if (forwarded != null) //czyli nie przyszla pusta stmka
            { 
                //cloud.sendMessage(forwarded);

>>>>>>> 10ae7036948c3f9ffb9df1f3a03fce21780a3fac
                foreach (string s in forwarded)
                {
                    if (s != null)
                    {
                        string[] msg = s.Split('&');
                        string[] msg1 = msg[1].Split('^');

                        if (s.Contains("CO"))
                        {
                            cloud.sendMessage(s);
                            addLog(logs, Constants.FORWARD_MESSAGE + " " + s, Constants.LOG_INFO);
                        }
                        else
                        {
                            try
                            {
                                STM.ElementAt(portsOutTemp.IndexOf(msg[0])).reserveSlot(Convert.ToInt32(msg1[0]), msg1[1]);
                                addLog(logs, "slot reserved ", Constants.LOG_INFO);
                                addLog(logs, Constants.FORWARD_MESSAGE + " " + s, Constants.LOG_INFO);
                            }
                            catch
                            {
                                //addLog(logs, "slot reserved before/not empty", Constants.LOG_ERROR);
                            }
                        }
                        
                    }
                }
<<<<<<< HEAD
=======

                //string[] ports = forwarded.Split('&')[0].Split('%');

                
>>>>>>> 10ae7036948c3f9ffb9df1f3a03fce21780a3fac
            }
            else
            {
                addLog(logs, Constants.INVALID_PORT, Constants.LOG_ERROR);
            }*/
            
        }
示例#4
0
文件: Client.cs 项目: sopel30/tsst2
 private void newSignalization(object a, MessageArgs e)
 {
     displayStatusMessage(e.message, Constants.LOG_ERROR);
     this.mainWindow.Dispatcher.Invoke(
         System.Windows.Threading.DispatcherPriority.Normal,
         new Action(() =>
         {
             this.mainWindow.ConnectButton.IsEnabled = true;
             this.mainWindow.statusBar.Text = "Disonnected";
             this.mainWindow.Button_1.IsEnabled = false;
             this.mainWindow.statusBar.Foreground = Brushes.Red;
         })
     );
 }
示例#5
0
文件: Client.cs 项目: sopel30/tsst2
 private void newMessageRecived(object a, MessageArgs e)
 {
     string message;
     try
     {
         //displayStatusMessage(e.message, Constants.LOG_ERROR);
         message = e.message.Split('&')[1];
         string dispMessage = message.Split('^')[1];
         addChatMessage(dispMessage, Constants.RIGHT);
     }
     catch
     {
         addChatMessage(e.message, Constants.RIGHT);
     }
 }
示例#6
0
        protected void ListenForMessage()
        {
            byte[] message = new byte[4096];
            int bytesRead;

            while (stream.CanRead)
            {
                bytesRead = 0;
                try
                {
                    bytesRead = stream.Read(message, 0, 4096);
                }
                catch
                {
                    break;
                }

                if (bytesRead == 0)
                {
                    break;
                }
                string signal = encoder.GetString(message, 0, bytesRead);
                Console.WriteLine(message);
                MessageArgs myArgs = new MessageArgs(signal);
                OnNewMessageRecived(this, myArgs);
            }
            if (client != null)
            {
                try
                {
                    var args = new MessageArgs("Disconnected from cloud");
                    OnNewSignalization(this, args);

                    client.GetStream().Close();
                    client.Close();
                    client = null;

                }
                catch (Exception e )
                {
                    Console.WriteLine(e.StackTrace);
                    Console.WriteLine("Exception in disconnecting from cloud");
                }
            }
        }
示例#7
0
文件: Node.cs 项目: sopel30/tsst2
        private void newControlOrder(object a, MessageArgs myArgs)
        {
            //addLog(logs, Constants.NEW_MSG_RECEIVED + " " + e.message, Constants.LOG_INFO);
            string[] check = myArgs.message.Split('%');
            string command = check[1].Split('#')[1];

                addLog(logs, Constants.RECEIVED_FROM_MANAGER + " " + myArgs.message, Constants.LOG_INFO);
                if (command == Constants.SET_LINK)
                    parseOrder(command + "%" + check[2] + "%" + check[3]);
                else if (command ==  Constants.DELETE_LINK)
                    parseOrder(command + "%" + check[2]);
                else if (command == Constants.SHOW_LINK)
                    parseOrder(command + "%" + check[2]);
        }
示例#8
0
        //mozna to przerobic na jakies bardziej obiektowe
        private void newMessageRecived(object a, MessageArgs e)
        {
            string getSenderId = null ;
            try
            {
                getSenderId = clientSockets.FirstOrDefault(x => x.Value == e.ID).Key;
            }
            catch { }
            if (e.message.Contains("CP") && !getSenderId.Contains("CallControl"))
            {
                addLog(this.logs, Constants.NEW_MSG_RECEIVED + " from " + getSenderId + " " + e.message, Constants.LOG_INFO);
                    try
                    {
                        string[] msg = e.message.Split('^');
                        string forwarded = switchBox.forwardMessage(getSenderId +"%"+msg[0]+ "&" + e.message);
                        string[] getNextNode = forwarded.Split('%');
                        server.sendMessage(clientSockets[getNextNode[0]], getSenderId + "%" + getNextNode[1] + msg[1].Split('&')[1]);
                        addLog(this.logs, Constants.FORWARD_MESSAGE + " " + forwarded, Constants.LOG_INFO);
                    }
                    catch
                    {
                        addLog(this.logs, Constants.UNREACHABLE_DST + " " + switchBox.forwardMessage(getSenderId + "%" + e.message), Constants.LOG_ERROR);
                    }
            }

            else if (e.message.Split('#').Length == 1 && e.message.Split('/').Length != 2 && e.message.Split(':').Length > 1 && !getSenderId.Contains("CallControl"))
            {
                addLog(this.logs, Constants.NEW_MSG_RECEIVED + " from " + getSenderId + " " + e.message, Constants.LOG_INFO);
                try
                {
                    string forwarded = switchBox.forwardMessage(getSenderId + "%" + e.message);
                    string[] getNextNode = forwarded.Split('%');
                    server.sendMessage(clientSockets[getNextNode[0]], getSenderId + "%" + getNextNode[1]);
                    addLog(this.logs, Constants.FORWARD_MESSAGE + " " + forwarded, Constants.LOG_INFO);
                }
                catch
                {
                    addLog(this.logs, Constants.UNREACHABLE_DST + " " + switchBox.forwardMessage(getSenderId + "%" + e.message), Constants.LOG_ERROR);
                }
            }

            else if (e.message.Split('#').Length == 1 && e.message.Split('/').Length == 2 && !getSenderId.Contains("CallControl"))
            {
                string[] receivedSlots = SynchronousTransportModule.getSlots(e.message.Split('/')[0]);
                if (receivedSlots != null)
                {
                    addLog(this.logs, Constants.NEW_MSG_RECEIVED + " from " + getSenderId + " " + e.message, Constants.LOG_INFO);
                    try
                    {
                        string forwarded = switchBox.forwardMessage(getSenderId + "%" + e.message);
                        addLog(this.logs, Constants.FORWARD_MESSAGE + " " + forwarded, Constants.LOG_INFO);
                        string[] getNextNode = forwarded.Split('%');
                        server.sendMessage(clientSockets[getNextNode[0]], getSenderId + "%" + getNextNode[1]);
                        addLog(this.logs, Constants.FORWARD_MESSAGE + " " + forwarded, Constants.LOG_INFO);
                    }
                    catch
                    {
                        addLog(this.logs, Constants.UNREACHABLE_DST + " " + switchBox.forwardMessage(getSenderId + "%" + e.message), Constants.LOG_ERROR);
                    }
                }
            }

            else if(getSenderId!=null)
            {
                if (getSenderId.Contains("CallControl"))
                {
                    addLog(this.logs, Constants.NEW_MSG_RECEIVED + " from " + getSenderId + " " + e.message, Constants.LOG_INFO);
                    if (getSenderId.Contains("NetworkNode") && getSenderId.Contains("rtadd"))
                    {
                        try
                        {
                            string[] getNextNode = e.message.Split('#');
                            string pdu = "";
                            for (int i = 1; i < getNextNode.Length; i++)
                                pdu += "#" + getNextNode[i];
                            server.sendMessage(clientSockets[getNextNode[0]], getSenderId + "%" + pdu);
                            addLog(this.logs, Constants.FORWARD_MESSAGE + " " + getSenderId + "%" + pdu, Constants.LOG_INFO);
                        }
                        catch
                        {
                            addLog(this.logs, Constants.UNREACHABLE_DST + " " , Constants.LOG_ERROR);
                        }
                    }
                    else
                    {
                        try
                        {
                            string[] getNextNode = e.message.Split('#');
                            string pdu = "";
                            for (int i = 1; i < getNextNode.Length; i++)
                                pdu += "#" + getNextNode[i];
                            server.sendMessage(clientSockets[getNextNode[0]], getSenderId + "%" + pdu);
                            addLog(this.logs, Constants.FORWARD_MESSAGE + " " + getSenderId + "%" + pdu, Constants.LOG_INFO);
                        }
                        catch
                        {
                            addLog(this.logs, Constants.UNREACHABLE_DST + " ", Constants.LOG_ERROR);
                        }
                    }
                }
            }
            else
            {
                addNewClient(e.message, e);
            }
        }
示例#9
0
文件: CPCC.cs 项目: sopel30/tsst2
        private void onNewMessage(object a, MessageArgs e)
        {
            logs.addLog(e.message, true, Constants.LOG_INFO, true);
            if (e.message.Contains("CallRequest") && !e.message.Contains("ok"))
            {
                string[] parts = e.message.Split('#');
                string response = parseMsgFromNCC(e.message);
                signalizationNetwork.sendMessage(nc.Split('%')[0] + "@CallControll#CallRequest#" + parts[2] + "#" + this.myId + "#" + response);
            }

            else if (e.message.Contains("CallCoordination") && e.message.Contains("ok"))
            {
                MessageArgs arg = new MessageArgs(e.message);
                OnNewConnectionEstablished(this, arg);
            }
        }
示例#10
0
文件: CPCC.cs 项目: sopel30/tsst2
        public string parseMsgFromNCC(string query)
        {
            string[] parts = query.Split('#');
            DialogResult dialogResult = MessageBox.Show(parts[2] + " is calling\nAccept?", myName + " CPCC", MessageBoxButtons.YesNo);
            if (dialogResult == DialogResult.Yes)
            {

                logs.addLog("Caller connected " + query, true, Constants.LOG_INFO, true);
                MessageArgs arg = new MessageArgs(query);
                OnNewConnectionEstablished(this, arg);
                return "ok";
                //do something
            }
            else if (dialogResult == DialogResult.No)
            {
                return "fail";
                //do something else
            }
            else
            {
                return "fail";
            }
        }
示例#11
0
文件: Client.cs 项目: sopel30/tsst
 private void newSignalization(object a, MessageArgs e)
 {
     displayStatusMessage(e.Message, Constants.LOG_ERROR);
 }
示例#12
0
 private void newMessageReceived(object a, MessageArgs e)
 {
     string[] temp = e.message.Split('#');
     //addLog(window.logList, e.message, Constants.LOG_INFO);
     if (temp[0].Contains("NetworkNode"))
         nodeParser(e.message);
     else if (temp[0].Contains("Client"))
         clientParser(e.message);
     else if (temp[0].Contains("NCC"))
         nccParser(e.message);
 }
示例#13
0
        private void newConnection(object a, MessageArgs e)
        {
            int i=0;
            do
            {
                ++i;
            }
            while (connections[i] != 0);
            connections[i] = 1;

            switch (i)
            {
                case 1:
                    clients[0] = e.message.Split('#')[2];
                    this.call1.Dispatcher.Invoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        new Action(() =>
                        {
                            this.call1.IsEnabled = true;
                            this.call1.Header = e.message.Split('#')[2];
                            this.Button_1.IsEnabled = true;
                        })
                    );
                    break;

            }
        }
示例#14
0
文件: Node.cs 项目: sopel30/tsst
 private void newOrderRecived(object myObject, MessageArgs myArgs)
 {
     string[] check = myArgs.Message.Split('%');
     if (check[0] == NodeId)
     {
         addLog(logs, Constants.RECIVED_FROM_MANAGER + " " + myArgs.Message, Constants.LOG_INFO);
         if (check[1] == Constants.SET_LINK)
             parseOrder(check[1] + "%" + check[2] + "%" + check[3]);
         else if (check[1] == Constants.DELETE_LINK)
             parseOrder(check[1] + "%" + check[2]);
         else if(check[1]==Constants.SHOW_LINK)
             parseOrder(check[1] + "%" + check[2]);   
     }            
 }
示例#15
0
文件: Node.cs 项目: sopel30/tsst2
        private void newMessageRecived(object myObject, MessageArgs myArgs)
        {
            addLog(logs, Constants.NEW_MSG_RECEIVED + " " + myArgs.message, Constants.LOG_INFO);

            string[] fromWho = myArgs.message.Split('%');
            if (fromWho[0].Contains("C"))
            {
                string forwarded = switchTable.forwardMessage(myArgs.message);

                try
                {
                    string port = forwarded.Split('^')[0];
                    string slot = forwarded.Split('^')[1].Split('&')[0];
                    STM.ElementAt(portsOutTemp.IndexOf(port)).reserveSlot(Convert.ToInt32(slot), forwarded.Split('^')[1].Split('&')[1]);
                    addLog(logs, "slot reserved ", Constants.LOG_INFO);
                    addLog(logs, Constants.FORWARD_MESSAGE + " " + forwarded, Constants.LOG_INFO);
                }
                catch(Exception e)
                {
                    //addLog(logs, "slot reserved before/not empty", Constants.LOG_ERROR);
                    addLog(logs, Constants.INVALID_PORT, Constants.LOG_ERROR);
                }
            }

            else if (fromWho[1].Split('/').Length>1)
            {
                string[] slots = SynchronousTransportModule.getSlots(fromWho[1].Split(':')[1]);
                try
                {
                    int i = 0;
                    foreach (string s in slots)
                    {
                        if (s.Length != 0)
                        {
                            string forwarded = switchTable.forwardMessage(fromWho[0]+"%"+fromWho[1].Split('&')[0]+"."+i+"&"+s);
                            addLog(logs, forwarded, Constants.LOG_INFO);
                            string port = forwarded.Split('^')[0];
                            string slot = forwarded.Split('^')[1].Split('&')[0];
                            if (!port.Contains("C"))
                            {
                                STM.ElementAt(portsOutTemp.IndexOf(port)).reserveSlot(Convert.ToInt32(slot), forwarded.Split('^')[1].Split('&')[1]);
                                addLog(logs, "slot reserved ", Constants.LOG_INFO);
                                addLog(logs, Constants.FORWARD_MESSAGE + " " + forwarded, Constants.LOG_INFO);
                            }
                            else
                            {
                                cloud.sendMessage(forwarded);
                            }
                        }
                        i++;
                    }

                }
                catch
                {
                    addLog(logs, Constants.INVALID_PORT, Constants.LOG_ERROR);
                }
            }
        }
示例#16
0
 private void addNewClient(string m, MessageArgs e)
 {
     try
     {
         if (clientSockets.Keys.Contains(m.Split('#')[0]))
         {
             bool isConnected = clientSockets[(m.Split('#')[0])].Connected;
             if (!isConnected)
             {
                 clientSockets.Remove(m.Split('#')[0]);
                 clientSockets.Add(m.Split('#')[0], e.ID);
                 addLog(this.logs, Constants.NEW_CLIENT_LOG + " " + m.Split('#')[0], Constants.LOG_INFO);
             }
         }
         else
         {
             clientSockets.Add(m.Split('#')[0], e.ID);
             addLog(this.logs, Constants.NEW_CLIENT_LOG + " " + m.Split('#')[0], Constants.LOG_INFO);
         }
     }
     catch
     {
         addLog(this.logs, Constants.ALREADY_CONNECTED + " " + e.message.Split('#')[0], Constants.LOG_ERROR);
     }
 }
示例#17
0
文件: Node.cs 项目: sopel30/tsst2
 private void newSignalization(object a, MessageArgs e)
 {
     addLog(logs, e.message, Constants.LOG_ERROR);
     this.mainWindow.Dispatcher.Invoke(
         System.Windows.Threading.DispatcherPriority.Normal,
         new Action(() =>
         {
             this.mainWindow.startButton.IsEnabled = true;
         })
     );
     cloud.OnNewMessageRecived -= newMessageHandler;
     cloud.OnNewSignalization -= signHandler;
     newMessageHandler = null;
     signHandler = null;
     cloud.stopService();
     cloud = null;
 }
示例#18
0
        protected void ListenForMessage(object client)
        {
            TcpClient clientSocket = (TcpClient)client;
            NetworkStream stream = clientSocket.GetStream();

            byte[] message = new byte[4096];
            int bytesRead;

            while (stream.CanRead)
            {
                bytesRead = 0;
                try
                {
                    bytesRead = stream.Read(message, 0, 4096);

                }
                catch
                {
                    break;
                }

                if (bytesRead == 0)
                {
                    break;
                }

                string signal = encoder.GetString(message, 0, bytesRead);
                MessageArgs myArgs = new MessageArgs(signal);
                myArgs.ID = clientSocket;
                OnNewMessageRecived(this, myArgs);

            }
            if (serverSocket != null)
            {
                try
                {
                    clientSocket.GetStream().Close();
                    clientSocket.Close();
                }
                catch
                {
                }
            }
        }
示例#19
0
        private void newMessageRecived(object a, MessageArgs e)
        {
            if(e.Message.Contains("CO"))
            {
                string getSenderId = clientSockets.FirstOrDefault(x => x.Value == e.ID).Key;
                addLog(this.logs, Constants.NEW_MSG_RECIVED + " from " + getSenderId + " " + e.Message, Constants.LOG_INFO);
                    try
                    {
                        string forwarded = switchBox.forwardMessage(getSenderId + "%" + e.Message);
                        string[] getNextNode = forwarded.Split('%');
                        server.sendMessage(clientSockets[getNextNode[0]], getSenderId + "%" + getNextNode[1]);
                        addLog(this.logs, Constants.FORWARD_MESSAGE + " " + forwarded, Constants.LOG_INFO);
                    }
                    catch
                    {
                        addLog(this.logs, Constants.UNREACHABLE_DST + " " + switchBox.forwardMessage(getSenderId + "%" + e.Message), Constants.LOG_ERROR);
                    }
            }

            <<<<<<< HEAD
            if(e.Message.Contains("COP"))
            {
                string getSenderId = clientSockets.FirstOrDefault(x => x.Value == e.ID).Key;
                addLog(this.logs, Constants.NEW_MSG_RECIVED + " from " + getSenderId + " " + e.Message, Constants.LOG_INFO);
                    try
                    {
                        string[] msg = e.Message.Split('^');
                        string forwarded = switchBox.forwardMessage(getSenderId +"%"+msg[0]+ "&" + e.Message);
                        string[] getNextNode = forwarded.Split('%');
                        server.sendMessage(clientSockets[getNextNode[0]], getSenderId + "%" + getNextNode[1] + msg[1].Split('&')[1]);
                        addLog(this.logs, Constants.FORWARD_MESSAGE + " " + forwarded, Constants.LOG_INFO);
                    }
                    catch
                    {
                        addLog(this.logs, Constants.UNREACHABLE_DST + " " + switchBox.forwardMessage(getSenderId + "%" + e.Message), Constants.LOG_ERROR);
                    }
            }

            =======
            >>>>>>> 10ae7036948c3f9ffb9df1f3a03fce21780a3fac
            else if (e.Message.Split('#').Length == 1 && e.Message.Split('/').Length != 2)
            {
                //string[] getSenderId = e.Message.Split('%');
                string getSenderId = clientSockets.FirstOrDefault(x => x.Value == e.ID).Key;
                if (e.Message.Split(':').Length > 1)
                {
                addLog(this.logs, Constants.NEW_MSG_RECIVED + " from " + getSenderId + " " + e.Message, Constants.LOG_INFO);
                    try
                    {
                        string forwarded = switchBox.forwardMessage(getSenderId + "%" + e.Message);
                        string[] getNextNode = forwarded.Split('%');
                        server.sendMessage(clientSockets[getNextNode[0]], getSenderId + "%" + getNextNode[1]);
                        addLog(this.logs, Constants.FORWARD_MESSAGE + " " + forwarded, Constants.LOG_INFO);
                    }
                    catch
                    {
                        addLog(this.logs, Constants.UNREACHABLE_DST + " " + switchBox.forwardMessage(getSenderId + "%" + e.Message), Constants.LOG_ERROR);
                    }
                }

            }

            else if (e.Message.Split('#').Length == 1 && e.Message.Split('/').Length == 2)
            {
                string getSenderId = clientSockets.FirstOrDefault(x => x.Value == e.ID).Key;
                string[] receivedSlots = SynchronousTransportModule.getSlots(e.Message.Split('/')[0]);
                if (receivedSlots != null)
                {
                    addLog(this.logs, Constants.NEW_MSG_RECIVED + " from " + getSenderId + " " + e.Message, Constants.LOG_INFO);
                    try
                    {
                        string forwarded = switchBox.forwardMessage(getSenderId + "%" + e.Message);
                        string[] getNextNode = forwarded.Split('%');
                        server.sendMessage(clientSockets[getNextNode[0]], getSenderId + "%" + getNextNode[1]);
                        addLog(this.logs, Constants.FORWARD_MESSAGE + " " + forwarded, Constants.LOG_INFO);
                    }
                    catch
                    {
                        addLog(this.logs, Constants.UNREACHABLE_DST + " " + switchBox.forwardMessage(getSenderId + "%" + e.Message), Constants.LOG_ERROR);
                    }
                }
            }
            else
            {
                try
                {
                    if (clientSockets.Keys.Contains(e.Message.Split('#')[0]))
                    {
                        bool isConnected = clientSockets[(e.Message.Split('#')[0])].Connected;
                        if (!isConnected)
                        {
                            clientSockets.Remove(e.Message.Split('#')[0]);
                            clientSockets.Add(e.Message.Split('#')[0], e.ID);
                            addLog(this.logs, Constants.NEW_CLIENT_LOG + " " + e.Message.Split('#')[0], Constants.LOG_INFO);
                        }
                    }
                    else
                    {
                        clientSockets.Add(e.Message.Split('#')[0], e.ID);
                        addLog(this.logs, Constants.NEW_CLIENT_LOG + " " + e.Message.Split('#')[0], Constants.LOG_INFO);
                    }
                }
                catch
                {
                    addLog(this.logs, Constants.ALREADY_CONNECTED + " " + e.Message.Split('#')[0], Constants.LOG_ERROR);
                }

            }
        }