Beispiel #1
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);
                    }
                }
            }
        }
Beispiel #2
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);
                }
            }
        }