C#C# V4 Misc API Reference for Realtime Apps

Go to Objects (BETA)


 

These docs are for PubNub 4.0 for C# which is our latest and greatest! For the docs of the 3.x versions of the SDK, please check the links: C#, Windows 8, Windows 8.1, ASP.Net, Windows Phone 8, Windows Phone 8.1, Xamarin.iOS, Xamarin.Android, Xamarin.Mac and C# PCL.

If you have questions about the PubNub for C# SDK, please contact us at support@pubnub.com.

This function allow to decrypt the data.
To decrypt the data you can use the following method(s) in C# V4 SDK.
  1. ParameterTypeRequiredDescription
    inputStringStringYesThe data to decrypt.
    cipherKeyStringOptionalIf it's not provided, the cipher key from config will be used.
string encryptedString = "9qR0Q4TuDUwiLTcxtIY3mA==";
string cipherKey = "testCipher";

string decryptedMessage = pubnub.Decrypt(encryptedString, cipherKey);
Destroy frees up the threads and allows for clean exit.
  1. destroy()
pubnub.Destroy();
None
This function allow to encrypt the data.
To encrypt the data you can use the following method(s) in C# V4 SDK.
  1. ParameterTypeRequiredDescription
    inputStringStringYesThe data to encrypt.
    cipherKeyStringOptionalIf it's not provided, the cipher key from config will be used.
string stringToEncrypt = "hello world";
string cipherKey = "testCipher";

string payload = pubnub.Encrypt(stringToEncrypt, cipherKey);
Call the Disconnect method to force the SDK to stop all requests to PubNub server when there are active subscribe channels.
To disconnect the data you can use the following method(s) in C# V4 SDK.
  1. This method doesn't take any arguments.

pubnub.Disconnect<string>();
Returns all the subscribed channel groups in a List of type String.
To Get Subscribe Channel Groups you can use the following method(s) in the C# V4 SDK
  1. List<string> GetSubscribedChannelGroups()
List<string> groups = pubnub.GetSubscribedChannelGroups();
List<String>
["channelGroup1", "channelGroup2"]
Returns all the subscribed channels in a List of type String.
To Get Subscribed Channels you can use the following method(s) in the C# V4 SDK:
  1. List<string> GetSubscribedChannels()
List<string> channels = pubnub.GetSubscribedChannels();
List<String>
["channel1", "channel2"]
Call the reconnect method to force the SDK to try and reach out PubNub.
To reconnect the data you can use the following method(s) in C# V4 SDK.
  1. ParameterTypeRequiredDescription
    resetSubscribeTokenboolOptionalPassing true will send zero timetoken upon reconnect.
pubnub.Reconnect<string>();
This function will return a 17 digit precision Unix epoch.
 
Timetoken
The timetoken is constructed using the following algorithm:
timetoken = (Unix epoch time in seconds) * 10000000
Example of creating a timetoken for a specific time & date
08/19/2013 @ 9:20pm in UTC = 1376961606
timetoken = 1376961606 * 10000000
timetoken = 13769616060000000
To fetch Time you can use the following method(s) in C# V4 SDK
  1. ParameterTypeRequiredDescription
    QueryParamDictionary<string, object>OptionalDictionary object to pass name/value pairs as query string params with PubNub URL request for debug purpose.
    AsyncPNCallbackDeprecatedPNCallback of type PNTimeResult.
    ExecutePNCallbackYesPNCallback of type PNTimeResult.
pubnub.Time()
    .Execute(new PNTimeResultExt(
        (result, status) => {
            // handle time result.
        }
    ));
The Time operation returns a PNTimeResult which contains the following property:
Property NameTypeDescription
TimetokenlongReturns a long representation of current time token.