public async Task <List <SignalServiceEnvelope> > RetrieveMessages(CancellationToken token, IMessagePipeCallback callback)
        {
            List <SignalServiceEnvelope>       results  = new List <SignalServiceEnvelope>();
            List <SignalServiceEnvelopeEntity> entities = await Socket.GetMessages(token);

            foreach (SignalServiceEnvelopeEntity entity in entities)
            {
                SignalServiceEnvelope envelope;

                if (entity.Source != null && entity.SourceDevice > 0)
                {
                    envelope = new SignalServiceEnvelope((int)entity.Type, entity.Source,
                                                         (int)entity.SourceDevice, (int)entity.Timestamp,
                                                         entity.Message, entity.Content,
                                                         entity.ServerTimestamp, entity.ServerUuid);
                }
                else
                {
                    envelope = new SignalServiceEnvelope((int)entity.Type, (int)entity.Timestamp,
                                                         entity.Message, entity.Content,
                                                         entity.ServerTimestamp, entity.ServerUuid);
                }

                await callback.OnMessage(envelope);

                results.Add(envelope);

                if (envelope.Envelope.ServerGUidOneofCase == Envelope.ServerGUidOneofOneofCase.ServerGuid)
                {
                    await Socket.AcknowledgeMessage(token, envelope.Envelope.ServerGuid);
                }
                else
                {
                    await Socket.AcknowledgeMessage(token, entity.Source, entity.Timestamp);
                }
            }
            return(results);
        }
예제 #2
0
        public async Task <List <SignalServiceEnvelope> > RetrieveMessages(CancellationToken token, IMessagePipeCallback callback)
        {
            List <SignalServiceEnvelope>       results  = new List <SignalServiceEnvelope>();
            List <SignalServiceEnvelopeEntity> entities = await Socket.GetMessages(token);

            foreach (SignalServiceEnvelopeEntity entity in entities)
            {
                SignalServiceEnvelope envelope = new SignalServiceEnvelope((int)entity.Type, entity.Source,
                                                                           (int)entity.SourceDevice, entity.Relay,
                                                                           (int)entity.Timestamp, entity.Message,
                                                                           entity.Content);

                await callback.OnMessage(envelope);

                results.Add(envelope);

                await Socket.AcknowledgeMessage(token, entity.Source, entity.Timestamp);
            }
            return(results);
        }