### XML-RPC Fault Response Example Source: https://github.com/agnauck/xmppdotnet/blob/master/src/XmppDotNet.Core/Xmpp/Rpc/XML-RPC.htm Demonstrates the structure of an XML-RPC fault response, typically returned when a method call fails. It includes a faultCode and a faultString. ```xml faultCode 23 faultString Unknown stock symbol ABCD ``` -------------------------------- ### XML-RPC Response with Array Source: https://github.com/agnauck/xmppdotnet/blob/master/src/XmppDotNet.Core/Xmpp/Rpc/XML-RPC.htm An example of an XML-RPC response document that returns an array of double values, representing prices. ```xml 4.12 13.68 1.93 0.78 ``` -------------------------------- ### XML-RPC Struct Example Source: https://github.com/agnauck/xmppdotnet/blob/master/src/XmppDotNet.Core/Xmpp/Rpc/XML-RPC.htm Represents an XML-RPC struct with two members: 'symbol' (string) and 'limit' (double). ```xml symbol RHAT limit 2.25 ``` -------------------------------- ### XML-RPC Request with Struct Argument Source: https://github.com/agnauck/xmppdotnet/blob/master/src/XmppDotNet.Core/Xmpp/Rpc/XML-RPC.htm An example of an XML-RPC method call ('bid') that passes a struct as an argument, representing a limit order with symbol, limit price, and expiration date. ```xml bid symbol RHAT limit 2.25 expires 20020709T20:00:00 ``` -------------------------------- ### XML-RPC Request with Array Argument Source: https://github.com/agnauck/xmppdotnet/blob/master/src/XmppDotNet.Core/Xmpp/Rpc/XML-RPC.htm An example of an XML-RPC method call that passes an array of strings as an argument to the 'getQuote' method. ```xml getQuote RHAT SUNW ASKJ COVD ``` -------------------------------- ### Define a Java method signature Source: https://github.com/agnauck/xmppdotnet/blob/master/src/XmppDotNet.Core/Xmpp/Rpc/XML-RPC.htm Represents the Java method signature for a remote procedure call example. ```java public static double getQuote(String symbol); ``` -------------------------------- ### Send Chat Messages Source: https://context7.com/agnauck/xmppdotnet/llms.txt Provides examples of sending various types of chat messages using extension methods. Includes sending simple messages, messages with auto-generated IDs for tracking, messages with thread IDs for conversation context, fully customized messages, and group chat messages to MUC rooms. ```csharp using XmppDotNet; using XmppDotNet.Extensions.Client.Message; using XmppDotNet.Xmpp; using XmppDotNet.Xmpp.Client; // Send a simple chat message await xmppClient.SendChatMessageAsync( new Jid("friend@server.com"), "Hello, how are you?" ); // Send chat message with auto-generated ID (for message tracking) await xmppClient.SendChatMessageAsync( new Jid("friend@server.com"), "Important message", autoGenerateMessageId: true ); // Send chat message with thread ID for conversation tracking await xmppClient.SendChatMessageAsync( new Jid("friend@server.com"), "Continuing our conversation", thread: "conversation-123", autoGenerateMessageId: true ); // Send a fully customized message var message = new Message { Type = MessageType.Chat, To = "recipient@server.com", Body = "Message content", Subject = "Optional subject", Thread = "thread-id" }; message.Id = Id.GenerateShortGuid(); await xmppClient.SendMessageAsync(message); // Send group chat message to a MUC room await xmppClient.SendGroupChatMessageAsync( new Jid("room@conference.server.com"), "Hello everyone!" ); ``` -------------------------------- ### Create and Configure XMPP Client Source: https://context7.com/agnauck/xmppdotnet/llms.txt Demonstrates how to instantiate and configure an XmppClient using a fluent API. Includes options for transport, auto-reconnect, and stream management. Subscribe to connection state changes and initiate connection/disconnection. ```csharp using XmppDotNet; using XmppDotNet.Transport.Socket; using System.Reactive.Linq; // Create and configure an XMPP client var xmppClient = new XmppClient( conf => { conf.UseSocketTransport(); // Use TCP socket transport conf.AutoReconnect = true; // Enable automatic reconnection conf.UseStreamManagement(); // Enable XEP-0198 Stream Management }) { Jid = "user@xmpp-server.com", Password = "secretpassword", Resource = "MyApp" // Optional: server usually assigns this }; // Subscribe to connection state changes xmppClient.StateChanged.Subscribe(state => { Console.WriteLine($"Connection state: {state}"); // States: Disconnected, Connected, Securing, Secure, // Authenticating, Authenticated, Binding, Binded }); // Connect to the server await xmppClient.ConnectAsync(); // Disconnect when done await xmppClient.DisconnectAsync(); ``` -------------------------------- ### Implement PubSub Messaging in C# Source: https://context7.com/agnauck/xmppdotnet/llms.txt Manages nodes, subscriptions, and item publication using XEP-0060. ```csharp using XmppDotNet; using XmppDotNet.Extensions.Client.PubSub; using XmppDotNet.Xmpp.PubSub; using XmppDotNet.Xml; Jid pubsubService = "pubsub.server.com"; // Create a new PubSub node await xmppClient.CreateNodeAsync(pubsubService, "mynode"); // Create instant node (server assigns node ID) var createResult = await xmppClient.CreateInstantNodeAsync(pubsubService); // Subscribe to a node await xmppClient.SubscribeAsync( pubsubService, "news", xmppClient.Jid // Subscribe with your JID ); // Publish an item to a node var item = new Item { Id = "item-1" }; item.Add(new XmppXElement("custom", "http://example.org", "data")); await xmppClient.PublishItemAsync(pubsubService, "mynode", item); // Publish multiple items var items = new[] { new Item { Id = "item-1" }, new Item { Id = "item-2" } }; await xmppClient.PublishItemsAsync(pubsubService, "mynode", items); // Request all items from a node var allItems = await xmppClient.RequestAllItemsAsync(pubsubService, "mynode"); // Request a specific item var specificItem = await xmppClient.RequestItemAsync(pubsubService, "mynode", "item-1"); // Retract (delete) an item await xmppClient.RetractItemAsync(pubsubService, "mynode", "item-1"); // Unsubscribe from a node await xmppClient.UnsubscribeAsync(pubsubService, "mynode", xmppClient.Jid); // Delete a node await xmppClient.DeleteNodeAsync(pubsubService, "mynode"); // Purge all items from a node await xmppClient.PurgeNodeAsync(pubsubService, "mynode"); // Request node configuration var configResult = await xmppClient.RequestNodeConfigurationAsync(pubsubService, "mynode"); ``` -------------------------------- ### Perform Service Discovery in C# Source: https://context7.com/agnauck/xmppdotnet/llms.txt Queries XMPP entities for items, features, and identities using XEP-0030. ```csharp using XmppDotNet; using XmppDotNet.Extensions.Client.Disco; using XmppDotNet.Xmpp.Disco; // Discover items available at server var itemsIq = await xmppClient.DiscoverItemsAsync(new Jid("server.com")); var items = itemsIq.Query as Items; foreach (var item in items.GetItems()) { Console.WriteLine($"Item: {item.Jid} - {item.Name}"); } // Discover items at a specific node var nodeItems = await xmppClient.DiscoverItemsAsync( new Jid("pubsub.server.com"), node: "music" ); // Discover information about an entity (features, identities) var infoIq = await xmppClient.DiscoverInformationAsync(new Jid("server.com")); var info = infoIq.Query as Info; // List features supported by the entity foreach (var feature in info.GetFeatures()) { Console.WriteLine($"Supported feature: {feature.Var}"); } // List identities (what the entity is) foreach (var identity in info.GetIdentities()) { Console.WriteLine($"Identity: {identity.Category}/{identity.Type} - {identity.Name}"); } // Discover with custom timeout var result = await xmppClient.DiscoverInformationAsync( new Jid("conference.server.com"), timeout: 10000 ); ``` -------------------------------- ### Manage Multi-User Chat Rooms in C# Source: https://context7.com/agnauck/xmppdotnet/llms.txt Use MucManager to join, configure, and interact with group chat rooms. Requires an initialized XmppClient instance. ```csharp using XmppDotNet; using XmppDotNet.Xmpp; using XmppDotNet.Xmpp.Client; using XmppDotNet.Xmpp.Muc; // Create a MUC manager helper var mucManager = new MucManager(xmppClient); // Enter a chat room Jid roomJid = "myroom@conference.server.com"; string nickname = "MyNickname"; var enterResult = await mucManager.EnterRoomAsync(roomJid, nickname); // Create room presence with password (for password-protected rooms) var enterPres = mucManager.CreateEnterRoomStanza( roomJid, nickname, password: "roompassword" ); await xmppClient.SendAsync(enterPres); // Create room presence with history options var historyPres = mucManager.CreateEnterRoomStanza( roomJid, nickname, disableHistory: true // Don't receive room history ); // Send message to room await xmppClient.SendGroupChatMessageAsync(roomJid, "Hello everyone!"); // Request room configuration (owner only) var configIq = await mucManager.RequestRoomConfigurationAsync(roomJid); // Submit room configuration var xdata = new XmppDotNet.Xmpp.XData.Data(); // ... configure xdata fields await mucManager.SubmitRoomConfigurationAsync(roomJid, xdata); // Exit the room await mucManager.ExitRoomAsync(roomJid, nickname); ``` -------------------------------- ### Configure XMPP Transports in C# Source: https://context7.com/agnauck/xmppdotnet/llms.txt Set up socket or WebSocket transport layers with custom certificate validation and URI resolution. ```csharp using XmppDotNet; using XmppDotNet.Transport.Socket; using XmppDotNet.Transport.WebSocket; // Socket transport with default settings var socketClient = new XmppClient(conf => { conf.UseSocketTransport(); }); // Socket transport with custom certificate validator var secureClient = new XmppClient(conf => { conf.UseSocketTransport(new DefaultCertificateValidator()); }); // Socket transport accepting all certificates (development only!) var devClient = new XmppClient(conf => { conf.UseSocketTransport(new AlwaysAcceptCertificateValidator()); }); // Socket transport with custom resolver var customResolverClient = new XmppClient(conf => { conf.UseSocketTransport() .WithResolver(new SocketUriResolver()) .WithCertificateValidator(new DefaultCertificateValidator()); }); // WebSocket transport for browser-compatible connections var webSocketClient = new XmppClient(conf => { conf.UseWebSocketTransport(); }) { Jid = "user@server.com", Password = "password" }; // WebSocket with custom resolver var customWsClient = new XmppClient(conf => { conf.UseWebSocketTransport(new WebSocketUriResolver()); }); ``` -------------------------------- ### Manage Presence Subscriptions in C# Source: https://context7.com/agnauck/xmppdotnet/llms.txt Handles adding contacts, approving or denying subscription requests, and managing unsubscriptions. ```csharp using XmppDotNet; using XmppDotNet.Extensions.Client.Subscription; // Subscribe to a user's presence (request to add as contact) await xmppClient.SubscribeAsync(new Jid("newuser@server.com")); // Subscribe with optional message and nickname await xmppClient.SubscribeAsync( new Jid("alice@server.com"), message: "Hi, I'd like to add you as a contact", nickname: "MyNickname" ); // Approve an incoming subscription request await xmppClient.ApproveSubscriptionRequestAsync(new Jid("requester@server.com")); // Deny an incoming subscription request await xmppClient.DenySubscriptionRequestAsync(new Jid("spammer@server.com")); // Unsubscribe from a user's presence await xmppClient.UnsubscribeAsync(new Jid("formercontact@server.com")); // Cancel a subscription you previously granted to someone await xmppClient.CancelSubscriptionAsync(new Jid("blocked@server.com")); ``` -------------------------------- ### Integrate with Foundation Source: https://github.com/agnauck/xmppdotnet/blob/master/examples/BlazorClient/wwwroot/css/open-iconic/README.md Include the Foundation stylesheet and use the span element to render icons. ```html ``` ```html ``` -------------------------------- ### Integrate with Bootstrap Source: https://github.com/agnauck/xmppdotnet/blob/master/examples/BlazorClient/wwwroot/css/open-iconic/README.md Include the Bootstrap stylesheet and use the span element to render icons. ```html ``` ```html ``` -------------------------------- ### Monitor XMPP Session State Changes Source: https://context7.com/agnauck/xmppdotnet/llms.txt This snippet demonstrates how to initialize an XmppClient with socket transport, auto-reconnect, and stream management. It subscribes to session state changes to send initial presence, request the roster upon binding, and log disconnection events. Ensure XMPP server details and credentials are correctly configured. ```csharp using XmppDotNet; using System.Reactive.Linq; var xmppClient = new XmppClient(conf => { conf.UseSocketTransport(); conf.UseAutoReconnect(); // Auto-reconnect on disconnect conf.UseStreamManagement(); // XEP-0198 for reliability }) { Jid = "user@server.com", Password = "password" }; // React to specific session states xmppClient.StateChanged .Where(s => s == SessionState.Binded) .Subscribe(async _ => { Console.WriteLine("Session ready - sending initial presence"); await xmppClient.SendPresenceAsync(Show.Chat, "Online"); // Request roster after successful bind var roster = await xmppClient.RequestRosterAsync(); Console.WriteLine("Roster loaded"); }); xmppClient.StateChanged .Where(s => s == SessionState.Disconnected) .Subscribe(_ => { Console.WriteLine("Disconnected from server"); }); xmppClient.StateChanged .Where(s => s == SessionState.Authenticated) .Subscribe(_ => { Console.WriteLine("Authentication successful"); }); // Available states: // Disconnected, Connected, Securing, Secure, // Registering, Registered, Authenticating, Authenticated, // ResumeFailed, Compressing, Compressed, // Binding, Binded, Resuming, Resumed, Disconnecting await xmppClient.ConnectAsync(); ``` -------------------------------- ### SendPresenceAsync - Presence Management Source: https://context7.com/agnauck/xmppdotnet/llms.txt Presence extensions allow broadcasting availability status including show state, status message, and priority to contacts. ```APIDOC ## SendPresenceAsync - Presence Management ### Description Presence extensions allow broadcasting availability status including show state, status message, and priority to contacts. ### Method POST ### Endpoint N/A (Client-side method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (Parameters are passed directly to the method) ### Request Example ```csharp // Send initial presence (become available online) await xmppClient.SendPresenceAsync(); // Send presence with show state await xmppClient.SendPresenceAsync(Show.Chat); // Available for chat // Send presence with status message await xmppClient.SendPresenceAsync(Show.Away, "Be right back"); // Send presence with priority (higher priority = preferred resource) await xmppClient.SendPresenceAsync(Show.Chat, "Working", priority: 10); // Send custom presence stanza var presence = new Presence { Show = Show.Dnd, // Do Not Disturb Status = "In a meeting", Priority = 5 }; await xmppClient.SendPresenceAsync(presence); // Show values: None, Away, Chat, Dnd (Do Not Disturb), Xa (Extended Away) ``` ### Response #### Success Response (200) Presence stanza sent successfully. #### Response Example N/A (Asynchronous operation, no direct response body) ### Error Handling Exceptions may be thrown for network issues or invalid presence configurations. ``` -------------------------------- ### Manage Presence with SendPresenceAsync Source: https://context7.com/agnauck/xmppdotnet/llms.txt Broadcasts availability status, custom messages, and priority levels to contacts. ```csharp using XmppDotNet; using XmppDotNet.Extensions.Client.Presence; using XmppDotNet.Xmpp; using XmppDotNet.Xmpp.Client; // Send initial presence (become available online) await xmppClient.SendPresenceAsync(); // Send presence with show state await xmppClient.SendPresenceAsync(Show.Chat); // Available for chat // Send presence with status message await xmppClient.SendPresenceAsync(Show.Away, "Be right back"); // Send presence with priority (higher priority = preferred resource) await xmppClient.SendPresenceAsync(Show.Chat, "Working", priority: 10); // Send custom presence stanza var presence = new Presence { Show = Show.Dnd, // Do Not Disturb Status = "In a meeting", Priority = 5 }; await xmppClient.SendPresenceAsync(presence); // Show values: None, Away, Chat, Dnd (Do Not Disturb), Xa (Extended Away) ``` -------------------------------- ### Send IQ Requests in C# Source: https://context7.com/agnauck/xmppdotnet/llms.txt Perform request-response operations using SendIqAsync. Supports custom timeouts and cancellation tokens. ```csharp using XmppDotNet; using XmppDotNet.Xmpp; using XmppDotNet.Xmpp.Client; using XmppDotNet.Xmpp.Last; using XmppDotNet.Xmpp.Version; using System.Threading; // Send a custom IQ request var iq = new Iq { Type = IqType.Get, To = "user@server.com" }; iq.GenerateId(); // Add query payload iq.Query = new LastQuery(); var response = await xmppClient.SendIqAsync(iq); if (response.Type == IqType.Result) { var lastActivity = response.Query as LastQuery; Console.WriteLine($"Last activity: {lastActivity?.Seconds} seconds ago"); } else if (response.Type == IqType.Error) { Console.WriteLine($"Error: {response.Error}"); } // Send IQ with custom timeout var result = await xmppClient.SendIqAsync(iq, timeout: 30000); // Send IQ with cancellation support var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10)); var resultWithCancel = await xmppClient.SendIqAsync(iq, cts.Token); // IQ Types: Get, Set, Result, Error ``` -------------------------------- ### Use default icon font Source: https://github.com/agnauck/xmppdotnet/blob/master/examples/BlazorClient/wwwroot/css/open-iconic/README.md Include the default stylesheet and use the data-glyph attribute to specify the icon. ```html ``` ```html ``` -------------------------------- ### Handle Incoming Stanzas with XmppXElementReceived Source: https://context7.com/agnauck/xmppdotnet/llms.txt Uses Reactive Extensions to filter and subscribe to specific XMPP stanza types like Message, Presence, and IQ. ```csharp using XmppDotNet; using XmppDotNet.Xmpp.Base; using XmppDotNet.Xmpp.Client; using System.Reactive.Linq; // Subscribe to all incoming messages xmppClient.XmppXElementReceived .Where(el => el is Message) .Subscribe(el => { var msg = (Message)el; Console.WriteLine($"From: {msg.From}"); Console.WriteLine($"Body: {msg.Body}"); Console.WriteLine($"Type: {msg.Type}"); }); // Subscribe to presence updates xmppClient.XmppXElementReceived .Where(el => el is Presence) .Subscribe(el => { var pres = (Presence)el; Console.WriteLine($"{pres.From} is {pres.Show}: {pres.Status}"); }); // Subscribe to IQ (Info/Query) stanzas xmppClient.XmppXElementReceived .Where(el => el is Iq) .Subscribe(el => { var iq = (Iq)el; if (iq.Type == IqType.Get || iq.Type == IqType.Set) { // Handle IQ requests Console.WriteLine($"IQ request from: {iq.From}"); } }); // Filter messages by sender xmppClient.XmppXElementReceived .Where(el => el is Message) .Cast() .Where(msg => msg.From.EqualsBare(new Jid("specific@user.com"))) .Subscribe(msg => Console.WriteLine($"Message from specific user: {msg.Body}")); ``` -------------------------------- ### XML-RPC Array with Mixed Types Source: https://github.com/agnauck/xmppdotnet/blob/master/src/XmppDotNet.Core/Xmpp/Rpc/XML-RPC.htm Demonstrates an XML-RPC array with elements of different types, including a string and two doubles. ```xml RHAT 4.12 4.25 ``` -------------------------------- ### Implement SVG sprite icons Source: https://github.com/agnauck/xmppdotnet/blob/master/examples/BlazorClient/wwwroot/css/open-iconic/README.md Use the SVG sprite method to load all icons in a single request. ```html ``` -------------------------------- ### XMPP Jabber ID Handling Source: https://context7.com/agnauck/xmppdotnet/llms.txt Illustrates the usage of the Jid class for parsing, manipulating, and comparing XMPP identifiers. Covers JID creation from strings and components, accessing JID parts, and JID escaping/unescaping according to XEP-0106. ```csharp using XmppDotNet; // Create JID from string Jid jid = new Jid("user@domain.com/resource"); // Access JID components string local = jid.Local; // "user" string domain = jid.Domain; // "domain.com" string resource = jid.Resource; // "resource" string bare = jid.Bare; // "user@domain.com" // Create JID from components (StringPrep applied automatically) var jid2 = new Jid("john.doe", "server.com", "mobile"); // Implicit conversion from string Jid jid3 = "alice@example.org"; // Compare JIDs bool isSameBare = jid.EqualsBare(jid2); // Compare bare JIDs only bool isSameFull = jid.Equals(jid2); // Compare full JIDs // JID escaping for special characters (XEP-0106) string escaped = Jid.EscapeNode("user@special"); // "user\40special" string unescaped = Jid.UnescapeNode("user\40special"); ``` -------------------------------- ### XML-RPC Array with Strings Source: https://github.com/agnauck/xmppdotnet/blob/master/src/XmppDotNet.Core/Xmpp/Rpc/XML-RPC.htm Represents an XML-RPC array containing four string elements, such as stock symbols. ```xml RHAT SUNW ASKJ COVD ``` -------------------------------- ### Construct an XML-RPC request document Source: https://github.com/agnauck/xmppdotnet/blob/master/src/XmppDotNet.Core/Xmpp/Rpc/XML-RPC.htm An XML document structure used to invoke a remote method with specific parameters. ```xml getQuote RHAT ``` -------------------------------- ### Display individual SVG icons Source: https://github.com/agnauck/xmppdotnet/blob/master/examples/BlazorClient/wwwroot/css/open-iconic/README.md Use standard image tags to display individual SVG files. ```html icon name ``` -------------------------------- ### Manage Roster with RequestRosterAsync Source: https://context7.com/agnauck/xmppdotnet/llms.txt Provides methods to retrieve, add, update, and remove contacts from the roster, supporting cancellation tokens and timeouts. ```csharp using XmppDotNet; using XmppDotNet.Extensions.Client.Roster; using XmppDotNet.Xmpp.Roster; using System.Threading; // Request the roster (contact list) from server var rosterIq = await xmppClient.RequestRosterAsync(); var roster = rosterIq.Query as Roster; foreach (var item in roster.GetRoster()) { Console.WriteLine($"Contact: {item.Jid}, Name: {item.Name}"); Console.WriteLine($" Subscription: {item.Subscription}"); Console.WriteLine($" Groups: {string.Join(", ", item.GetGroups())}"); } // Add a new contact to roster await xmppClient.AddRosterItemAsync(new Jid("newcontact@server.com")); // Add contact with nickname await xmppClient.AddRosterItemAsync( new Jid("john@server.com"), "John Doe" ); // Add contact with nickname and group await xmppClient.AddRosterItemAsync( new Jid("jane@server.com"), "Jane Smith", "Colleagues" ); // Add contact to multiple groups await xmppClient.AddRosterItemAsync( new Jid("bob@server.com"), "Bob Wilson", new[] { "Friends", "Gaming Buddies" } ); // Update existing roster item await xmppClient.UpdateRosterItemAsync( new Jid("john@server.com"), "Johnny", "Close Friends" ); // Remove contact from roster await xmppClient.RemoveRosterItemAsync(new Jid("oldcontact@server.com")); // Request roster with timeout and cancellation support var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var result = await xmppClient.RequestRosterAsync(timeout: 60000, cts.Token); ``` -------------------------------- ### POST an XML-RPC request via HTTP Source: https://github.com/agnauck/xmppdotnet/blob/master/src/XmppDotNet.Core/Xmpp/Rpc/XML-RPC.htm An HTTP POST request containing an XML-RPC payload, including necessary headers like Content-Type and Content-Length. ```http POST /quotes.cgi HTTP/1.0 Host: stocks.cafeconleche.org Content-Type: text/xml Content-length: 167 getQuote RHAT ``` -------------------------------- ### XML-RPC Response Structure Source: https://github.com/agnauck/xmppdotnet/blob/master/src/XmppDotNet.Core/Xmpp/Rpc/XML-RPC.htm The standard format for a successful XML-RPC response, including HTTP headers and the XML payload. ```xml HTTP/1.0 200 OK Date: Mon, 16 Jul 2001 20:12:37 GMT Server: Apache/1.3.12 (Unix) mod_perl/1.24 Last-Modified: Mon, 16 Jul 2001 20:12:37 GMT Content-Length: 140 Connection: close Content-Type: text/xml 4.12 ``` -------------------------------- ### XmppXElementReceived - Receive and Handle Incoming Stanzas Source: https://context7.com/agnauck/xmppdotnet/llms.txt The reactive `XmppXElementReceived` observable allows subscribing to incoming XMPP stanzas with filtering support using LINQ-style operators. ```APIDOC ## XmppXElementReceived - Receive and Handle Incoming Stanzas ### Description The reactive `XmppXElementReceived` observable allows subscribing to incoming XMPP stanzas with filtering support using LINQ-style operators. ### Method Observable Subscription ### Endpoint N/A (Client-side event) ### Parameters None ### Request Example ```csharp // Subscribe to all incoming messages xmppClient.XmppXElementReceived .Where(el => el is Message) .Subscribe(el => { var msg = (Message)el; Console.WriteLine($"From: {msg.From}"); Console.WriteLine($"Body: {msg.Body}"); Console.WriteLine($"Type: {msg.Type}"); }); // Subscribe to presence updates xmppClient.XmppXElementReceived .Where(el => el is Presence) .Subscribe(el => { var pres = (Presence)el; Console.WriteLine($"{pres.From} is {pres.Show}: {pres.Status}"); }); // Subscribe to IQ (Info/Query) stanzas xmppClient.XmppXElementReceived .Where(el => el is Iq) .Subscribe(el => { var iq = (Iq)el; if (iq.Type == IqType.Get || iq.Type == IqType.Set) { // Handle IQ requests Console.WriteLine($"IQ request from: {iq.From}"); } }); // Filter messages by sender xmppClient.XmppXElementReceived .Where(el => el is Message) .Cast() .Where(msg => msg.From.EqualsBare(new Jid("specific@user.com"))) .Subscribe(msg => Console.WriteLine($"Message from specific user: {msg.Body}")); ``` ### Response N/A (This is an observable for incoming data) ### Error Handling Standard observable error handling applies. ``` -------------------------------- ### XML Schema for XML-RPC Source: https://github.com/agnauck/xmppdotnet/blob/master/src/XmppDotNet.Core/Xmpp/Rpc/XML-RPC.htm Defines the structure and constraints for XML-RPC method calls and responses, including strict typing for parameters and fault handling. ```xml ``` -------------------------------- ### Register Service Worker in Blazor Source: https://github.com/agnauck/xmppdotnet/blob/master/examples/BlazorClient/wwwroot/index.html Registers the service-worker.js file to enable PWA features in the Blazor client. ```javascript navigator.serviceWorker.register('service-worker.js'); ``` -------------------------------- ### Style SVG sprite icons Source: https://github.com/agnauck/xmppdotnet/blob/master/examples/BlazorClient/wwwroot/css/open-iconic/README.md Apply CSS to control the dimensions and color of SVG sprite icons. ```css .icon { width: 16px; height: 16px; } ``` ```css .icon-account-login { fill: #f00; } ``` -------------------------------- ### RequestRosterAsync - Roster (Contact List) Management Source: https://context7.com/agnauck/xmppdotnet/llms.txt Roster extensions provide methods for managing the contact list including requesting, adding, updating, and removing contacts. ```APIDOC ## RequestRosterAsync - Roster (Contact List) Management ### Description Roster extensions provide methods for managing the contact list including requesting, adding, updating, and removing contacts. ### Method GET/POST (depending on operation) ### Endpoint N/A (Client-side methods) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (Parameters are passed directly to the methods) ### Request Example ```csharp // Request the roster (contact list) from server var rosterIq = await xmppClient.RequestRosterAsync(); var roster = rosterIq.Query as Roster; foreach (var item in roster.GetRoster()) { Console.WriteLine($"Contact: {item.Jid}, Name: {item.Name}"); Console.WriteLine($" Subscription: {item.Subscription}"); Console.WriteLine($" Groups: {string.Join(", ", item.GetGroups())}"); } // Add a new contact to roster await xmppClient.AddRosterItemAsync(new Jid("newcontact@server.com")); // Add contact with nickname await xmppClient.AddRosterItemAsync( new Jid("john@server.com"), "John Doe" ); // Add contact with nickname and group await xmppClient.AddRosterItemAsync( new Jid("jane@server.com"), "Jane Smith", "Colleagues" ); // Add contact to multiple groups await xmppClient.AddRosterItemAsync( new Jid("bob@server.com"), "Bob Wilson", new[] { "Friends", "Gaming Buddies" } ); // Update existing roster item await xmppClient.UpdateRosterItemAsync( new Jid("john@server.com"), "Johnny", "Close Friends" ); // Remove contact from roster await xmppClient.RemoveRosterItemAsync(new Jid("oldcontact@server.com")); // Request roster with timeout and cancellation support var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var result = await xmppClient.RequestRosterAsync(timeout: 60000, cts.Token); ``` ### Response #### Success Response (200) - **rosterIq** (Iq) - The IQ stanza containing the roster information. #### Response Example ```json { "query": { "@xmlns": "jabber:iq:roster", "item": [ { "jid": "contact1@server.com", "name": "Contact One", "subscription": "both", "group": ["Friends"] } ] } } ``` ### Error Handling Exceptions may be thrown for network issues, server errors, or invalid roster operations. ``` -------------------------------- ### DTD for XML-RPC Validation Source: https://github.com/agnauck/xmppdotnet/blob/master/src/XmppDotNet.Core/Xmpp/Rpc/XML-RPC.htm A sample Document Type Definition (DTD) for validating XML-RPC method calls and responses. Note that this DTD is illustrative and not officially part of the XML-RPC specification. ```dtd ``` -------------------------------- ### XML Schema for NumericBoolean Source: https://github.com/agnauck/xmppdotnet/blob/master/src/XmppDotNet.Core/Xmpp/Rpc/XML-RPC.htm Defines a custom simple type for boolean values restricted to 0 or 1. ```xml ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.