Exemplo n.º 1
0
 protected override void ProcessPlug()
 {
     //  Start polling for incoming connections.
     m_ioObject.SetHandler(this);
     m_ioObject.AddFd(m_handle);
     m_ioObject.SetPollin(m_handle);
 }
Exemplo n.º 2
0
        public void Plug(IOThread ioThread,
                         SessionBase session)
        {
            Debug.Assert(!m_plugged);
            m_plugged = true;

            //  Connect to session object.
            Debug.Assert(m_session == null);
            Debug.Assert(session != null);
            m_session = session;
            m_socket  = m_session.Socket;

            m_ioObject = new IOObject(null);
            m_ioObject.SetHandler(this);
            //  Connect to I/O threads poller object.
            m_ioObject.Plug(ioThread);
            m_ioObject.AddFd(m_handle);

            //  Send the 'length' and 'flags' fields of the identity message.
            //  The 'length' field is encoded in the long format.

            m_greetingOutputBuffer[m_outsize++] = ((byte)0xff);
            m_greetingOutputBuffer.PutLong(m_options.Endian, (long)m_options.IdentitySize + 1, 1);
            m_outsize += 8;
            m_greetingOutputBuffer[m_outsize++] = ((byte)0x7f);

            m_outpos = new ByteArraySegment(m_greetingOutputBuffer);

            m_ioObject.SetPollin(m_handle);
            m_ioObject.SetPollout(m_handle);

            //  Flush all the data that may have been already received downstream.
            InEvent();
        }
Exemplo n.º 3
0
        public void ActivateIn()
        {
            //  It is possible that the most recently used decoder
            //  processed the whole buffer but failed to write
            //  the last message into the pipe.
            if (m_pendingBytes == 0)
            {
                if (m_decoder != null)
                {
                    m_decoder.ProcessBuffer(null, 0);
                    m_session.Flush();
                }

                m_ioObject.SetPollin(m_handle);

                return;
            }

            Debug.Assert(m_decoder != null);
            Debug.Assert(m_pendingData != null);

            //  Ask the decoder to process remaining data.
            int n = m_decoder.ProcessBuffer(m_pendingData, m_pendingBytes);

            m_pendingBytes -= n;
            m_session.Flush();;

            if (m_pendingBytes > 0)
            {
                return;
            }

            //  Resume polling.
            m_ioObject.SetPollin(m_handle);

            InEvent();
        }
Exemplo n.º 4
0
        public void Plug(IOThread ioThread, SessionBase session)
        {
            m_session = session;

            m_socket = session.Socket;

            m_ioObject = new IOObject(null);
            m_ioObject.SetHandler(this);
            m_ioObject.Plug(ioThread);
            m_ioObject.AddFd(m_handle);
            m_ioObject.SetPollin(m_handle);

            DropSubscriptions();

            // push message to the session because there is no identity message with pgm
            session.PushMsg(new Msg());
        }
Exemplo n.º 5
0
        public void ActivateIn()
        {
            if (m_inputError)
            {
                //  There was an input error but the engine could not
                //  be terminated (due to the stalled decoder).
                //  Flush the pending message and terminate the engine now.
                m_decoder.ProcessBuffer(m_inpos, 0);
                Debug.Assert(!m_decoder.Stalled());
                m_session.Flush();
                Error();
                return;
            }

            m_ioObject.SetPollin(m_handle);

            //  Speculative read.
            m_ioObject.InEvent();
        }
Exemplo n.º 6
0
        public void Plug(IOThread ioThread,
		                 SessionBase session)
        {
            Debug.Assert(!m_plugged);
            m_plugged = true;

            //  Connect to session object.
            Debug.Assert(m_session == null);
            Debug.Assert(session != null);
            m_session = session;
            m_socket = m_session.Socket;

            m_ioObject = new IOObject(null);
            m_ioObject.SetHandler(this);
            //  Connect to I/O threads poller object.
            m_ioObject.Plug(ioThread);
            m_ioObject.AddFd(m_handle);

            //  Send the 'length' and 'flags' fields of the identity message.
            //  The 'length' field is encoded in the long format.

            m_greetingOutputBuffer[m_outsize++] = ((byte) 0xff);
            m_greetingOutputBuffer.PutLong((long) m_options.IdentitySize + 1, 1);
            m_outsize += 8;
            m_greetingOutputBuffer[m_outsize++] = ((byte) 0x7f);

            m_outpos = new ByteArraySegment(m_greetingOutputBuffer);

            m_ioObject.SetPollin(m_handle);
            m_ioObject.SetPollout(m_handle);

            //  Flush all the data that may have been already received downstream.
            InEvent();
        }
Exemplo n.º 7
0
        public void Plug(IOThread ioThread, SessionBase session)
        {
            m_session = session;

            m_socket = session.Socket;

            m_ioObject = new IOObject(null);
            m_ioObject.SetHandler(this);
            m_ioObject.Plug(ioThread);
            m_ioObject.AddFd(m_handle);
            m_ioObject.SetPollin(m_handle);

            DropSubscriptions();

            // push message to the session because there is no identity message with pgm
            session.PushMsg(new Msg());
        }