OrtcClient ClassOpen Real Time Connectivity Application Programming Interface Help
Represents a OrtcClient that connects to a specified gateway.
Inheritance Hierarchy

SystemObject
  Ibt.Ortc.Api.ExtensibilityOrtcClient

Namespace: Ibt.Ortc.Api.Extensibility
Assembly: Ibt.Ortc.Api.Extensibility (in Ibt.Ortc.Api.Extensibility.dll) Version: 2.1.14.0 (2.1.14)
Syntax

public abstract class OrtcClient

The OrtcClient type exposes the following members.

Methods

  NameDescription
Public methodCode exampleConnect
Connects to the gateway with the application key and authentication token. The gateway must be set before using this method.
Public methodCreateLocalStorage
Creates the local storage.
Public methodDisablePresence
Disables presence for the specified channel.
Public methodCode exampleDisconnect
Disconnects from the gateway.
Public methodCode exampleEnablePresence
Enables presence for the specified channel with first 100 unique metadata if metadata is set to true.
Public methodIsSubscribed
Indicates whether is subscribed to a channel.
Public methodCode examplePresence
Gets the subscriptions in the specified channel and if active the first 100 unique metadata.
Public methodReadLocalStorage
Reads the local storage.
Public methodCode exampleSend
Sends a message to a channel.
Public methodSendProxy
Public methodCode exampleSubscribe
Subscribes to a channel.
Public methodCode exampleUnsubscribe
Unsubscribes from a channel.
Top
Fields

  NameDescription
Public fieldStatic memberSESSION_STORAGE_NAME
Session storage name
Top
Properties

  NameDescription
Public propertyAnnouncementSubChannel
Gets or sets the client announcement subchannel.
Public propertyClusterUrl
Gets or sets the cluster gateway URL.
Public propertyConnectionMetadata
Gets or sets the client connection metadata.
Public propertyConnectionTimeout
Gets or sets the connection timeout. Default value is 5000 miliseconds.
Public propertyHeartbeatActive
Gets or sets a value indicating whether this client has a heartbeat activated.
Public propertyHeartbeatFails
Gets or sets a value indicating how many times can the client fail the heartbeat.
Public propertyHeartbeatTime
Gets or sets the heartbeat interval.
Public propertyId
Gets or sets the client object identifier.
Public propertyIsCluster
Gets or sets a value indicating whether this instance is cluster.
Public propertyIsConnected
Gets a value indicating whether this client object is connected.
Public propertySessionId
Gets or sets the session id.
Public propertyUrl
Gets or sets the gateway URL.
Top
Events

  NameDescription
Public eventOnConnected
Occurs when a connection attempt was successful.
Public eventOnDisconnected
Occurs when the client connection terminated.
Public eventOnException
Occurs when there is an error.
Public eventOnReconnected
Occurs when a client reconnected.
Public eventOnReconnecting
Occurs when a client attempts to reconnect.
Public eventOnSubscribed
Occurs when the client subscribed to a channel.
Public eventOnUnsubscribed
Occurs when the client unsubscribed from a channel.
Top
Examples

public partial class OrtcUsageForm : Form
{
    public OrtcUsageForm()
    {
        string applicationKey = "myApplicationKey";
        string authenticationToken = "myAuthenticationToken"; 

        // Permissions
        Dictionary{string, ChannelPermissions} permissions = new Dictionary{string, ChannelPermissions}();

        permissions.Add("channel1", ChannelPermissions.Read);
        permissions.Add("channel2", ChannelPermissions.Write);

        string url = "http://ortc_server";
        bool isCluster = false;
        string authenticationToken = "myAuthenticationToken";
        bool authenticationTokenIsPrivate = true;
        string applicationKey = "myApplicationKey";
        int timeToLive = 1800; // 30 minutes
        string privateKey = "myPrivateKey";

        // Save authentication
        bool authSaved = Ibt.Ortc.Api.Ortc.SaveAuthentication(url, isCluster, authenticationToken, authenticationTokenIsPrivate, applicationKey, timeToLive, privateKey, permissions)) 

        // Load factory
        var api = new Api.Ortc("Plugins");

        IOrtcFactory factory = api.LoadOrtcFactory("IbtRealTimeSJ");

        if (factory != null)
        {
            // Create ORTC client
            OrtcClient ortcClient = factory.CreateClient();

            if (ortcClient != null)
            {
                // ORTC client parameters
                ortcClient.Id = "myId";
                // You can use a cluster server URL
                ortcClient.ClusterUrl = "http://ortc_cluster_server";
                // Or just a server URL
                // ortcClient.Url = "http://ortc_server";
                ortcClient.ConnectionMetadata = "myConnectionMetadata";

                // Ortc client handlers
                ortcClient.OnConnected += new OnConnectedDelegate(ortc_OnConnected);
                ortcClient.OnDisconnected += new OnDisconnectedDelegate(ortc_OnDisconnected);
                ortcClient.OnReconnecting += new OnReconnectingDelegate(ortc_OnReconnecting);
                ortcClient.OnReconnected += new OnReconnectedDelegate(ortc_OnReconnected);
                ortcClient.OnSubscribed += new OnSubscribedDelegate(ortc_OnSubscribed);
                ortcClient.OnUnsubscribed += new OnUnsubscribedDelegate(ortc_OnUnsubscribed);
                ortcClient.OnException += new OnExceptionDelegate(ortc_OnException);

                ortcClient.connect(applicationKey, authenticationToken);
            }
            else
            {
                // Error creating client
            }
        }
        else
        {
            // Error loading factory
        }
    }

    private void ortc_OnConnected(object sender)
    {
        // If the client reconnects it will automatically subscribe to the channel “channel1”
        ortcClient.Subscribe("channel1", true, OnMessageCallback1);

        // If the client reconnects it will not automatically subscribe to the channel “channel2”
        ortcClient.Subscribe("channel2", false, OnMessageCallback2);
    }

    private void OnMessageCallback1(object sender, string channel, string message)
    {
        // Handle the message received event
    }

    private void OnMessageCallback2(object sender, string channel, string message)
    {
        // Handle the message received event
    }

    private void ortc_OnDisconnected(object sender)
    {
        // Handle the ortc client disconnected event
    }

    private void ortc_OnReconnecting(object sender)
    {
        // Handle the ortc client reconnecting event
    }

    private void ortc_OnReconnected(object sender)
    {
        // Handle the ortc client reconnected event
    }

    private void ortc_OnSubscribed(object sender, string channel)
    {
        // Handle the ortc client subscribed event
    }

    private void ortc_OnUnsubscribed(object sender, string channel)
    {
        // Handle the ortc client unsubscribed event
    }

    private void ortc_OnException(object sender, Exception ex)
    {
        // Handle the ortc client exception event
    }
}
See Also

Reference