Example #1
0
        private static XmlElement CreateStatusUpdateStanza(PresenceStatus presenceStatus)
        {
            var stanzaType = presenceStatus.IsAvailable ? string.Empty : PresenceStanza.Type.Unavailable;
            var showStatus = ToShowStatus(presenceStatus.AvailabilitySubstate);

            return(PresenceStanza.New(stanzaType, showStatus, presenceStatus.StatusText));
        }
Example #2
0
        public async Task SendStatusUpdateAsync_Sends_Correct_Presence_Stanza()
        {
            var expectedStatus = new PresenceStatus
            {
                AvailabilitySubstate = AvailabilitySubstate.Chat,
                StatusText           = Guid.NewGuid().ToString()
            };
            var token      = new CancellationToken();
            var sentStanza = default(XmlElement);

            HandlersRegistry.RegisterTransmitPipeHandler <XmlElement>(e => sentStanza = e);

            await MessageSender.SendStatusUpdateAsync(expectedStatus, token);

            Assert.NotNull(sentStanza);
            Assert.Equal(expectedStatus.StatusText, sentStanza.Child("status").Value);
            Assert.Equal(expectedStatus.AvailabilitySubstate.ToString().ToLower(), sentStanza.Child("show").Value);
        }
Example #3
0
        public static Task SendStatusUpdateAsync(this IMessageSender messageSender, PresenceStatus presenceStatus, CancellationToken cancellationToken)
        {
            var stanza = CreateStatusUpdateStanza(presenceStatus);

            return(messageSender.SendToTransmitPipeAsync(stanza, cancellationToken));
        }