コード例 #1
0
        private void processIncommingXFR()
        {
            while (incommingXFRQueue.Count > 0)
            {
                MSNMessage message = incommingXFRQueue.Dequeue();

                try
                {
                    #region process command
                    //XFR 12 SB 207.46.26.161:1863 CKI 1790215149.6727142.1184104\r\n
                    String        address      = message.getData()[1].Replace(":1863", "");
                    int           port         = 1863;
                    String        authCode     = message.getData()[3].ToString();
                    String        trID         = message.getTrID().ToString();
                    List <String> initialUsers = newConversationContacts[trID.ToString()];
                    #endregion

                    #region try to find existing switchboard to connect to
                    MSNSwitchboard existingAddTo = null;
                    for (int i = 0; i < activeSwitchboards.Count; i++)
                    {
                        MSNSwitchboard testSwitchboard  = (MSNSwitchboard)activeSwitchboards[i];
                        List <String>  switchboardUsers = testSwitchboard.getConnectedUsers();

                        #region test initial users = switchboardUsers
                        int checkCounter = 0;
                        for (int x = 0; x < initialUsers.Count; x++)
                        {
                            for (int y = 0; y < switchboardUsers.Count; y++)
                            {
                                if (initialUsers[x].Equals(switchboardUsers[y].ToString()))
                                {
                                    checkCounter++;
                                }
                            }
                        }

                        bool usersEqual = false;
                        if (initialUsers.Count == switchboardUsers.Count && checkCounter == initialUsers.Count)
                        {
                            usersEqual = true;
                        }
                        #endregion

                        if (usersEqual)
                        {
                            existingAddTo = testSwitchboard;
                            existingAddTo.reconnect(address, port, authCode, initialUsers);

                            if (SwitchboardReCreated != null)
                            {
                                SwitchboardReCreated(existingAddTo);
                            }
                        }
                    }
                    #endregion

                    #region build switchboard (and load plugins) if no existing switchboard
                    if (existingAddTo == null)
                    {
                        MSNSwitchboard s = new MSNSwitchboard(controller, address, port, authCode, initialUsers);

                        activeSwitchboards.Add(s);

                        if (SwitchboardCreated != null)
                        {
                            SwitchboardCreated(s);
                        }
                    }
                    #endregion
                }
                catch (Exception)
                {
                    Console.WriteLine("Error processing XFR message in MSNSwitchboardController.processXFR(), message = " + message.ToString());
                }
            }
        }
コード例 #2
0
        private void processIncommingRNG()
        {
            while (incommingRNGQueue.Count > 0)
            {
                MSNMessage message = incommingRNGQueue.Dequeue();

                try
                {
                    #region process command
                    //RNG 11752013 207.46.108.38:1863 CKI 849102291.520491113 [email protected] Example%20Name\r\n
                    String   address      = message.getData()[0].Replace(":1863", "");
                    int      port         = 1863;
                    String   authCode     = message.getData()[2];
                    String   rngTrID      = message.getTrID().ToString();
                    String[] initialUsers = new String[] { message.getData()[3] };
                    #endregion

                    #region try to find existing switchboard to connect to
                    MSNSwitchboard existingAddTo = null;
                    for (int i = 0; i < activeSwitchboards.Count; i++)
                    {
                        MSNSwitchboard testSwitchboard  = (MSNSwitchboard)activeSwitchboards[i];
                        List <String>  switchboardUsers = testSwitchboard.getConnectedUsers();

                        #region test initial users = switchboardUsers
                        int checkCounter = 0;
                        for (int x = 0; x < initialUsers.Length; x++)
                        {
                            for (int y = 0; y < switchboardUsers.Count; y++)
                            {
                                if (initialUsers[x].Equals(switchboardUsers[y].ToString()))
                                {
                                    checkCounter++;
                                }
                            }
                        }

                        bool usersEqual = false;
                        if (initialUsers.Length == switchboardUsers.Count && checkCounter == initialUsers.Length)
                        {
                            usersEqual = true;
                        }
                        #endregion

                        if (usersEqual)
                        {
                            existingAddTo = testSwitchboard;
                            existingAddTo.reconnect(address, port, authCode, rngTrID);

                            if (SwitchboardReCreated != null)
                            {
                                SwitchboardReCreated(existingAddTo);
                            }
                        }
                    }
                    #endregion

                    #region build switchboard (and load plugins) if no existing switchboard found
                    if (existingAddTo == null)
                    {
                        MSNSwitchboard s = new MSNSwitchboard(controller, address, port, authCode, rngTrID);

                        activeSwitchboards.Add(s);

                        if (SwitchboardCreated != null)
                        {
                            SwitchboardCreated(s);
                        }
                    }
                    #endregion
                }
                catch (Exception)
                {
                    Console.WriteLine("Error processing RNG message in MSNSwitchboardController.processRNG(), message = " + message.ToString());
                }
            }
        }