Skip to content

Wrapper around System.Net.WebSockets.ClientWebSocket that provides event based interface to exchange text messages over Web Sockets. Support cancellation

License

Notifications You must be signed in to change notification settings

dimaaan/WebSocketTextClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebSocketTextClient

Wrapper around System.Net.WebSockets.ClientWebSocket that provides event based interface to exchange text messages over Web Sockets in event based way and support cancellation. Includes events for open/close, message received and error received.

Target Platform:

.NET Standard 2.0

Install

Package Manager

Install-Package WebSocketTextClient

DotNetCore

dotnet add package WebSocketTextClient

Packet

paket add WebSocketTextClient

Example

using (var cts = new CancellationTokenSource())
using (var client = new WebSocketTextClient(cts.Token))
{
    client.MessageReceived = (sender, eventArgs) => Console.WriteLine(eventArgs.Message);

    await client.ConnectAsync(new Uri("ws://example.com"));
    await client.SendAsync("ping");
    await Task.Delay(5000);
}

About

Wrapper around System.Net.WebSockets.ClientWebSocket that provides event based interface to exchange text messages over Web Sockets. Support cancellation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages