示例#1
0
        public bool SendMeta(IClientSession session, IMutableMessage message)
        {
            if (ChannelFields.META_HANDSHAKE.Equals(message.Channel))
            {
                message.GetExt(true)[EXT_FIELD] = true;
                _ackId = -1;
            }
            else if (_serverSupportsAcks && ChannelFields.META_CONNECT.Equals(message.Channel))
            {
                message.GetExt(true)[EXT_FIELD] = _ackId;
            }

            return(true);
        }
示例#2
0
        public bool SendMeta(IClientSession session, IMutableMessage message)
        {
            if (ChannelFields.MetaHandshake.Equals(message.Channel))
            {
                message.GetExt(true)[ExtField] = true;
                _ackId = -1;
            }
            else if (_serverSupportsAcks && ChannelFields.MetaConnect.Equals(message.Channel))
            {
                message.GetExt(true)[ExtField] = _ackId;
            }

            return(true);
        }
        public bool SendMeta(IClientSession session, IMutableMessage message)
        {
            switch (message.Channel)
            {
            case ChannelFields.MetaHandshake:
                message.GetExt(true)[ExtField] = true;
                break;

            case ChannelFields.MetaSubscribe:
                message.GetExt(true)[ExtField] = new Dictionary <string, long>(_channelToReplayId);
                break;
            }

            return(true);
        }
示例#4
0
        public bool ReceiveMeta(IClientSession session, IMutableMessage message)
        {
            var ext = (Dictionary<string, object>)message.GetExt(false);
            if (ext != null)
            {
                var sync = (Dictionary<string, object>)ext["timesync"];
                if (sync != null)
                {
                    var now = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;

                    var tc = ObjectConverter.ToInt64(sync["tc"], 0);
                    var ts = ObjectConverter.ToInt64(sync["ts"], 0);
                    var p = ObjectConverter.ToInt32(sync["p"], 0);
                    // final int a=((Number)sync.get("a")).intValue();

                    var l2 = (int)((now - tc - p) / 2);
                    var o2 = (int)(ts - tc - l2);

                    Lag = Lag == 0 ? l2 : (Lag + l2) / 2;
                    Offset = Offset == 0 ? o2 : (Offset + o2) / 2;
                }
            }

            return true;
        }
示例#5
0
 public bool SendMeta(IClientSession session, IMutableMessage message)
 {
     var ext = (Dictionary<string, object>)message.GetExt(true);
     var now = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
     // Changed JSON.Literal to string
     var timesync = "{\"tc\":" + now + ",\"l\":" + Lag + ",\"o\":" + Offset + "}";
     ext["timesync"] = timesync;
     return true;
 }
示例#6
0
        public bool ReceiveMeta(IClientSession session, IMutableMessage message)
        {
            if (ChannelFields.META_HANDSHAKE.Equals(message.Channel))
            {
                var ext = (Dictionary <string, object>)message.GetExt(false);
                _serverSupportsReplay = ext != null && true.Equals(ext[EXTENSION_NAME]);
            }

            return(true);
        }
        public bool ReceiveMeta(IClientSession session, IMutableMessage message)
        {
            if (ChannelFields.MetaHandshake.Equals(message.Channel))
            {
                var ext = message.GetExt(false);
                _serverSupportsReplay = ext?[ExtField] != null;
            }

            return(true);
        }
示例#8
0
        public bool ReceiveMeta(IClientSession session, IMutableMessage message)
        {
            if (ChannelFields.META_HANDSHAKE.Equals(message.Channel))
            {
                var ext = (Dictionary <string, object>)message.GetExt(false);
                _serverSupportsAcks = ext != null && true.Equals(ext[EXT_FIELD]);
            }
            else if (_serverSupportsAcks && true.Equals(message[MessageFields.SUCCESSFUL_FIELD]) && ChannelFields.META_CONNECT.Equals(message.Channel))
            {
                var ext = (Dictionary <string, object>)message.GetExt(false);
                if (ext != null)
                {
                    ext.TryGetValue(EXT_FIELD, out var ack);
                    _ackId = ObjectConverter.ToInt32(ack, _ackId);
                }
            }

            return(true);
        }
示例#9
0
        public bool ReceiveMeta(IClientSession session, IMutableMessage message)
        {
            if (ChannelFields.MetaHandshake.Equals(message.Channel))
            {
                var ext = (Dictionary <string, object>)message.GetExt(false);
                _serverSupportsAcks = ext != null && true.Equals(ext[ExtField]);
            }
            else if (_serverSupportsAcks && true.Equals(message[MessageFields.SuccessfulField]) && ChannelFields.MetaConnect.Equals(message.Channel))
            {
                var ext = (Dictionary <string, object>)message.GetExt(false);

                if (ext == null)
                {
                    return(true);
                }

                ext.TryGetValue(ExtField, out var ack);
                _ackId = ObjectConverter.ToInt32(ack, _ackId);
            }

            return(true);
        }
        public bool SendMeta(IClientSession session, IMutableMessage message)
        {
            if (ChannelFields.META_SUBSCRIBE.Equals(message.Channel) ||
                ChannelFields.META_UNSUBSCRIBE.Equals(message.Channel))
            {
                var value = new Dictionary <string, object>
                {
                    { message.Subscription, message.ReplayId }
                };

                message.GetExt(true)[EXTENSION_NAME] = value;
            }
            return(true);
        }
        public bool ReceiveMeta(IClientSession session, IMutableMessage message)
        {
            var ext  = (Dictionary <string, object>)message.GetExt(false);
            var sync = (Dictionary <string, object>)ext?["timesync"];

            if (sync != null)
            {
                var now = (DateTime.Now.Ticks - 621355968000000000) / 10000;

                var tc = ObjectConverter.ToInt64(sync["tc"], 0);
                var ts = ObjectConverter.ToInt64(sync["ts"], 0);
                var p  = ObjectConverter.ToInt32(sync["p"], 0);

                var l2 = (int)((now - tc - p) / 2);
                var o2 = (int)(ts - tc - l2);

                _lag    = _lag == 0 ? l2 : (_lag + l2) / 2;
                _offset = _offset == 0 ? o2 : (_offset + o2) / 2;
            }

            return(true);
        }