static async Task Main(string[] args)
        {
            Console.WriteLine("Push any key to start");

            Console.ReadLine();

            _client = new WebsocketClient(new ParamsWSClient
            {
                IsWebsocketSecured = false,
                Port = 65214,
                Uri  = "localhost",
                RequestedSubProtocols = new string[] { "testProtocol", "test2", "test3" },
                RequestHeaders        = new Dictionary <string, string> {
                    { HttpKnownHeaderNames.From, "Robbie" }
                },
                KeepAliveInterval = TimeSpan.FromSeconds(5)
            }, token: "Test");
            _client.ConnectionEvent += OnConnectionEvent;
            _client.MessageEvent    += OnMessageEvent;
            _client.ErrorEvent      += OnErrorEvent;
            await _client.ConnectAsync();

            while (true)
            {
                await _client.SendToServerAsync(Console.ReadLine());
            }
        }
Exemple #2
0
 public virtual async Task <bool> SendAsync(string message)
 {
     return(await _websocketClient.SendToServerAsync(new Packet
     {
         Data = message,
         Timestamp = DateTime.UtcNow
     }));
 }