The community forums are in BETA and closed to the public.

Easiest Way to Subscribe to a WebSocket TCP Data Channel in .NET C# SDK 3.5 or Later

The Easiest Way to Subscribe to a WebSocket TCP Data Channel in .NET C# SDK 3.5 or Later

pubnub.Subscribe<string>()

The pubnub.Subscribe() method is being used to receive a open tcp stream of JSON messages in realtime via an automatically negotiated protocol like WebSockets, HTTP Streaming, HTTP Long-polling, TCP Streaming and more with automatic recovery of dropped messages. We've made it easy for you to get started by providing this easy-to-use SDK.

//Basic usage for subscribe and publish
Pubnub pubnub = new Pubnub( publishKey="demo", subscribeKey="demo" );

// Subscribe To Vote Submissions
pubnub.Subscribe<string>(
    pubnubChannel,
    DisplayReturnMessage, 
    DisplaySubscribeConnectStatusMessage, 
    DisplayErrorMessage
);

// Callback method Receive Votes in JSON string format
static void DisplayReturnMessage(string result)
{
    Console.WriteLine("VOTE RECEIVED!");
    Console.WriteLine(result);
    Console.WriteLine();
}

// Callback method to provide the connect status of Subscribe call
static void DisplaySubscribeConnectStatusMessage(string result)
{
    Console.WriteLine("SUBSCRIBE CONNECT CALLBACK:");
    Console.WriteLine(result);
    Console.WriteLine();
}

// Callback method for error messages
static void DisplayErrorMessage(PubnubClientError result)
{
    Console.WriteLine();
    Console.WriteLine(result.Description);
    Console.WriteLine();
}

Comments to this discussion are now closed!