Exemple #1
0
        private void OnClientConnected(IAsyncResult result)
        {
            // Complete the client connection
            NamedPipeServerStream pipe = (NamedPipeServerStream)result.AsyncState;

            pipe.EndWaitForConnection(result);

            // Create client pipe structure
            IpcPipeData pd = new IpcPipeData {
                Pipe = pipe, State = null, Data = new Byte[ServerInBufferSize]
            };

            // Add connection to connection list
            bool running;

            lock (_pipes)
            {
                running = _running;
                if (running)
                {
                    _pipes.Add(pd.Pipe, pd);
                }
            }

            // If server is still running
            if (running)
            {
                // Prepare for next connection
                IpcServerPipeCreate();

                // Alert server that client connection exists
                _iipcCallback.OnAsyncConnect(pipe, out pd.State);

                // Accept messages
                BeginRead(pd);
            }
            else
            {
                pipe.Close();
            }
        }
Exemple #2
0
        private void OnClientConnected(IAsyncResult result)
        {
            // Complete the client connection
            NamedPipeServerStream pipe = (NamedPipeServerStream)result.AsyncState;

            pipe.EndWaitForConnection(result);
            // Create client pipe structure
            IpcPipeData pd = new IpcPipeData();

            pd.pipe  = pipe;
            pd.state = null;
            pd.data  = new Byte[SERVER_IN_BUFFER_SIZE];
            // Add connection to connection list
            bool running;

            lock (m_pipes)
            {
                running = m_running;
                if (running)
                {
                    m_pipes.Add(pd.pipe, pd);
                }
            }

            // If server is still running
            if (running)
            {
                // Prepare for next connection
                IpcServerPipeCreate();
                // Alert server that client connection exists
                m_callback.OnAsyncConnect(pipe, out pd.state);
                // Accept messages
                BeginRead(pd);
            }
            else
            {
                pipe.Close();
            }
        }