Ejemplo n.º 1
0
        private void _onData(object data)
        {
            var log = LogManager.GetLogger(GlobalHelper.CallerName());

            log.Info(string.Format("polling got data {0}", data));
            var callback = new DecodePayloadCallback(this);

            if (data is string)
            {
                EngineParser.DecodePayload((string)data, callback);
            }
            else if (data is byte[])
            {
                EngineParser.DecodePayload((byte[])data, callback);
            }

            if (ReadyState != ReadyStateEnum.CLOSED)
            {
                IsPolling = false;
                log.Info("ReadyState != ReadyStateEnum.CLOSED");
                Emit(EVENT_POLL_COMPLETE);

                if (ReadyState == ReadyStateEnum.OPEN)
                {
                    Poll();
                }
                else
                {
                    log.Info(string.Format("ignoring poll - transport state {0}", ReadyState));
                }
            }
        }
Ejemplo n.º 2
0
        protected override void Write(List <EnginePacket> packets)
        {
            var log = LogManager.GetLogger(GlobalHelper.CallerName());

            log.Info("Write packets.Count = " + packets.Count);

            Writable = false;

            var callback = new SendEncodeCallback(this);

            EngineParser.EncodePayload(packets.ToArray(), callback);
        }
Ejemplo n.º 3
0
        protected override void Write(List <EnginePacket> packets)
        {
            Writable = false;
            lock (packets)
            {
                foreach (var packet in packets)
                {
                    EngineParser.EncodePacket(packet, new WriteEncodeCallback(this));
                }
            }

            // fake drain
            // defer to next tick to allow Socket to clear writeBuffer
            //EasyTimer.SetTimeout(() =>
            //{
            Writable = true;
            Emit(EVENT_DRAIN);
            //}, 1);
        }
Ejemplo n.º 4
0
 protected virtual void OnData(byte[] data)
 {
     this.OnPacket(EngineParser.DecodePacket(data));
 }