Please Wait

Loading..

.Net SDK 1.0.0

Create amazing realtime applications easily with Yalgaar .Net SDK

.Net SDK

1 Connect To Yalgaar

Requirement :

.Net Framework 4.5 or above

Download package and Include Yalgaar .Net SDK(YalgaarNet.dll) in your code.

using YalgaarNet;

To connect to a Yalgaar client,use following method, it must have valid Client Key.

YalgaarClient(string ClientKey, bool IsSecure, Action<bool> ConnectionCallback);
YalgaarClient(string ClientKey, bool IsSecure, string UUID, Action<bool> ConnectionCallback);
YalgaarClient(string ClientKey, bool IsSecure, string AESSecretKey, int AESType, Action<bool> ConnectionCallback);
YalgaarClient(string ClientKey, bool IsSecure, string UUID, string AESSecretKey, int AESType,Action<bool> ConnectionCallback);    

Parameter:

  • Client Key
    • Description: Yalgaar provided authentic client key for project.
    • DataType: string
  • IsSecure
    • Description: Secure connection with SSL [True / False].
    • DataType: boolean (value must be true or false)
  • UUID
    • Description: Any unique user name or user id. UUID is CASE SENSITIVE and only alpha numeric, hyphens,@,underscore allowed and maximum length must be 50.
    • DataType: string
  • AESSecretKey
    • Description: Secret key use for encrypt/decrypt message.
    • DataType: string
  • AESType
    • Description: Type of AES algorithm use for encrypt/decrypt message. Support AES type 128,192 and 256.
    • DataType: int
  • ConnectionCallback
    • Description: Called when successfully connected to server.
    • DataType: Action


2 Publish Message

To publish message, use following method

Publish(string Channel, string Message);

Parameter:

  • Channel
    • Description: Channel name on which message will be published. Only alpha numeric, hyphens, @, underscore allowed and maximum length must be 50.
    • Data Type: string
  • Message
    • Description: Data to be send on given channel.
    • DataType: string


3 Subscribe Message

To subscribe message,use following method.

Subscribe(string Channel, Action<string,string> SubscribeReturnMessageCallback,Action<string> ErrorMsgCallback);
Subscribe(string Channel, Action<string, string> SubscribeReturnMessageCallback, Action<string> PresenceMessageCallback, Action<string> ErrorMsgCallback);

Parameter:

  • Channel
    • Description: Single channel name or list of channels name on which message will be subscribed. For multiple channel names use List. Channel name is CASE SENSITIVE. Only alpha numeric, hyphens, @, underscore allowed and maximum length must be 50.
    • DataType: string (for multiple channels use List<string>).
  • SubscribeReturnMessageCallback
    • Description: Callback function to consume received message.
    • DataType: Action
  • PresenceMessageCallback
    • Description: Callback function to consume presence events such as join or leave.
    • DataType: Action
  • ErrorMsgCallback
    • Description: Callback is called on system error occurred during subscription.
    • DataType: Action


4 Unsubscribe Message

To unsubscribe message,use following method.

UnSubscribe(string Channel);

Parameter:

  • Channel
    • Description: channel name to be unsubscribe. Only alpha numeric, hyphens, @, underscore allowed and maximum length must be 50.
    • DataType: string


5 Get User List

To get list of all users subscribed with specific channel name, use following method.

GetUUIDList(string Channel, Action<object> UserListCallback, Action<string> ErrorMsgCallback)

Parameter:

  • Channel
    • Description: Valid channel name. Channel name is CASE SENSITIVE and only alpha numeric, hyphens, @, underscore allowed and maximum length must be 50.
    • DataType: string
  • UserListCallback
    • Description: Callback is called when successfully get user list.
    • DataType: Action
  • ErrorMsgCallback
    • Description: Callback is called when an error occurred.
    • DataType: Action


6 Get Channel List

To get list of all channels subscribed by specified user, use following method.

GetChannelList(string UUID, Action<object> ChannelListCallback, Action<string> ErrorMsgCallback);

Parameter:

  • UUID:
    • Description: Valid user Id. user Id is CASE SENSITIVE and only alpha numeric, hyphens, @, underscore allowed and maximum length must be 50.
    • DataType: string
  • ChannelListCallback
    • Description: Callback is called when successfully get channel list.
    • DataType: Action
  • ErrorMsgCallback
    • Description: Callback is called when an error occurred
    • DataType: Action


7 Get Message History

To get the already published messages, use following method

GetHistory(string Channel, int MessageCount, Action<object> HistoryMessageCallback, Action<string> ErrorMsgCallback);

Parameter:

  • Channel
    • Description: Valid channel name. Channel name is CASE SENSITIVE and only alpha numeric, hyphens, @, underscore allowed and maximum length must be 50.
    • DataType: string
  • MessageCount
    • Description: How many messages that you want to fetch. Maximum 100 messages allow at a time.
    • Data Type: int
  • HistoryMessageCallback
    • Description: Callback is called when successfully get message history list.
    • DataType: Action
  • ErrorMsgCallback
    • Description: Callback is called when an error occurred.
    • DataType: Action


8 Close Connection

To close connection, use following method

CloseConnection();


9 Connection close event handler

You can handle connection closing event as follow

yalgaar.IsConnectionClose += handler;

Handler Parameter:

  • ErrorMessage
    • Description: System error occurred during connection lost.
    • DataType: string


You can publish/subscribe message like so :

Include Yalgaar .Net SDK(YalgaarNet.dll) in your code

using YalgaarNet;
public class YalgaarNet : Form
{
	YalgaarClient yalgaar = null;
	public YalgaarNet(string ClientKey,bool Secure)
	{
		yalgaar = new YalgaarClient(ClientKey, Secure);
        yalgaar.IsConnectionClose += YalgaarClient_IsConnectionClose;
	}
	private bool PublishMessage()
	{
        yalgaar.Publish("YourChannel", "This is Yalgaar .Net SDK Example");
	}
	private bool SubscribeMessage()
	{
        yalgaar.Subscribe("YourChannel", SubscribeReturnMessage, SubErrorMessage);
	}
    public void SubscribeReturnMessage(string Channel, string message)
    {
        MessageBox.Show(message);
        yalgaar.CloseConnection();
    }
    public void SubErrorMessage(string message)
    {
        MessageBox.Show(message);
    }
    void YalgaarClient_IsConnectionClose(string ErrorMessage)
    {
        MessageBox.Show("Connection Close: "+ ErrorMessage);
    }
}