示例#1
0
 internal Connection(Options opts)
 {
     this.opts = opts;
     this.pongs = createPongs();
     this.ps = new Parser(this);
     this.pingProtoBytes = System.Text.Encoding.UTF8.GetBytes(IC.pingProto);
     this.pingProtoBytesLen = pingProtoBytes.Length;
     this.pongProtoBytes = System.Text.Encoding.UTF8.GetBytes(IC.pongProto);
     this.pongProtoBytesLen = pongProtoBytes.Length;
 }
示例#2
0
文件: Conn.cs 项目: nats-io/csnats
        private void readLoop()
        {
            // Stack based buffer.
            byte[] buffer = new byte[Defaults.defaultReadLength];
            Parser parser = new Parser(this);
            int    len;

            while (true)
            {
                try
                {
                    len = br.Read(buffer, 0, Defaults.defaultReadLength);
                    parser.parse(buffer, len);
                }
                catch (Exception e)
                {
                    if (State != ConnState.CLOSED)
                    {
                        processOpError(e);
                    }
                    break;
                }
            }
        }
示例#3
0
        private void readLoop()
        {
            // Stack based buffer.
            byte[] buffer = new byte[Defaults.defaultReadLength];
            Parser parser = new Parser(this);
            int    len;
            bool   sb;

            while (true)
            {
                sb = false;
                lock (mu)
                {
                    sb = (isClosed() || isReconnecting());
                    if (sb)
                        this.ps = parser;
                }

                try
                {
                    len = br.Read(buffer, 0, Defaults.defaultReadLength);
                    parser.parse(buffer, len);
                }
                catch (Exception e)
                {
                    if (State != ConnState.CLOSED)
                    {
                        processOpError(e);
                    }
                    break;
                }
            }

            lock (mu)
            {
                parser = null;
            }
        }
示例#4
0
        internal Connection(Options opts)
        {
            this.opts = new Options(opts);
            this.pongs = createPongs();
            this.ps = new Parser(this);

            PING_P_BYTES = System.Text.Encoding.UTF8.GetBytes(IC.pingProto);
            PING_P_BYTES_LEN = PING_P_BYTES.Length;

            PONG_P_BYTES = System.Text.Encoding.UTF8.GetBytes(IC.pongProto);
            PONG_P_BYTES_LEN = PONG_P_BYTES.Length;

            PUB_P_BYTES = Encoding.UTF8.GetBytes(IC._PUB_P_);
            PUB_P_BYTES_LEN = PUB_P_BYTES.Length;

            CRLF_BYTES = Encoding.UTF8.GetBytes(IC._CRLF_);
            CRLF_BYTES_LEN = CRLF_BYTES.Length;

            // predefine the start of the publish protocol message.
            buildPublishProtocolBuffer(Defaults.scratchSize);
        }