Пример #1
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));
        }
Пример #2
0
        byte[] EnterRoom()
        {
            var request = new ZtLiveCsEnterRoom
            {
                EnterRoomAttach      = EnterRoomAttach,
                ClientLiveSdkVersion = ClientLiveSdkVersion
            };

            var cmd = new ZtLiveCsCmd
            {
                CmdType = GlobalCommand.ENTER_ROOM,
                Payload = request.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             = HeaderSeqId++,
                Kpn               = KPN
            };

            return(Encode(header, body));
        }