Ejemplo n.º 1
0
    private static void ReceiveCallback(IAsyncResult ar)
    {
        try
        {
            int bytesRead = m_ClientState.Socket.EndReceive(ar);
            if (bytesRead > 0)
            {
                string msg = Encoding.ASCII.GetString(m_ClientState.Buffer, 0, bytesRead);

                if (m_ClientManager.PublicKeyReceived)
                {
                    m_ClientState.MessageQueue.Append(msg);
                    ClientManager.MessageIsolator.ProcessStream();
                }

                else if (AsymModule.IsPublicKey(msg))
                {
                    EventSink.InvokePublicKeySetEvent();
                }

                m_ClientState.Socket.BeginReceive
                    (m_ClientState.Buffer, 0, ClientState.BufferSize, 0,
                    new AsyncCallback(ReceiveCallback), m_ClientState);
            }
        }

        catch (Exception e)
        {
            EventSink.InvokeStandardLogEvent(new LogEventArgs(e.ToString()));
        }
    }
Ejemplo n.º 2
0
 private void SendSessionKey()
 {
     Client.Send
         (AsymModule.EncryptStringToString(GetAesKeyVector()));
 }