Click or drag to resize
OrtcClient Class
The ORTC (Open Real-Time Connectivity) was developed to add a layer of abstraction to real-time full-duplex web communications platforms by making real-time web applications independent of those platforms. OrtcClient instance provides methods for sending and receiving data in real-time over the web.
Inheritance Hierarchy
SystemObject
  RealtimeFramework.MessagingOrtcClient

Namespace: RealtimeFramework.Messaging
Assembly: RealtimeFramework.Messaging (in RealtimeFramework.Messaging.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public class OrtcClient

The OrtcClient type exposes the following members.

Constructors
  NameDescription
Public methodOrtcClient
OrtcClient Constructor
Top
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 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 methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsSubscribed
Indicates whether is subscribed to a channel.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodCode examplePresence
Gets the subscriptions in the specified channel and if active the first 100 unique metadata.
Public methodCode exampleSend
Sends a message to a channel.
Public methodSendProxy
Sends a message to a channel for a specific application key
Public methodCode exampleSubscribe
Subscribes to a channel.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodCode exampleUnsubscribe
Unsubscribes from a channel.
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
string applicationKey = "myApplicationKey";
string authenticationToken = "myAuthenticationToken"; 

// Create ORTC client
OrtcClient ortcClient = new RealtimeFramework.Messaging.OrtcClient();
ortcClient.ClusterUrl = "http://ortc-developers.realtime.co/server/2.1/";

// Ortc client handlers
ortcClient.OnConnected += new OnConnectedDelegate(ortc_OnConnected);
ortcClient.OnSubscribed += new OnSubscribedDelegate(ortc_OnSubscribed);
ortcClient.OnException += new OnExceptionDelegate(ortc_OnException);

ortcClient.connect(applicationKey, authenticationToken);

private void ortc_OnConnected(object sender)
{
    ortcClient.Subscribe("channel1", true, OnMessageCallback);
}

private void OnMessageCallback(object sender, string channel, string message)
{
    System.Diagnostics.Debug.Writeline("Message received: " + message);
}
private void ortc_OnSubscribed(object sender, string channel)
{
    ortcClient.Send(channel, "your message");
}

private void ortc_OnException(object sender, Exception ex)
{
    System.Diagnostics.Debug.Writeline(ex.Message);
}
See Also