コード例 #1
0
        private byte[] createSentTranscriptMessage(byte[] content, May <SignalServiceAddress> recipient, ulong timestamp)
        {
            {
                try
                {
                    Content.Builder                container   = Content.CreateBuilder();
                    SyncMessage.Builder            syncMessage = SyncMessage.CreateBuilder();
                    SyncMessage.Types.Sent.Builder sentMessage = SyncMessage.Types.Sent.CreateBuilder();

                    sentMessage.SetTimestamp(timestamp);
                    sentMessage.SetMessage(DataMessage.ParseFrom(content));

                    if (recipient.HasValue)
                    {
                        sentMessage.SetDestination(recipient.ForceGetValue().getNumber());
                    }

                    return(container.SetSyncMessage(syncMessage.SetSent(sentMessage)).Build().ToByteArray());;
                }
                catch (InvalidProtocolBufferException e)
                {
                    throw new Exception(e.Message);
                }
            }
        }
コード例 #2
0
        private byte[] createMultiDeviceSentTranscriptContent(byte[] content, May <SignalServiceAddress> recipient, ulong timestamp)
        {
            try
            {
                Content.Builder                container   = Content.CreateBuilder();
                SyncMessage.Builder            syncMessage = SyncMessage.CreateBuilder();
                SyncMessage.Types.Sent.Builder sentMessage = SyncMessage.Types.Sent.CreateBuilder();
                DataMessage dataMessage = DataMessage.ParseFrom(content);

                sentMessage.SetTimestamp(timestamp);
                sentMessage.SetMessage(dataMessage);

                if (recipient.HasValue)
                {
                    sentMessage.SetDestination(recipient.ForceGetValue().getNumber());
                }

                if (dataMessage.ExpireTimer > 0)
                {
                    sentMessage.SetExpirationStartTimestamp((ulong)Util.CurrentTimeMillis());
                }

                return(container.SetSyncMessage(syncMessage.SetSent(sentMessage)).Build().ToByteArray());
            }
            catch (InvalidProtocolBufferException e)
            {
                throw new Exception(e.Message);
            }
        }