Esempio n. 1
0
        private void StartReceiveNextMessagePart()
        {
            int toRead = Math.Min(READ_CHUNK_SIZE,
                                  m_expectedMessageLength - m_bytesRead);

            m_onTransport.BeginRead(m_buffer, 0, toRead, new AsyncCallback(this.HandleReadCompleted), this);
        }
Esempio n. 2
0
            public void ProcessIncoming(int msecs)
            {
                int seq = transport.BeginRead();

                try {
                    int       code = (byte)(Packers.Int8.unpack(transport));
                    ReplySlot slot;

                    if (!replies.TryGetValue(seq, out slot) ||
                        (slot.type != ReplySlotType.SLOT_EMPTY && slot.type != ReplySlotType.SLOT_DISCARDED))
                    {
                        throw new ProtocolError("invalid reply sequence: " + seq);
                    }
                    Packers.AbstractPacker packer = (Packers.AbstractPacker)slot.value;
                    bool discard = (slot.type == ReplySlotType.SLOT_DISCARDED);

                    switch (code)
                    {
                    case REPLY_SUCCESS:
                        if (packer == null)
                        {
                            slot.value = null;
                        }

                        /*else if (packer == Packers.MockupPacker) {
                         *      slot.value = transport.ReadAll ();
                         * }*/
                        else
                        {
                            slot.value = packer.unpack(transport);
                        }
                        slot.type = ReplySlotType.SLOT_VALUE;
                        break;

                    case REPLY_PROTOCOL_ERROR:
                        throw (ProtocolError)loadProtocolError();

                    case REPLY_PACKED_EXCEPTION:
                        slot.type  = ReplySlotType.SLOT_EXCEPTION;
                        slot.value = loadPackedException();
                        break;

                    case REPLY_GENERIC_EXCEPTION:
                        slot.type  = ReplySlotType.SLOT_EXCEPTION;
                        slot.value = loadGenericException();
                        break;

                    default:
                        throw new ProtocolError("unknown reply code: " + code);
                    }

                    if (discard)
                    {
                        replies.Remove(seq);
                    }
                } finally {
                    transport.EndRead();
                }
            }
Esempio n. 3
0
            public void process()
            {
                int  seq   = transport.BeginRead();
                byte cmdid = (byte)(Packers.Int8.unpack(transport));

                transport.BeginWrite(seq);

                try {
                    switch (cmdid)
                    {
                    case CMD_INVOKE:
                        processInvoke(seq);
                        break;

                    case CMD_DECREF:
                        processDecref(seq);
                        break;

                    case CMD_INCREF:
                        processIncref(seq);
                        break;

                    case CMD_GETINFO:
                        processGetInfo(seq);
                        break;

                    case CMD_PING:
                        processPing(seq);
                        break;

                    case CMD_QUIT:
                        processQuit(seq);
                        break;

                    default:
                        throw new ProtocolError("unknown command code: " + cmdid);
                    }
                } catch (ProtocolError exc) {
                    transport.RestartWrite();
                    sendProtocolError(exc);
                } catch (GenericException exc) {
                    transport.RestartWrite();
                    sendGenericException(exc);
                } catch (Exception) {
                    transport.CancelWrite();
                    throw;
                } finally {
                    transport.EndRead();
                }
                transport.EndWrite();
            }
Esempio n. 4
0
 public int BeginRead()
 {
     return(transport.BeginRead());
 }