/// <param name="timeout">The maximum timeout in milliseconds for the function to execute. Will raise Waapi.TimeoutException when timeout is reached.</param>
publicasyncSystem.Threading.Tasks.TaskConnect(
stringuri="ws://localhost:8080/waapi",
inttimeout=System.Int32.MaxValue)
{
if(wamp==null)
wamp=newWamp();
wamp.Disconnected+=Wamp_Disconnected;
awaitwamp.Connect(uri,timeout);
}
privatevoidWamp_Disconnected()
{
if(Disconnected!=null)
{
Disconnected();
}
}
/// <summary>Close the connection.</summary>
/// <param name="timeout">The maximum timeout in milliseconds for the function to execute. Will raise Waapi.TimeoutException when timeout is reached.</param>
publicasyncSystem.Threading.Tasks.TaskClose(
inttimeout=System.Int32.MaxValue)
{
if(wamp==null)
thrownewWamp.WampNotConnectedException("WAMP connection is not established");
awaitwamp.Close(timeout);
wamp.Disconnected-=Wamp_Disconnected;
wamp=null;
}
/// <summary>
/// Return true if the client is connected and ready for operations.
/// </summary>
publicboolIsConnected()
{
if(wamp==null)
returnfalse;
returnwamp.IsConnected();
}
/// <summary>Call a WAAPI remote procedure. Refer to WAAPI reference documentation for a list of URIs and their arguments and options.</summary>
/// <param name="uri">The URI of the remote procedure.</param>
/// <param name="args">The arguments of the remote procedure.</param>
/// <param name="options">The options the remote procedure.</param>
/// <param name="timeout">The maximum timeout in milliseconds for the function to execute. Will raise Waapi.TimeoutException when timeout is reached.</param>
/// <returns>A JSON string with the result of the Remote Procedure Call.</returns>
thrownewWamp.WampNotConnectedException("WAMP connection is not established");
if(args==null)
args="{}";
if(options==null)
options="{}";
returnawaitwamp.Call(uri,args,options,timeout);
}
/// <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>
/// <summary>Unsubscribe from a subscription.</summary>
/// <param name="subscriptionId">The subscription id received from the initial subscription.</param>
/// <param name="timeout">The maximum timeout in milliseconds for the function to execute. Will raise Waapi.TimeoutException when timeout is reached.</param>