Пример #1
1
        /// <summary>
        /// Exchange messages with Outlook.
        /// </summary>
        private void ChatWithOutlook()
        {
            Debug.Assert(m_msgQueue.Count == 0);
            Debug.Assert(m_chattingFlag);

            try
            {
                AnpTransport transport = new AnpTransport(m_outlookSock);

                while (true)
                {
                    if (!transport.isReceiving) transport.beginRecv();
                    if (!transport.isSending && m_msgQueue.Count != 0) transport.sendMsg(m_msgQueue.Dequeue());
                    SelectSockets select = new SelectSockets();
                    select.AddRead(m_outlookSock);
                    if (transport.isSending) select.AddWrite(m_outlookSock);
                    Block(select);
                    transport.doXfer();

                    if (transport.doneReceiving)
                    {
                        OutlookUiThreadMsg msg = new OutlookUiThreadMsg(m_broker, OutlookBrokerMsgType.ReceivedMsg);
                        msg.Msg = transport.getRecv();
                        PostToUI(msg);
                    }
                }
            }

            catch (Exception ex)
            {
                m_chattingFlag = false;
                CloseOutlookSock();
                m_msgQueue.Clear();
                if (ex is WorkerCancellationException) throw;
                OutlookUiThreadMsg msg = new OutlookUiThreadMsg(m_broker, OutlookBrokerMsgType.Disconnected);
                msg.Ex = ex;
                PostToUI(msg);
            }
        }
Пример #2
0
Файл: Tunnel.cs Проект: tmbx/kwm
 /// <summary>
 /// Close the connection to ktlstunnel.
 /// </summary>
 public void Disconnect()
 {
     tunnel.Disconnect();
     transport = null;
 }
Пример #3
0
Файл: Tunnel.cs Проект: tmbx/kwm
 /// <summary>
 /// Kill ktlstunnel.
 /// </summary>
 public void Terminate()
 {
     tunnel.Terminate();
     transport = null;
 }
Пример #4
0
Файл: Tunnel.cs Проект: tmbx/kwm
 /// <summary>
 /// Create an AnpTransport when the tunnel is connected.
 /// </summary>
 public void CreateTransport()
 {
     transport = new AnpTransport(tunnel.EndTls());
     transport.beginRecv();
 }