Skip to content

Instantly share code, notes, and snippets.

@stephenlb
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save stephenlb/13bfd88284ec1f4d59f5 to your computer and use it in GitHub Desktop.

Select an option

Save stephenlb/13bfd88284ec1f4d59f5 to your computer and use it in GitHub Desktop.
The Subscribe<string>() method is being used to receive poll answers 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.
// 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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment