Пример #1
0
 public static bool IsSynthesized(this PresenceMessage msg)
 {
     return(!msg.Id.StartsWith(msg.ConnectionId));
 }
Пример #2
0
 public ProtocolMessage()
 {
     Messages = new Message[] { };
     Presence = new PresenceMessage[] { };
 }
Пример #3
0
        private bool onChangeNickMessage(MessageResponseHelper <PresenceMessage> helper, PresenceMessage msg)
        {
            if (msg is MUCMemberPresenceMessage)
            {
                // Success:
                MUCMemberPresenceMessage mPMessage = msg as MUCMemberPresenceMessage;
                if (mPMessage.STATUS_CODES.Contains(MUCPresenceStatusCode.PRESENCE_SELFE_REFERENCE) && (mPMessage.STATUS_CODES.Contains(MUCPresenceStatusCode.MEMBER_NICK_CHANGED) || mPMessage.STATUS_CODES.Contains(MUCPresenceStatusCode.ROOM_NICK_CHANGED)))
                {
                    Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        MUCInfo.nickname      = mPMessage.NICKNAME;
                        MUCChatInfoTable info = MUCInfo;
                        Task.Run(() => MUCDBManager.INSTANCE.setMUCChatInfo(info, false, false));

                        nickname_stbx.Text = mPMessage.NICKNAME;
                        nickname_stbx.onSavingDone();
                        notificationBanner_ian.Show("Successfully changed nickname to: " + mPMessage.NICKNAME, 5000);
                    }).AsTask();
                    return(true);
                }
            }
            // Error:
            else if (msg is MUCErrorMessage && Equals(msg.ID, changeNickHelper.sendId))
            {
                MUCErrorMessage errorMessage = msg as MUCErrorMessage;
                Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    nickname_stbx.Text = MUCInfo.nickname;
                    nickname_stbx.onSavingDone();
                    notificationBanner_ian.Show("Changing nickname failed:\nCode: " + errorMessage.ERROR_CODE + "\nType: " + errorMessage.ERROR_TYPE + "\nMessage:\n" + errorMessage.ERROR_MESSAGE);
                }).AsTask();
            }
            return(false);
        }
Пример #4
0
 private void Client_OnPresenceUpdate(object sender, PresenceMessage args)
 {
     LogWriter.WriteToFile($"[RpcMessage] | Presence state: {args.Presence.State}");
 }
Пример #5
0
 private static void OnPresenceUpdate(object sender, PresenceMessage args)
 {
     //This is called when the Rich Presence has been updated in the discord client.
     // Use this to keep track of the rich presence and validate that it has been sent correctly.
     Console.WriteLine("Rich Presence Updated. Playing {0}", args.Presence == null ? "Nothing (NULL)" : args.Presence.State);
 }
Пример #6
0
 public QueuedPresenceMessage(PresenceMessage message, Action <bool, ErrorInfo> callback)
 {
     Message  = message;
     Callback = callback;
 }
Пример #7
0
            public async Task PresenceMap_WhenSyncingLeaveStoredAsAbsentAndDeleted(Protocol protocol)
            {
                Logger.LogLevel = LogLevel.Debug;

                var channelName = "presence_map_tests_newness".AddRandomSuffix();

                var client = await GetRealtimeClient(protocol);

                await client.WaitForState(ConnectionState.Connected);

                client.Connection.State.ShouldBeEquivalentTo(ConnectionState.Connected);

                var channel = client.Channels.Get(channelName);

                channel.Attach();
                await channel.WaitForState(ChannelState.Attached);

                channel.State.ShouldBeEquivalentTo(ChannelState.Attached);


                #region test data

                PresenceMessage[] TestPresence1()
                {
                    return(new PresenceMessage[]
                    {
                        new PresenceMessage
                        {
                            Action = PresenceAction.Enter,
                            ClientId = "1",
                            ConnectionId = "1",
                            Id = "1:0",
                            Data = string.Empty
                        },
                    });
                }

                PresenceMessage[] TestPresence2()
                {
                    return(new PresenceMessage[]
                    {
                        new PresenceMessage
                        {
                            Action = PresenceAction.Enter,
                            ClientId = "2",
                            ConnectionId = "2",
                            Id = "2:1:0",
                            Data = string.Empty
                        },
                        new PresenceMessage
                        {
                            Action = PresenceAction.Enter,
                            ClientId = "3",
                            ConnectionId = "3",
                            Id = "3:1:0",
                            Data = string.Empty
                        },
                    });
                }

                PresenceMessage[] TestPresence3()
                {
                    return(new PresenceMessage[]
                    {
                        new PresenceMessage
                        {
                            Action = PresenceAction.Leave,
                            ClientId = "3",
                            ConnectionId = "3",
                            Id = "3:0:0",
                            Data = string.Empty
                        },
                        new PresenceMessage
                        {
                            Action = PresenceAction.Enter,
                            ClientId = "4",
                            ConnectionId = "4",
                            Id = "4:1:1",
                            Data = string.Empty
                        },
                        new PresenceMessage
                        {
                            Action = PresenceAction.Leave,
                            ClientId = "4",
                            ConnectionId = "4",
                            Id = "4:2:2",
                            Data = string.Empty
                        },
                    });
                }

                #endregion

                bool seenLeaveMessageAsAbsentForClient4    = false;
                List <PresenceMessage> presenceMessagesLog = new List <PresenceMessage>();
                channel.Presence.Subscribe(message =>
                {
                    // keep track of the all presence messages we receive
                    presenceMessagesLog.Add(message);
                });

                channel.Presence.Subscribe(PresenceAction.Leave, async message =>
                {
                    /*
                     * Do not call it in states other than ATTACHED because of presence.get() side
                     * effect of attaching channel
                     */
                    if (message.ClientId == "4" && message.Action == PresenceAction.Leave && channel.State == ChannelState.Attached)
                    {
                        /*
                         * Client library won't return a presence message if it is stored as ABSENT
                         * so the result of the presence.get() call should be empty.
                         */
                        var result = await channel.Presence.GetAsync("4");
                        seenLeaveMessageAsAbsentForClient4 = result.ToArray().Length == 0;
                    }
                });

                await client.Connection.ConnectionManager.OnTransportMessageReceived(new ProtocolMessage()
                {
                    Action        = Types.ProtocolMessage.MessageAction.Sync,
                    Channel       = channelName,
                    ChannelSerial = "1:1",
                    Presence      = TestPresence1()
                });

                await client.Connection.ConnectionManager.OnTransportMessageReceived(new ProtocolMessage()
                {
                    Action        = Types.ProtocolMessage.MessageAction.Sync,
                    Channel       = channelName,
                    ChannelSerial = "2:1",
                    Presence      = TestPresence2()
                });

                await client.Connection.ConnectionManager.OnTransportMessageReceived(new ProtocolMessage()
                {
                    Action        = Types.ProtocolMessage.MessageAction.Sync,
                    Channel       = channelName,
                    ChannelSerial = "2:",
                    Presence      = TestPresence3()
                });

                var presence1 = await channel.Presence.GetAsync("1");

                var presence2 = await channel.Presence.GetAsync("2");

                var presence3 = await channel.Presence.GetAsync("3");

                var presenceOthers = await channel.Presence.GetAsync();

                presence1.ToArray().Length.ShouldBeEquivalentTo(0, "incomplete sync should be discarded");
                presence2.ToArray().Length.ShouldBeEquivalentTo(1, "client with id==2 should be in presence map");
                presence3.ToArray().Length.ShouldBeEquivalentTo(1, "client with id==3 should be in presence map");
                presenceOthers.ToArray().Length.ShouldBeEquivalentTo(2, "presence map should be empty");

                seenLeaveMessageAsAbsentForClient4.ShouldBeEquivalentTo(true, "LEAVE message for client with id==4 was not stored as ABSENT");

                PresenceMessage[] correctPresenceHistory = new PresenceMessage[] {
                    /* client 1 enters (will later be discarded) */
                    new PresenceMessage(PresenceAction.Enter, "1"),
                    /* client 2 enters */
                    new PresenceMessage(PresenceAction.Enter, "2"),
                    /* client 3 enters and never leaves because of newness comparison for LEAVE fails */
                    new PresenceMessage(PresenceAction.Enter, "3"),
                    /* client 4 enters and leaves */
                    new PresenceMessage(PresenceAction.Enter, "4"),
                    new PresenceMessage(PresenceAction.Leave, "4"), /* geting dupe */
                    /* client 1 is eliminated from the presence map because the first portion of SYNC is discarded */
                    new PresenceMessage(PresenceAction.Leave, "1")
                };

                presenceMessagesLog.Count.ShouldBeEquivalentTo(correctPresenceHistory.Length);

                for (int i = 0; i < correctPresenceHistory.Length; i++)
                {
                    PresenceMessage factualMsg = presenceMessagesLog[i];
                    PresenceMessage correctMsg = correctPresenceHistory[i];
                    factualMsg.ClientId.ShouldBeEquivalentTo(correctMsg.ClientId);
                    factualMsg.Action.ShouldBeEquivalentTo(correctMsg.Action);
                }
            }
Пример #8
0
        /// <summary>
        /// Sends a <seealso cref="PresenceMessage"/> to answer an presence subscription request from the given bare JID.
        /// </summary>
        /// <param name="bareJid">The bare JID of the target e.g. '*****@*****.**'.</param>
        /// <param name="accept">Whether the request was accepted or not.</param>
        public Task answerPresenceSubscriptionRequestAsync(string bareJid, bool accept)
        {
            PresenceMessage msg = new PresenceMessage(CONNECTION.account.getBareJid(), bareJid, accept ? "subscribed" : "unsubscribed");

            return(CONNECTION.SendAsync(msg, true));
        }
Пример #9
0
 private static void OnPresenceUpdate(object sender, PresenceMessage args)
 {
     RichPresenceHelper.Log(args.Type, args.TimeCreated,
                            string.Format("Now playing {0}.", args.Presence == null ? "nothing" : args.Presence.State));
 }
Пример #10
0
            public async Task PresenceMapBehaviour_ShouldConformToSpec(Protocol protocol)
            {
                Logger.LogLevel = LogLevel.Debug;

                var channelName = "presence_map_tests_newness".AddRandomSuffix();

                var client = await GetRealtimeClient(protocol);

                await client.WaitForState(ConnectionState.Connected);

                client.Connection.State.ShouldBeEquivalentTo(ConnectionState.Connected);

                var channel = client.Channels.Get(channelName);

                channel.Attach();
                await channel.WaitForState(ChannelState.Attached);

                channel.State.ShouldBeEquivalentTo(ChannelState.Attached);

                const string wontPass = "******";

                List <PresenceMessage> presenceMessages = new List <PresenceMessage>();

                channel.Presence.Subscribe(x =>
                {
                    x.Data.Should().NotBe(wontPass, "message did not pass the newness test");
                    presenceMessages.Add(x);
                });

                /* Test message newness criteria as described in RTP2b */
                PresenceMessage[] testData = new PresenceMessage[] {
                    new PresenceMessage
                    {
                        Action       = PresenceAction.Enter,
                        ClientId     = "1",
                        ConnectionId = "1",
                        Id           = "1:0",
                        Data         = string.Empty
                    },
                    new PresenceMessage
                    {
                        Action       = PresenceAction.Enter,
                        ClientId     = "2",
                        ConnectionId = "2",
                        Id           = "2:1:0",
                        Timestamp    = new DateTimeOffset(2000, 1, 1, 1, 1, 1, new TimeSpan()),
                        Data         = string.Empty
                    },
                    /* Should be newer than previous one */
                    new PresenceMessage
                    {
                        Action       = PresenceAction.Update,
                        ClientId     = "2",
                        ConnectionId = "2",
                        Id           = "2:2:1",
                        Timestamp    = new DateTimeOffset(2000, 1, 1, 1, 1, 2, new TimeSpan()),
                        Data         = string.Empty
                    },
                    /* Shouldn't pass newness test because of message serial, timestamp doesn't matter in this case */
                    new PresenceMessage
                    {
                        Action       = PresenceAction.Update,
                        ClientId     = "2",
                        ConnectionId = "2",
                        Id           = "2:1:1",
                        Timestamp    = new DateTimeOffset(2000, 1, 1, 1, 1, 3, new TimeSpan()),
                        Data         = wontPass
                    },
                    /* Shouldn't pass because of message index */
                    new PresenceMessage
                    {
                        Action       = PresenceAction.Update,
                        ClientId     = "2",
                        ConnectionId = "2",
                        Id           = "2:2:0",
                        Data         = wontPass
                    },
                    /* Should pass because id is not in form connId:clientId:index and timestamp is greater */
                    new PresenceMessage
                    {
                        Action       = PresenceAction.Update,
                        ClientId     = "2",
                        ConnectionId = "2",
                        Id           = "wrong_id",
                        Timestamp    = new DateTimeOffset(2000, 1, 1, 1, 1, 10, new TimeSpan()),
                        Data         = string.Empty
                    },
                    /* Shouldn't pass because of timestamp */
                    new PresenceMessage
                    {
                        Action       = PresenceAction.Update,
                        ClientId     = "2",
                        ConnectionId = "2",
                        Id           = "2:3:1",
                        Timestamp    = new DateTimeOffset(2000, 1, 1, 1, 1, 5, new TimeSpan()),
                        Data         = wontPass
                    }
                };

                foreach (var presenceMessage in testData)
                {
                    var protocolMessage = new ProtocolMessage(ProtocolMessage.MessageAction.Presence)
                    {
                        Channel  = channelName,
                        Presence = new PresenceMessage[] { presenceMessage }
                    };
                    await client.Connection.ConnectionManager.OnTransportMessageReceived(protocolMessage);
                }

                int n = 0;

                foreach (var testMsg in testData)
                {
                    if (testMsg.Data.ToString() == wontPass)
                    {
                        continue;
                    }
                    PresenceMessage factualMsg = n < presenceMessages.Count ? presenceMessages[n++] : null;
                    factualMsg.Should().NotBe(null);
                    factualMsg.Id.ShouldBeEquivalentTo(testMsg.Id);
                    factualMsg.Action.ShouldBeEquivalentTo(testMsg.Action, "message was not emitted on the presence object with original action");
                    var presentMessage = await channel.Presence.GetAsync(new GetOptions
                    {
                        ClientId = testMsg.ClientId, WaitForSync = false
                    });

                    presentMessage.FirstOrDefault().Should().NotBe(null);
                    presentMessage.FirstOrDefault()?.Action.ShouldBeEquivalentTo(PresenceAction.Present, "message was not added to the presence map and stored with PRESENT action");
                }

                presenceMessages.Count.ShouldBeEquivalentTo(n, "the number of messages received didn't match the number of test messages sent.");

                /* Repeat the process now as a part of SYNC and verify everything is exactly the same */
                var channel2Name = "presence_map_tests_sync_newness".AddRandomSuffix();

                var client2 = await GetRealtimeClient(protocol);

                await client2.WaitForState(ConnectionState.Connected);

                client2.Connection.State.ShouldBeEquivalentTo(ConnectionState.Connected);

                var channel2 = client2.Channels.Get(channel2Name);

                channel2.Attach();
                await channel2.WaitForState(ChannelState.Attached);

                channel2.State.ShouldBeEquivalentTo(ChannelState.Attached);

                /* Send all the presence data in one SYNC message without channelSerial (RTP18c) */
                ProtocolMessage syncMessage = new ProtocolMessage()
                {
                    Channel  = channel2Name,
                    Action   = ProtocolMessage.MessageAction.Sync,
                    Presence = testData
                };

                var counter = new TaskCountAwaiter(presenceMessages.Count, 5000);
                List <PresenceMessage> syncPresenceMessages = new List <PresenceMessage>();

                channel2.Presence.Subscribe(x =>
                {
                    x.Data.Should().NotBe(wontPass, "message did not pass the newness test");
                    syncPresenceMessages.Add(x);
                    counter.Tick();
                });

                await client2.Connection.ConnectionManager.OnTransportMessageReceived(syncMessage);

                await counter.Task;

                syncPresenceMessages.Count.ShouldBeEquivalentTo(presenceMessages.Count);

                for (int i = 0; i < syncPresenceMessages.Count; i++)
                {
                    syncPresenceMessages[i].Id.ShouldBeEquivalentTo(presenceMessages[i].Id, "result should be the same in case of SYNC");
                    syncPresenceMessages[i].Action.ShouldBeEquivalentTo(presenceMessages[i].Action, "result should be the same in case of SYNC");
                }
            }
Пример #11
0
        private static PresenceMessage DeserializePresenceMessage(Unpacker unpacker)
        {
            PresenceMessage message = new PresenceMessage();

            long fields;

            unpacker.ReadMapLength(out fields);
            string fieldName;

            for (int i = 0; i < fields; i++)
            {
                unpacker.ReadString(out fieldName);
                switch (fieldName)
                {
                case PresenceMessage.ActionPropertyName:
                {
                    int result;
                    unpacker.ReadInt32(out result);
                    message.Action = (PresenceMessage.ActionType)result;
                }
                break;

                case PresenceMessage.IdPropertyName:
                {
                    string result;
                    unpacker.ReadString(out result);
                    message.Id = result;
                }
                break;

                case PresenceMessage.ClientIdPropertyName:
                {
                    string result;
                    unpacker.ReadString(out result);
                    message.ClientId = result;
                }
                break;

                case PresenceMessage.ConnectionIdPropertyName:
                {
                    string result;
                    unpacker.ReadString(out result);
                    message.ConnectionId = result;
                }
                break;

                case PresenceMessage.TimestampPropertyName:
                {
                    long result;
                    unpacker.ReadInt64(out result);
                    message.Timestamp = result.FromUnixTimeInMilliseconds();
                }
                break;

                case PresenceMessage.DataPropertyName:
                {
                    MessagePackObject result = unpacker.ReadItemData();
                    message.Data = ParseResult(result);
                }
                break;
                }
            }

            return(message);
        }
Пример #12
0
        public RPCPreview(PresenceMessage msg)
        {
            InitializeComponent();

            CurrentViewType = ViewType.RichPresence;
            UpdateBackground("Purple");
            UpdateForeground(Brushes.White);
            tblTitle.Text = msg.Name;
            tblText1.Text = msg.Presence.Details;
            tblText2.Text = msg.Presence.State;
            UpdateTextVisibility();
            tblTime.Visibility = Visibility.Visible;

            if (msg.Presence.HasAssets())
            {
                recLargeImage.Visibility = Visibility.Collapsed;
                if (!string.IsNullOrEmpty(msg.Presence.Assets.LargeImageKey))
                {
                    recLargeImage.Visibility = Visibility.Visible;
                    var largeImage = (new [] {
                        "https://cdn.discordapp.com/app-assets",
                        msg.ApplicationID,
                        msg.Presence.Assets.LargeImageID + ".png"
                    }.CombineToUri()).DownloadImage()
                                     .ConfigureAwait(false).GetAwaiter().GetResult();

                    recLargeImage.Fill = new ImageBrush(largeImage);
                    if (!string.IsNullOrEmpty(msg.Presence.Assets.LargeImageText))
                    {
                        recLargeImage.ToolTip = new ToolTip(msg.Presence.Assets.LargeImageText);
                    }
                }
                else
                {
                    recLargeImage.Fill = null;
                }

                if (!string.IsNullOrEmpty(msg.Presence.Assets.SmallImageKey) &&
                    recLargeImage.Visibility == Visibility.Visible)
                {
                    var smallImage = new [] {
                        "https://cdn.discordapp.com/app-assets",
                        msg.ApplicationID,
                        msg.Presence.Assets.SmallImageID + ".png"
                    }
                    .CombineToUri()
                    .DownloadImage()
                    .ConfigureAwait(false)
                    .GetAwaiter().GetResult();
                    ellSmallImage.Fill = new ImageBrush(smallImage);
                    if (!string.IsNullOrEmpty(msg.Presence.Assets.SmallImageText))
                    {
                        ellSmallImage.ToolTip = new ToolTip(msg.Presence.Assets.SmallImageText);
                    }
                }
                else
                {
                    gridSmallImage.Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                recLargeImage.Visibility  = Visibility.Collapsed;
                gridSmallImage.Visibility = Visibility.Collapsed;
            }
        }
Пример #13
0
 private static void OnPresenceUpdate(object sender, PresenceMessage args)
 {
     Console.WriteLine("Rich Presence Updated. Playing {0}", args.Presence == null ? "Nothing (NULL)" : args.Presence.State);
 }
Пример #14
0
        /// <summary>
        /// Sends a PresenceMessage to request a presence subscription from the given bare JID.
        /// </summary>
        /// <param name="bareJid">The bare JID of the target e.g. '*****@*****.**'.</param>
        public Task requestPresenceSubscriptionAsync(string bareJid)
        {
            PresenceMessage msg = new PresenceMessage(CONNECTION.account.getBareJid(), bareJid, "subscribe");

            return(CONNECTION.SendAsync(msg, true));
        }
Пример #15
0
            public void PresenceMessage_IsNewerThan_RaisesExceptionWithMalformedIdStrings()
            {
                // Set the first portion of the Id to match the connection id
                // This is so the message does not appear synthesised
                var p1 = new PresenceMessage(PresenceAction.Present, "client1");

                p1.Id           = "abcdef:1:1";
                p1.ConnectionId = "abcdef";
                p1.Timestamp    = new DateTimeOffset(2000, 1, 1, 1, 1, 1, 1, TimeSpan.Zero);
                var p2 = new PresenceMessage(PresenceAction.Present, "client2");

                // make the timestamps the same so we can get to the parsing part of the code
                p2.Timestamp    = p1.Timestamp;
                p2.Id           = "abcdef:this_should:error";
                p2.ConnectionId = "abcdef";

                bool exHandled = false;

                try
                {
                    p1.IsNewerThan(p2);
                }
                catch (Exception e)
                {
                    e.Should().BeOfType <AblyException>();
                    e.Message.Should().Contain("this_should:error");
                    exHandled = true;
                }
                exHandled.Should().BeTrue();
                exHandled = false;

                try
                {
                    p2.IsNewerThan(p1);
                }
                catch (Exception e)
                {
                    e.Should().BeOfType <AblyException>();
                    e.Message.Should().Contain("this_should:error");
                    exHandled = true;
                }
                exHandled.Should().BeTrue();
                exHandled = false;

                // test not enough sections
                p2.Id = "abcdef:2";
                try
                {
                    p1.IsNewerThan(p2);
                }
                catch (Exception e)
                {
                    e.Should().BeOfType <AblyException>();
                    e.Message.Should().Contain("abcdef:2");
                    exHandled = true;
                }
                exHandled.Should().BeTrue();
                exHandled = false;

                try
                {
                    p2.IsNewerThan(p1);
                }
                catch (Exception e)
                {
                    e.Should().BeOfType <AblyException>();
                    e.Message.Should().Contain("abcdef:2");
                    exHandled = true;
                }
                exHandled.Should().BeTrue();
                exHandled = false;

                // correctly formatted Ids should not throw an exception
                p2.Id = p1.Id;
                try
                {
                    p2.IsNewerThan(p1);
                }
                catch (Exception e)
                {
                    exHandled = true;
                }
                exHandled.Should().BeFalse();
                exHandled = false;
            }
Пример #16
0
        /// <summary>
        /// Sends a <seealso cref="PresenceMessage"/> to unsubscribe form the given bare JID.
        /// </summary>
        /// <param name="bareJid">The bare JID of the target e.g. '*****@*****.**'.</param>
        public Task unsubscribeFromPresenceAsync(string bareJid)
        {
            PresenceMessage msg = new PresenceMessage(CONNECTION.account.getBareJid(), bareJid, "unsubscribe");

            return(CONNECTION.SendAsync(msg, true));
        }
Пример #17
0
 private void OnPresenceUpdate(object sender, PresenceMessage args)
 {
     Logger.Log($"Discord: Rich Presence Updated. State: {args.Presence?.State}; Details: {args.Presence?.Details}");
 }
Пример #18
0
        private async Task AnswerPresenceProbeAsync(string from, string to, ChatTable chat, PresenceMessage msg)
        {
            XMPPAccount     account = client.getXMPPAccount();
            PresenceMessage answer;

            if (chat is null)
            {
                Logger.Warn("Received a presence probe message for an unknown chat from: " + from + ", to: " + to);
                return;
            }
            else
            {
                switch (chat.subscription)
                {
                case "both":
                case "from":
                    answer = new PresenceMessage(account.getBareJid(), from, account.presence, account.status, account.presencePriorety);
                    Logger.Debug("Answered presence probe from: " + from);
                    break;

                case "none" when chat.inRoster:
                case "to" when chat.inRoster:
                    answer = new PresenceErrorMessage(account.getFullJid(), from, PresenceErrorType.FORBIDDEN);
                    Logger.Warn("Received a presence probe but chat has no subscription: " + from + ", to: " + to + " subscription: " + chat.subscription);
                    break;

                default:
                    answer = new PresenceErrorMessage(account.getFullJid(), from, PresenceErrorType.NOT_AUTHORIZED);
                    Logger.Warn("Received a presence probe but chat has no subscription: " + from + ", to: " + to + " subscription: " + chat.subscription);
                    break;
                }
            }
            await client.SendAsync(answer);
        }
Пример #19
0
 //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
 #region --Constructors--
 /// <summary>
 /// Basic Constructor
 /// </summary>
 /// <history>
 /// 21/08/2017 Created [Fabian Sauter]
 /// </history>
 public NewPresenceMessageEventArgs(PresenceMessage msg)
 {
     PRESENCE_MESSAGE = msg;
 }
Пример #20
0
 void XMPPClient_OnUserSubscriptionRequest(PresenceMessage pres)
 {
     Dispatcher.BeginInvoke(new System.Net.XMPP.XMPPClient.DelegateShouldSubscribeUser(DoOnUserSubscriptionRequest), pres);
 }
Пример #21
0
 void Presence_MessageReceived(PresenceMessage message)
 {
     outputBox.Items.Add(string.Format("{0}: {1} {2}", message.Data, message.Action, message.ClientId));
 }
Пример #22
0
 private static void Presence_MessageReceived2(PresenceMessage obj)
 {
     Console.WriteLine(obj.ConnectionId + "\t" + obj.Timestamp);
 }
Пример #23
0
 private static void OnPresenceUpdate(object sender, PresenceMessage args)
 {
     //This is called when the Rich Presence has been updated in the discord client.
     // Use this to keep track of the rich presence and validate that it has been sent correctly.
     Console.WriteLine("Changes detected, Presence updated");
 }