Created
January 15, 2013 06:03
-
-
Save renatoeufe/4536557 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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