A callback method to invoke when a request for a subscription is received from another XMPP user.

Namespace: S22.Xmpp.Client
Assembly: S22.Xmpp (in S22.Xmpp.dll) Version: 1.0.0.0 (1.0.0.0)

Syntax

C#
public SubscriptionRequest SubscriptionRequest { get; set; }

Examples

This example demonstrates how to set up the SubscriptionRequest delegate in order to process incoming subscription requests.
CopyC#
static void Main(string[] args) {
  string hostname = "jabber.se",
    username = "myUsername",
    password = "myPassword";

  using (var cl = new XmppClient(hostname, username, password)) {
    cl.SubscriptionRequest = OnSubscriptionRequest;
    cl.Connect();

    // Put the thread to sleep and wait for subscription requests.
    Thread.Sleep(Timeout.Infinite);
  }
}

/// <summary>
/// A callback method that is invoked whenever a subscription request from
/// another XMPP user is received.
/// </summary>
/// <param name="from">The JID of the XMPP user who wishes to subscribe to our
/// presence.</param>
/// <returns>true to approve the request; Otherwise false.</returns>
static bool OnSubscriptionRequest(Jid from) {
  Console.WriteLine(from + " wants to subscribe to your presence.");
  Console.Write("Type Y to approve the request, or any other key to refuse it: ");

  // Return true to approve the request, or false to refuse it.
  return Console.ReadLine().ToLowerInvariant() == "y";
}

See Also