Realtime Messaging
Public Member Functions | Public Attributes | Properties | Events | List of all members
RealtimeMessaging.DotNetCore.Extensibility.OrtcClient Class Referenceabstract

Represents a OrtcClient that connects to a specified gateway. More...

Inheritance diagram for RealtimeMessaging.DotNetCore.Extensibility.OrtcClient:
RealtimeMessaging.DotNetCore.Plugin.RealTimeSJ.RealTimeSJClient

Public Member Functions

virtual Task Connect (string applicationKey, string authenticationToken)
 Connects to the gateway with the application key and authentication token. The gateway must be set before using this method. More...
 
virtual void Disconnect ()
 Disconnects from the gateway. More...
 
virtual Task Subscribe (string channel, bool subscribeOnReconnected, OnMessageDelegate onMessage)
 Subscribes to a channel. More...
 
virtual Task SubscribeWithFilter (String channel, Boolean subscribeOnReconnect, String filter, OnMessageWithFilterDelegate onMessage)
 Subscribes to a channel with a message filter. More...
 
virtual Task SubscribeWithOptions (Dictionary< string, object > options, OnMessageWithOptionsDelegate onMessage)
 Subscribes to a channel with given options. More...
 
virtual Task subscribeWithBuffer (String channel, String subscriberId, OnMessageWithBufferDelegate onMessage)
 Subscribes to a channel with buffer. More...
 
virtual Task Unsubscribe (string channel)
 Unsubscribes from a channel. More...
 
virtual Task Send (string channel, string message)
 Sends a message to a channel. More...
 
virtual void publish (string channel, string message, int ttl, OnPublishResultDelegate callback)
 Publish a message to a channel. More...
 
abstract Task SendProxyAsync (string applicationKey, string privateKey, string channel, string message)
 
virtual bool IsSubscribed (string channel)
 Indicates whether is subscribed to a channel. More...
 
abstract void Presence (String channel, OnPresenceDelegate callback)
 Gets the subscriptions in the specified channel and if active the first 100 unique metadata. More...
 
abstract void EnablePresence (String privateKey, String channel, bool metadata, OnEnablePresenceDelegate callback)
 Enables presence for the specified channel with first 100 unique metadata if metadata is set to true. More...
 
abstract void DisablePresence (String privateKey, String channel, OnDisablePresenceDelegate callback)
 Disables presence for the specified channel. More...
 
string ReadLocalStorage (string applicationKey, int sessionExpirationTime)
 Reads the local storage. More...
 
void CreateLocalStorage (string applicationKey)
 Creates the local storage. More...
 

Public Attributes

const int MAX_MESSAGE_SIZE = 700
 Message maximum size in bytes More...
 
const int MAX_CHANNEL_SIZE = 100
 Channel maximum size in bytes More...
 
const int MAX_CONNECTION_METADATA_SIZE = 256
 Connection Metadata maximum size in bytes More...
 
const string SESSION_STORAGE_NAME = "ortcsession-"
 Session storage name More...
 

Properties

string Id [get, set]
 Gets or sets the client object identifier. More...
 
string Url [get, set]
 Gets or sets the gateway URL. More...
 
string ClusterUrl [get, set]
 Gets or sets the cluster gateway URL. More...
 
bool IsCluster [get, set]
 Gets or sets a value indicating whether this instance is cluster. More...
 
int ConnectionTimeout [get, set]
 Gets or sets the connection timeout. Default value is 5000 miliseconds. More...
 
bool IsConnected [get, set]
 Gets a value indicating whether this client object is connected. More...
 
string ConnectionMetadata [get, set]
 Gets or sets the client connection metadata. More...
 
string AnnouncementSubChannel [get, set]
 Gets or sets the client announcement subchannel. More...
 
string SessionId [get, set]
 Gets or sets the session id. More...
 
bool HeartbeatActive [get, set]
 Gets or sets a value indicating whether this client has a heartbeat activated. More...
 
int HeartbeatFails [get, set]
 Gets or sets a value indicating how many times can the client fail the heartbeat. More...
 
int HeartbeatTime [get, set]
 Gets or sets the heartbeat interval. More...
 

Events

abstract OnConnectedDelegate OnConnected
 Occurs when a connection attempt was successful. More...
 
abstract OnDisconnectedDelegate OnDisconnected
 Occurs when the client connection terminated. More...
 
abstract OnSubscribedDelegate OnSubscribed
 Occurs when the client subscribed to a channel. More...
 
abstract OnUnsubscribedDelegate OnUnsubscribed
 Occurs when the client unsubscribed from a channel. More...
 
abstract OnExceptionDelegate OnException
 Occurs when there is an error. More...
 
abstract OnReconnectingDelegate OnReconnecting
 Occurs when a client attempts to reconnect. More...
 
abstract OnReconnectedDelegate OnReconnected
 Occurs when a client reconnected. More...
 

Detailed Description

Represents a OrtcClient that connects to a specified gateway.

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 = RealtimeMessaging.DotNetCore.Ortc.SaveAuthentication(url, isCluster, authenticationToken, authenticationTokenIsPrivate, applicationKey, timeToLive, privateKey, permissions))
// Load factory
var api = new Api.Ortc("Plugins");
IOrtcFactory factory = api.LoadOrtcFactory("RealTimeSJ");
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
}
}

Member Function Documentation

◆ Connect()

virtual Task RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.Connect ( string  applicationKey,
string  authenticationToken 
)
virtual

Connects to the gateway with the application key and authentication token. The gateway must be set before using this method.

Parameters
applicationKeyYour application key to use ORTC.
authenticationTokenAuthentication token that identifies your permissions.
ortcClient.Connect("myApplicationKey", "myAuthenticationToken");

Reimplemented in RealtimeMessaging.DotNetCore.Plugin.RealTimeSJ.RealTimeSJClient.

◆ CreateLocalStorage()

void RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.CreateLocalStorage ( string  applicationKey)

Creates the local storage.

Parameters
applicationKeyThe application key.

◆ DisablePresence()

abstract void RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.DisablePresence ( String  privateKey,
String  channel,
OnDisablePresenceDelegate  callback 
)
pure virtual

Disables presence for the specified channel.

Parameters
privateKeyThe private key provided when the ORTC service is purchased.
channelChannel to disable presence.
callbackCallback with error OrtcPresenceException and result.

Implemented in RealtimeMessaging.DotNetCore.Plugin.RealTimeSJ.RealTimeSJClient.

◆ Disconnect()

virtual void RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.Disconnect ( )
virtual

Disconnects from the gateway.

ortcClient.Disconnect();

Reimplemented in RealtimeMessaging.DotNetCore.Plugin.RealTimeSJ.RealTimeSJClient.

◆ EnablePresence()

abstract void RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.EnablePresence ( String  privateKey,
String  channel,
bool  metadata,
OnEnablePresenceDelegate  callback 
)
pure virtual

Enables presence for the specified channel with first 100 unique metadata if metadata is set to true.

Parameters
privateKeyThe private key provided when the ORTC service is purchased.
channelChannel to activate presence.
metadataDefines if to collect first 100 unique metadata.
callbackCallback with error OrtcPresenceException and result.

///

client.EnablePresence("myPrivateKey", "presence-channel", false, (error, result) =>
{
if (error != null)
{
Console.WriteLine(error.Message);
}
else
{
Console.WriteLine(result);
}
});

Implemented in RealtimeMessaging.DotNetCore.Plugin.RealTimeSJ.RealTimeSJClient.

◆ IsSubscribed()

virtual bool RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.IsSubscribed ( string  channel)
virtual

Indicates whether is subscribed to a channel.

Parameters
channelThe channel name.
Returns
true if subscribed to the channel; otherwise, false.

Reimplemented in RealtimeMessaging.DotNetCore.Plugin.RealTimeSJ.RealTimeSJClient.

◆ Presence()

abstract void RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.Presence ( String  channel,
OnPresenceDelegate  callback 
)
pure virtual

Gets the subscriptions in the specified channel and if active the first 100 unique metadata.

Parameters
channelChannel with presence data active.
callbackOnPresenceDelegateCallback with error OrtcPresenceException and result Presence.
client.Presence("presence-channel", (error, result) =>
{
if (error != null)
{
Console.WriteLine(error.Message);
}
else
{
if (result != null)
{
Console.WriteLine(result.Subscriptions);
if (result.Metadata != null)
{
foreach (var metadata in result.Metadata)
{
Console.WriteLine(metadata.Key + " - " + metadata.Value);
}
}
}
else
{
Console.WriteLine("There is no presence data");
}
}
});

Implemented in RealtimeMessaging.DotNetCore.Plugin.RealTimeSJ.RealTimeSJClient.

◆ publish()

virtual void RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.publish ( string  channel,
string  message,
int  ttl,
OnPublishResultDelegate  callback 
)
virtual

Publish a message to a channel.

Parameters
channelChannel name.
messageMessage to be sent.
ttlThe message expiration time in seconds (0 for maximum allowed ttl).
callbackReturns error if message publish was not successful or published message unique id (seqId) if sucessfully published
ortcClient.publish("channelName", "messageToSend");

Reimplemented in RealtimeMessaging.DotNetCore.Plugin.RealTimeSJ.RealTimeSJClient.

◆ ReadLocalStorage()

string RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.ReadLocalStorage ( string  applicationKey,
int  sessionExpirationTime 
)

Reads the local storage.

Parameters
applicationKeyThe application key.
sessionExpirationTimeThe session expiration time.
Returns

◆ Send()

virtual Task RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.Send ( string  channel,
string  message 
)
virtual

Sends a message to a channel.

Parameters
channelChannel name.
messageMessage to be sent.
ortcClient.Send("channelName", "messageToSend");

Reimplemented in RealtimeMessaging.DotNetCore.Plugin.RealTimeSJ.RealTimeSJClient.

◆ Subscribe()

virtual Task RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.Subscribe ( string  channel,
bool  subscribeOnReconnected,
OnMessageDelegate  onMessage 
)
virtual

Subscribes to a channel.

Parameters
channelChannel name.
subscribeOnReconnectedSubscribe to the specified channel on reconnect.
onMessageOnMessageDelegate callback.
ortcClient.Subscribe("channelName", true, OnMessageCallback);
private void OnMessageCallback(object sender, string channel, string message)
{
// Do something
}

Reimplemented in RealtimeMessaging.DotNetCore.Plugin.RealTimeSJ.RealTimeSJClient.

◆ subscribeWithBuffer()

virtual Task RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.subscribeWithBuffer ( String  channel,
String  subscriberId,
OnMessageWithBufferDelegate  onMessage 
)
virtual

Subscribes to a channel with buffer.

Parameters
channelChannel name.
subscriberIdThe subscriber client identifier
onMessageOnMessageWithBufferDelegate callback.
ortcClient.subscribeWithBuffer("channelName", "SOME_ID", OnMessageCallback);
private void OnMessageCallback(object ortc, string channel, string seqId, string message)
{
// Do something
}

Reimplemented in RealtimeMessaging.DotNetCore.Plugin.RealTimeSJ.RealTimeSJClient.

◆ SubscribeWithFilter()

virtual Task RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.SubscribeWithFilter ( String  channel,
Boolean  subscribeOnReconnect,
String  filter,
OnMessageWithFilterDelegate  onMessage 
)
virtual

Subscribes to a channel with a message filter.

Parameters
channelChannel name.
subscribeOnReconnectedSubscribe to the specified channel on reconnect.
filterMessage filter
onMessageOnMessageWithFilterDelegate callback.
ortcClient.subscribeWithFilter("channelName", true, "a = 1", OnMessageCallback);
private void OnMessageCallback(object sender, string channel, Boolean filtered, string message)
{
// Do something
}

Reimplemented in RealtimeMessaging.DotNetCore.Plugin.RealTimeSJ.RealTimeSJClient.

◆ SubscribeWithOptions()

virtual Task RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.SubscribeWithOptions ( Dictionary< string, object >  options,
OnMessageWithOptionsDelegate  onMessage 
)
virtual

Subscribes to a channel with given options.

Parameters
optionsChannel subscription options
subscribeOnReconnectedSubscribe to the specified channel on reconnect.
onMessageOnMessageWithOptionsDelegate callback.
"options = {
channel,
subscribeOnReconnected, // optional, default = true,
withNotifications(Bool), // optional, default = false, use push notifications as in subscribeWithNotifications
filter, // optional, default = "", the subscription filter as in subscribeWithFilter
subscriberId // optional, default = "", the subscriberId as in subscribeWithBuffer
}"
ortcClient.SubscribeWithOptions(options, OnMessageCallback);
private void OnMessageCallback(object sender, Dictionary<string, object> msgOptions)
{
// Do something
}

Reimplemented in RealtimeMessaging.DotNetCore.Plugin.RealTimeSJ.RealTimeSJClient.

◆ Unsubscribe()

virtual Task RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.Unsubscribe ( string  channel)
virtual

Unsubscribes from a channel.

Parameters
channelChannel name.
ortcClient.Unsubscribe("channelName");

Reimplemented in RealtimeMessaging.DotNetCore.Plugin.RealTimeSJ.RealTimeSJClient.

Member Data Documentation

◆ MAX_CHANNEL_SIZE

const int RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.MAX_CHANNEL_SIZE = 100

Channel maximum size in bytes

<exclude>

◆ MAX_CONNECTION_METADATA_SIZE

const int RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.MAX_CONNECTION_METADATA_SIZE = 256

Connection Metadata maximum size in bytes

<exclude>

◆ MAX_MESSAGE_SIZE

const int RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.MAX_MESSAGE_SIZE = 700

Message maximum size in bytes

<exclude>

◆ SESSION_STORAGE_NAME

const string RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.SESSION_STORAGE_NAME = "ortcsession-"

Session storage name

Property Documentation

◆ AnnouncementSubChannel

string RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.AnnouncementSubChannel
getset

Gets or sets the client announcement subchannel.

///

Announcement subchannel.

◆ ClusterUrl

string RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.ClusterUrl
getset

Gets or sets the cluster gateway URL.

◆ ConnectionMetadata

string RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.ConnectionMetadata
getset

Gets or sets the client connection metadata.

Connection metadata.

◆ ConnectionTimeout

int RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.ConnectionTimeout
getset

Gets or sets the connection timeout. Default value is 5000 miliseconds.

◆ HeartbeatActive

bool RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.HeartbeatActive
getset

Gets or sets a value indicating whether this client has a heartbeat activated.

true if the heartbeat is active; otherwise, false.

◆ HeartbeatFails

int RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.HeartbeatFails
getset

Gets or sets a value indicating how many times can the client fail the heartbeat.

Failure limit.

◆ HeartbeatTime

int RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.HeartbeatTime
getset

Gets or sets the heartbeat interval.

Interval in seconds between heartbeats.

◆ Id

string RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.Id
getset

Gets or sets the client object identifier.

Object identifier.

◆ IsCluster

bool RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.IsCluster
getset

Gets or sets a value indicating whether this instance is cluster.

true if this instance is cluster; otherwise, false.

◆ IsConnected

bool RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.IsConnected
getset

Gets a value indicating whether this client object is connected.

true if this client is connected; otherwise, false.

◆ SessionId

string RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.SessionId
getset

Gets or sets the session id.

The session id.

◆ Url

string RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.Url
getset

Gets or sets the gateway URL.

Gateway URL where the socket is going to connect.

Event Documentation

◆ OnConnected

abstract OnConnectedDelegate RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.OnConnected

Occurs when a connection attempt was successful.

◆ OnDisconnected

abstract OnDisconnectedDelegate RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.OnDisconnected

Occurs when the client connection terminated.

◆ OnException

abstract OnExceptionDelegate RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.OnException

Occurs when there is an error.

◆ OnReconnected

abstract OnReconnectedDelegate RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.OnReconnected

Occurs when a client reconnected.

◆ OnReconnecting

abstract OnReconnectingDelegate RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.OnReconnecting

Occurs when a client attempts to reconnect.

◆ OnSubscribed

abstract OnSubscribedDelegate RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.OnSubscribed

Occurs when the client subscribed to a channel.

◆ OnUnsubscribed

abstract OnUnsubscribedDelegate RealtimeMessaging.DotNetCore.Extensibility.OrtcClient.OnUnsubscribed

Occurs when the client unsubscribed from a channel.


The documentation for this class was generated from the following file: