Skip to content

Instantly share code, notes, and snippets.

@renatoeufe
Created January 15, 2013 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renatoeufe/4536557 to your computer and use it in GitHub Desktop.
Save renatoeufe/4536557 to your computer and use it in GitHub Desktop.
using System;
using System.Threading.Tasks;
using Microsoft.AspNet.SignalR.Client.Hubs;
namespace AsyncMessageSender
{
internal class Program
{
private const string PrivateKey = "bcf9f7ff-dd90-41ac-b737-dd0b93be3fc5";
private const string Url = "http://localhost:6398";
private static void Main(string[] args)
{
var connection = new HubConnection(Url, "key=" + PrivateKey);
var hub = connection.CreateHubProxy("chatHub");
connection.Start().Wait();
hub.Invoke("SendRequest", "[usuário]", "[mensagem]")
.ContinueWith(task =>
{
if (task.IsFaulted)
{
if (task.Exception != null)
Console.WriteLine(task.Exception.GetBaseException().Message);
}
else
{
Console.WriteLine("End.");
}
})
.ContinueWith(task =>
{
Console.ReadLine();
}, TaskContinuationOptions.OnlyOnFaulted);
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment