Exemplo n.º 1
0
        void switchboard_UserConnected(dotMSN.MSNSwitchboard switchboard, string username, bool joined)
        {
            if (joined)
            {
                m_convos[username] = switchboard;

                if (m_msgque[username] != null)
                {
                    ArrayList msgs = m_msgque[username] as ArrayList;
                    if (msgs != null)
                    {
                        foreach (string strMessage in msgs)
                        {
                            switchboard.sendMessage(new dotMSN.MSNUserOutgoingMessage(@"Times New Roman", strMessage));
                        }

                        m_msgque.Remove(username);
                    }
                }
            }
            else
            {
                if (m_convos[username] != null)
                {
                    m_convos.Remove(username);
                }
            }
        }
Exemplo n.º 2
0
        //public override void Disconnect()
        //{
        //    base.Disconnect();
        //    //m_msn.CloseConnection();
        //    m_msn.NameserverProcessor.Disconnect();

        //    // reset the m_msn object
        //    InitMSN();
        //}

        //private void OnConversationCreated(object sender, DotMSN.ConversationCreatedEventArgs e)
        //{
        //    // if e.Initiator is null, then this convo was created by a remote user
        //    // otherwise it was created by us!
        //    if (e.Initiator == null)
        //    {
        //        Console.WriteLine("MSN: Conversation initiated by remote user...");

        //    }
        //    else
        //    {
        //        Console.WriteLine("MSN: Conversation initiated locally...");

        //    }

        //    //e.Conversation.Switchboard.TextMessageReceived += new XihSolutions.DotMSN.TextMessageReceivedEventHandler(MessageHandler);

        //    //e.Conversation.MessageReceived += new Conversation.MessageReceivedHandler(MessageHandler);
        //    //e.Conversation.ContactJoin += new Conversation.ContactJoinHandler(ContactJoined);
        //    //e.Conversation.ContactLeave += new Conversation.ContactLeaveHandler(ContactLeave);
        //}

        ////private void ContactLeave(Conversation sender, ContactEventArgs e)
        ////{
        ////    m_convos[e.Contact.Mail] = null;
        ////}

        //private void ContactJoined(DotMSN.Conversation sender, DotMSN.ContactEventArgs e)
        //{
        //    //m_convos[e.Contact.Mail] = sender;

        //    //if (sender.ClientData != null)
        //    //{
        //    //    SendMessage(e.Contact.Mail, (string)sender.ClientData);
        //    //    sender.ClientData = null;
        //    //}
        //}

        //private void MessageHandler(object sender, XihSolutions.DotMSN.TextMessageEventArgs e)
        //{

        //    DotMSN.TextMessage msg = e.Message;
        //    DotMSN.Contact con = e.Sender;

        //    if (e.Sender.Status != XihSolutions.DotMSN.PresenceStatus.Away)
        //    {
        //        _OnMessageReceived(con.Mail, msg.Text, false);
        //    }
        //}

        public override void SendMessage(string strUser, string strMessage)
        {
            base.SendMessage(strUser, strMessage);

            if (m_convos[strUser] != null)
            {
                dotMSN.MSNSwitchboard sb = m_convos[strUser] as dotMSN.MSNSwitchboard;

                if (sb != null)
                {
                    sb.sendMessage(new dotMSN.MSNUserOutgoingMessage(@"Times New Roman", strMessage));
                }
            }
            else
            {
                List <string> users = new List <string>();
                users.Add(strUser);
                m_msn.startConversation(users);

                if (m_msgque[strUser] == null)
                {
                    ArrayList msglist = new ArrayList();
                    msglist.Add(strMessage);
                    m_msgque[strUser] = msglist;
                }
                else
                {
                    ArrayList msglist = m_msgque[strUser] as ArrayList;
                    if (msglist != null)
                    {
                        msglist.Add(strMessage);
                    }
                }
            }
        }
Exemplo n.º 3
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());
                }
            }
        }
Exemplo n.º 4
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());
                }
            }
        }
Exemplo n.º 5
0
 void SwitchboardController_SwitchboardCreated(DNBSoft.MSN.ClientController.MSNSwitchboard switchboard)
 {
     switchboard.MessageRecieved += new DNBSoft.MSN.ClientController.MSNEventDelegates.MessageRecieved(switchboard_MessageRecieved);
     switchboard.UserConnected   += new DNBSoft.MSN.ClientController.MSNEventDelegates.SwitchboardUserConnected(switchboard_UserConnected);
 }