예제 #1
0
    /// <summary>Subscribe to WAAPI topic. Refer to WAAPI reference documentation for a list of topics and their options.</summary>
    /// <param name="topic">The topic to which subscribe.</param>
    /// <param name="options">The options the subscription.</param>
    /// <param name="publishHandler/// ">The delegate function to call when the topic is published.</param>
    /// <param name="timeout">The maximum timeout in milliseconds for the function to execute. Will raise Waapi.TimeoutException when timeout is reached.</param>
    /// <returns>Subscription id, that you can use to unsubscribe.</returns>
    public async System.Threading.Tasks.Task <uint> Subscribe(
        string topic,
        string options,
        Wamp.PublishHandler publishHandler,
        int timeout = System.Int32.MaxValue)
    {
        if (wamp == null)
        {
            throw new Wamp.WampNotConnectedException("WAMP connection is not established");
        }

        if (options == null)
        {
            options = "{}";
        }

        return(await wamp.Subscribe(topic, options, publishHandler, timeout));
    }
예제 #2
0
 public SubscriptionInfo(string uri, Wamp.PublishHandler cb)
 {
     Uri            = uri;
     Callback       = cb;
     SubscriptionId = 0;
 }
예제 #3
0
 /// <summary>
 /// Subscribe to WAAPI topic. Refer to WAAPI reference documentation for a list of topics and their options.
 /// Creates a WaapiCommand object containing a lambda call to SubscribeAsync and adds it to the waapiCommandQueue.
 /// </summary>
 /// <param name="topic">The topic URI to subscribe to.</param>
 /// <param name="subscriptionCallback">Delegate function to call when the topic is published.</param>
 /// <param name="handshakeCallback">Action to be executed once the subscription has been made.
 /// This should store the subscription ID so that the subscription can be cleaned up when it is no longer needed.</param>
 public static void Subscribe(string topic, Wamp.PublishHandler subscriptionCallback, System.Action <SubscriptionInfo> handshakeCallback)
 {
     waapiCommandQueue.Enqueue(new WaapiCommand(
                                   async() => handshakeCallback(await SubscribeAsync(new SubscriptionInfo(topic, subscriptionCallback)))));
 }