Skip to content

Commit

Permalink
NuGet v1.3.0, thanks @FodderMK for ClientConnected improvements and b…
Browse files Browse the repository at this point in the history
…ugfixes
  • Loading branch information
Joel committed Aug 28, 2019
1 parent 3ee04fe commit b1a9b44
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 40 deletions.
28 changes: 12 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,29 @@ A test project for both client (```TestClient```) and server (```TestServer```)

SSL is supported in WatsonWebsocket. The constructors for ```WatsonWsServer``` and ```WatsonWsClient``` accept a ```bool``` indicating whether or not SSL should be enabled. Since websockets, and as a byproduct WatsonWebsocket, use HTTPS, they rely on certificates within the certificate store of your operating system. A test certificate is provided in both the ```TestClient``` and ```TestServer``` projects which can be used for testing purposes. These should NOT be used in production.

## New in v1.2.x
## New in v1.3.x

- Big thanks to @FodderMK for his time and contributions to WatsonWebsocket!
- Breaking change, ```ClientConnected``` now returns entire HttpListenerRequest
- Simplifications to test programs for both client and server
- More appropriate status codes for various scenarios including non-websocket requests and denied requests

## Version History

v1.2.x

- Return value from ```ClientConnected``` now acts as permit/deny for the connection - thank you @FodderMK!
- Bugfixes to client disconnect handling - thank you @FodderMK!
- Integrated pull requests from @FodderMK (thank you!) for fixes and GetAwaiter()
- Retarget to support both .NET Core 2.0 and .NET Framework 4.5.2

## Running under Mono

Watson works well in Mono environments to the extent that we have tested it. It is recommended that when running under Mono, you execute the containing EXE using --server and after using the Mono Ahead-of-Time Compiler (AOT).

NOTE: To bind to all interfaces specify ```*``` as an IP address representing any interface. Using ```0.0.0.0``` only works on Windows.

```
mono --aot=nrgctx-trampolines=8096,nimt-trampolines=8096,ntrampolines=4048 --server myapp.exe
mono --server myapp.exe
```

## Version History

v1.2.x
- Enhancements and fixes, new constructor using Uri (thank you @BryanCrotaz!)
- Bugfixes, client kill API (thank you @BryanCrotaz!)

v1.1.x

- threading fixes, code cleanup, client connected signature change (thank you @BryanCrotaz!)
- Remove unnecessary framing

v1.0.x

- initial release, bugfixes
34 changes: 23 additions & 11 deletions TestClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,34 @@ class TestClient

static void Main(string[] args)
{
Console.Write("Server IP : ");
serverIp = Console.ReadLine();

Console.Write("Server Port : ");
serverPort = Convert.ToInt32(Console.ReadLine());

Console.Write("SSL (true/false) : ");
ssl = Convert.ToBoolean(Console.ReadLine());

WatsonWsClient client = new WatsonWsClient(serverIp, serverPort, ssl, true, ServerConnected, ServerDisconnected, MessageReceived, true);
string userInput;
Console.Write("Server IP [127.0.0.1] : ");
userInput = Console.ReadLine();
serverIp = string.IsNullOrEmpty(userInput) ? "127.0.0.1" : userInput;

Console.Write("Server Port [8080] : ");
userInput = Console.ReadLine()?.Trim();
if (!int.TryParse(userInput, out serverPort)) serverPort = 8080;

Console.Write("SSL (true/false) [false] : ");
userInput = Console.ReadLine()?.Trim();
if (!bool.TryParse(userInput, out ssl)) ssl = false;

WatsonWsClient client = new WatsonWsClient(
serverIp,
serverPort,
ssl,
true,
ServerConnected,
ServerDisconnected,
MessageReceived,
true);

bool runForever = true;
while (runForever)
{
Console.Write("Command [? for help]: ");
string userInput = Console.ReadLine();
userInput = Console.ReadLine();
if (String.IsNullOrEmpty(userInput)) continue;

switch (userInput)
Expand Down
8 changes: 4 additions & 4 deletions TestDebug.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@echo off
cd TestServer\bin\debug
cd TestServer\bin\debug\net452
start TestServer.exe
TIMEOUT 1 > NULL
cd ..\..\..
cd ..\..\..\..

cd TestClient\bin\debug
cd TestClient\bin\debug\net452
start TestClient.exe
cd ..\..\..
cd ..\..\..\..
echo on
23 changes: 16 additions & 7 deletions TestServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TestServer
static int serverPort = 0;
static bool ssl = false;

static void Main(string[] _)
static void Main(string[] args)
{
string userInput;
Console.Write("Server IP [127.0.0.1] : ");
Expand All @@ -28,17 +28,26 @@ static void Main(string[] _)
userInput = Console.ReadLine()?.Trim();
if (!bool.TryParse(userInput, out ssl)) ssl = false;

WatsonWsServer server = new WatsonWsServer(serverIp, serverPort, ssl, true, null, ClientConnected, ClientDisconnected, MessageReceived, true);
WatsonWsServer server = new WatsonWsServer(
serverIp,
serverPort,
ssl,
true,
null,
ClientConnected,
ClientDisconnected,
MessageReceived,
true);

bool runForever = true;
while (runForever)
{
Console.Write("Command [? for help]: ");
userInput = Console.ReadLine()?.Trim();
if (string.IsNullOrEmpty(userInput)) continue;
string[] splitInput = userInput.Split(" ", 2);

string ipPort;
string[] splitInput = userInput.Split(new string[] { " " }, 2, StringSplitOptions.None);
string ipPort = null;
bool success = false;

switch (splitInput[0])
{
Expand Down Expand Up @@ -79,13 +88,13 @@ static void Main(string[] _)

case "send":
if (splitInput.Length != 2) break;
splitInput = splitInput[1].Split(" ", 2);
splitInput = splitInput[1].Split(new string[] { " " }, 2, StringSplitOptions.None);
if (splitInput.Length != 2) break;
ipPort = splitInput[0];
string data = splitInput[1];

if (string.IsNullOrEmpty(data)) break;
server.SendAsync(ipPort, data);
success = server.SendAsync(ipPort, data).Result;
break;

case "kill":
Expand Down
4 changes: 2 additions & 2 deletions WatsonWebsocket/WatsonWebsocket.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
<Version>1.2.7</Version>
<Version>1.3.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Joel Christner</Authors>
<Description>A simple C# async websocket server and client for reliable transmission and receipt of data</Description>
Expand All @@ -12,7 +12,7 @@
<RepositoryType>Github</RepositoryType>
<PackageLicenseUrl>https://github.com/jchristn/WatsonWebsocket/blob/master/LICENSE.TXT</PackageLicenseUrl>
<PackageTags>websocket message messaging frame framing web</PackageTags>
<PackageReleaseNotes>Return value to ClientConnected now acts as permit/deny for the connection, bugfix for disconnection. Thanks @FodderMK!</PackageReleaseNotes>
<PackageReleaseNotes>Breaking changes, enhancements to ClientConnected and other methods (thank you @FodderMK!)</PackageReleaseNotes>
<PackageIconUrl>https://raw.githubusercontent.com/jchristn/watsonwebsocket/master/assets/watson.ico</PackageIconUrl>
</PropertyGroup>

Expand Down

0 comments on commit b1a9b44

Please sign in to comment.