コード例 #1
0
        private void BeginRead(PipeHeaderData hd)
        {
            bool isConnected = hd.pipe.IsConnected;

            try
            {
                hd.pipe.BeginRead(hd.data, 0, hd.data.Length, OnReadMessage, hd);
            }
            catch (Exception ex)
            {
                //AnalyzerManager.Logger.Error(ex);
                isConnected = false;
            }
        }
コード例 #2
0
        private void OnReadMessage(IAsyncResult result)
        {
            PipeHeaderData hd        = (PipeHeaderData)result.AsyncState;
            int            bytesRead = hd.pipe.EndRead(result);

            if (bytesRead != 0)
            {
                Array.Resize(ref hd.data, bytesRead);
                try
                {
                    switch (hd.pipeServerType)
                    {
                    case 0:
                        MessageProcessor.ProcessMessage(Encoding.ASCII.GetString(hd.data));
                        break;

                    case 1:
                        HookDllMessageProcessor.ProcessMessage(hd.data);
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    //AnalyzerManager.Logger.Error(ex);
                }
                BeginRead(hd);
            }
            else
            {
                try
                {
                    m_pipes.TryRemove(hd.pipe, out hd);
                    hd.pipe.Close();
                }
                catch (Exception ex)
                {
                    //AnalyzerManager.Logger.Error(ex);
                }
                if (hd != null)
                {
                    m_handler.OnDisconnect(hd.pipe, hd.state);
                    PipeServerCreate(hd.pipeServerType);
                }
            }
        }
コード例 #3
0
        private void OnClientConnected(IAsyncResult result)
        {
            NamedPipeServerStream pipe = (NamedPipeServerStream)result.AsyncState;

            pipe.EndWaitForConnection(result);

            PipeHeaderData hd = m_pipes[pipe];

            hd.state = null;
            hd.pipe  = pipe;
            hd.data  = new byte[BUFFER_SIZE];

            m_handler.OnConnect(pipe, out hd.state);

            BeginRead(hd);
        }