fix websocket sample (#2096)

This commit is contained in:
Andrew Stanton-Nurse 2018-04-19 11:04:39 -07:00 committed by GitHub
parent 31624d2826
commit 617d0bb4f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 4 deletions

View File

@ -11,15 +11,24 @@ namespace WebSocketSample
{
public class Program
{
public static void Main(string[] args)
public static async Task<int> Main(string[] args)
{
RunWebSockets().GetAwaiter().GetResult();
if (args.Length < 1)
{
Console.Error.WriteLine("Usage: WebSocketSample <URL>");
Console.Error.WriteLine("");
Console.Error.WriteLine("To connect to an ASP.NET Connection Handler, use 'ws://example.com/path/to/hub' or 'wss://example.com/path/to/hub' (for HTTPS)");
return 1;
}
await RunWebSockets(args[0]);
return 0;
}
private static async Task RunWebSockets()
private static async Task RunWebSockets(string url)
{
var ws = new ClientWebSocket();
await ws.ConnectAsync(new Uri("ws://localhost:5000/chat/ws"), CancellationToken.None);
await ws.ConnectAsync(new Uri(url), CancellationToken.None);
Console.WriteLine("Connected");