Exemple #1
0
        public byte[] HeartbeatReqeust()
        {
            var heartbeat = new ZtLiveCsHeartbeat
            {
                ClientTimestampMs = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
                Sequence          = _HeartbeatSeqId,
            };

            var cmd = GenerateCommand(GlobalCommand.HEARTBEAT, heartbeat);

            var payload = GeneratePayload(Command.GLOBAL_COMMAND, cmd);

            var body = payload.ToByteArray();

            var header = GenerateHeader(body);

            _HeartbeatSeqId++;
            Interlocked.Increment(ref SeqId);

            Log.Debug("--------");
            Log.Debug("Up\t\t {HeaderSeqId}, {SeqId}, {Command}", header.SeqId, payload.SeqId, payload.Command);
            Log.Debug("Header: {Header}", header);
            Log.Debug("Payload Base64: {Payload}", Convert.ToBase64String(body));
            Log.Debug("Payload: {Payload}", payload);
            Log.Debug("\t{Command}", cmd);
            Log.Debug("\t\t{Heartbeat}", heartbeat);
            Log.Debug("--------");

            return(Encode(header, body, SessionKey));
        }
Exemple #2
0
        internal byte[] HeartbeatReqeust()
        {
            var hearbeat = new ZtLiveCsHeartbeat
            {
                ClientTimestampMs = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
                Sequence          = HeartbeatSeqId,
            };

            var cmd = GenerateCommand(GlobalCommand.HEARTBEAT, hearbeat);

            var payload = GeneratePayload(Command.GLOBAL_COMMAND, cmd);

            var body = payload.ToByteString();

            var header = GenerateHeader(body);

            HeartbeatSeqId++;
            SeqId++;

            return(Encode(header, body, SessionKey));
        }
Exemple #3
0
        byte[] Heartbeat()
        {
            var hearbeat = new ZtLiveCsHeartbeat
            {
                ClientTimestampMs = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
                Sequence          = HeartbeatSeqId++,
            };

            var cmd = new ZtLiveCsCmd
            {
                CmdType = GlobalCommand.HEARTBEAT,
                Payload = hearbeat.ToByteString(),
                Ticket  = Tickets[TicketIndex],
                LiveId  = LiveId,
            };

            var payload = new UpstreamPayload
            {
                Command     = Command.GLOBAL_COMMAND,
                SeqId       = SeqId,
                RetryCount  = RetryCount,
                PayloadData = cmd.ToByteString(),
                SubBiz      = SubBiz,
            };

            var body = payload.ToByteString();

            var header = new PacketHeader
            {
                AppId             = AppId,
                Uid               = UserId,
                InstanceId        = InstanceId,
                DecodedPayloadLen = body.Length,
                EncryptionMode    = PacketHeader.Types.EncryptionMode.KEncryptionSessionKey,
                SeqId             = SeqId++,
                Kpn               = KPN
            };

            return(Encode(header, body));
        }