From 1ab5e4b6e19c1b929907df1e849d9c542ae3752e Mon Sep 17 00:00:00 2001 From: Alecio Furanze Date: Sat, 7 Oct 2023 12:02:55 +0200 Subject: [PATCH] ``release`` Netly 3.0 --- README.md | 19 ++- src/Netly.csproj | 18 ++- static/nuget/README.md | 293 ++++++++++++++++++++++------------------- 3 files changed, 183 insertions(+), 147 deletions(-) diff --git a/README.md b/README.md index a5ebf735..878d6593 100644 --- a/README.md +++ b/README.md @@ -48,15 +48,15 @@ powered by ALEC1O > Notable changes -| v1 (old) | v2 (stable) | v3 (in dev) | v4 (nonexistent) | -|--------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|--------------------------------------------| -| TCP (client/server) | TCP/IP [Message Framing](https://web.archive.org/web/20230219220947/https://blog.stephencleary.com/2009/04/message-framing.html) | TLS/SSL (client/server) | Websocket (client/server) | -| UDP | TCP/UDP performance improvement | Include docs/sample (SSL/TLS) | Include docs/sample (Websocket) | -| | | ``Message Framing`` memory and performance improve | | -| | | ``Message Framing`` new protocol | | -| | | ``UDP`` impl connection with udp (ping/timeout) | | -| | | collaborative documentation ``docsify`` | | -| | | Byter ``2.0`` | | +| v1 (old) | v2 (old) | v3 (stable) | v4 (nonexistent) | +|--------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|-----------------------------------------------| +| TCP (client/server) | TCP/IP [Message Framing](https://web.archive.org/web/20230219220947/https://blog.stephencleary.com/2009/04/message-framing.html) | TLS/SSL (client/server) | Websocket (client/server) | +| UDP | TCP/UDP performance improvement | Include docs/sample (SSL/TLS) | Include docs/sample (Websocket) | +| | | ``Message Framing`` memory and performance improve | | +| | | ``Message Framing`` new protocol | | +| | | ``UDP`` impl connection with udp (ping/timeout) | | +| | | collaborative documentation ``docsify`` | | +| | | Byter ``2.0`` | |
@@ -72,7 +72,6 @@ powered by ALEC1O > Below are some missing features that are planned to be added in later versions.
-- SSL/TLS (v3) - Websocket (v4)
diff --git a/src/Netly.csproj b/src/Netly.csproj index 0ebc3b07..854a2f7d 100644 --- a/src/Netly.csproj +++ b/src/Netly.csproj @@ -23,7 +23,7 @@ Netly - 2.5.2 + 3.0 alec1o alec1o alec1o @@ -37,7 +37,21 @@ README.md LICENSE.md - + Update default MAX_SIZE 8kb to 8MB (Package.MAX_SIZE -> MesssageFraming encode/decode) + Note + [+] Added + [-] Removed + [!] Fixed + [>] Updated + + [+] SSL/TLS protocol + [+] Include docs/sample (SSL/TLS) + [+] New docs (Gitbook -> Docsify) + [>] New MessageFraming protocol + [>] Message Framing memory and performance improve + [>] Udp set max buffer size + [>] Udp connection detection (timeout/ping-pong) + [!] MainThread null reference exception + [>] Byter 2.0 Netly is a socket library for c# (C-Sharp). It facilitates the use of socket (UDP and TCP, Client and Server). diff --git a/static/nuget/README.md b/static/nuget/README.md index 023317c7..1a58526f 100644 --- a/static/nuget/README.md +++ b/static/nuget/README.md @@ -1,187 +1,210 @@ -## About -> Netly is a open source socket library for c# (C-Sharp). It facilitates the use of socket (UDP and TCP, Client and Server) with which it is compatible (Android, iOS, macOS, Linux, Windows, ...) as long as it is compiled with its destination. +##### About +> Netly is a flexible socket library built on c-sharp. It is compatible with (Android, iOS, Linux, +> Windows...) -## Docs -> ### See the documentation [here!](http://netly.docs.kezero.com) -## Install -###### Official publisher -| Nuget | Unity Asset Store | -| --- | --- | -| Install on [Nuget](https://www.nuget.org/packages/Netly)| Install on [Asset Store ](https://assetstore.unity.com/packages/tools/network/225473)| +##### Documentation -## Versions -###### Notable changes -| [v1](https://github.com/alec1o/Netly/tree/1.x) (old) | [v2](https://github.com/alec1o/Netly/tree/2.x) (current) | [v3](https://github.com/alec1o/Netly/tree/3.x) (nonexistent) | -| --- | --- | --- | -| TCP client/server | TCP/IP [Message Framing](https://web.archive.org/web/20230219220947/https://blog.stephencleary.com/2009/04/message-framing.html) | SSL client/server | -| UDP client/server | TCP/UDP performance improvement | Add documentation and samples for SSL | +> Netly docs ([HERE](https://netly.docs.kezero.com)) - -## Dependency -- ##### [Byter](https://github.com/alec1o/byter) - +##### Install -## Build -- ### Build dependencies - ###### [Git](http://git-scm.com/) - ###### [MONO](http://mono-project.com) or [.NET](http://dot.net) - -- ### Build step-by-step -```rb -# 1. clone repository -$ git clone "https://github.com/alec1o/netly.git" +> Official publisher -# 2. open source directory -$ cd netly/ +| Nuget | Unity Asset Store | +|--------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| Install on [Nuget](https://www.nuget.org/packages/Netly) | Install on [Asset Store ](https://assetstore.unity.com/packages/tools/network/225473) | -# 5. restore dotnet project -$ dotnet restore -# 6. build dotnet project -$ dotnet build -``` - +##### Sponsor and Supporter -## List of tested platforms -- ###### [.NET](https://dotnet.microsoft.com) (SDK) -- ###### [Mono](https://mono-project.com) (SDK) -- ###### [Unity](https://unity.com) (Engine) +> Well, this project is open source and only development can be supported by suggestions for improvements, bug +> reports or the like. (for those who want to financially support this resource is not available at this time) - - -## Demo -```rb -messageFraming: just set this to false if you want to use netly to communicate with another tcp library. -true case: this will improve data security, but both client and server must have the same configuration. -``` -- ### Client - _Instance_ - ```csharp - using Netly; - using Netly.Core; +##### Versions + +> Notable changes + +| v1 (old) | v2 (old) | v3 (stable) | v4 (nonexistent) | +|---------------------|----------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------|---------------------------------| +| TCP (client/server) | TCP/IP [Message Framing](https://web.archive.org/web/20230219220947/https://blog.stephencleary.com/2009/04/message-framing.html) | TLS/SSL (client/server) | Websocket (client/server) | +| UDP | TCP/UDP performance improvement | Include docs/sample (SSL/TLS) | Include docs/sample (Websocket) | +| | | ``Message Framing`` memory and performance improve | | +| | | ``Message Framing`` new protocol | | +| | | ``UDP`` impl connection with udp (ping/timeout) | | +| | | collaborative documentation ``docsify`` | | +| | | Byter ``2.0`` | | + + + +##### List of tested platforms + +- [.NET](https://dotnet.microsoft.com) (SDK) +- [Mono](https://mono-project.com) (SDK) +- [Unity](https://unity.com) (Engine) + + + +##### Feature + +> Below are some missing features that are planned to be added in later versions. + +- Websocket (v4) + + +##### Dependency + +- [Byter](https://github.com/alec1o/Byter) + + +##### Build - // Example udp client instance - var client = new UdpClient(); +> ###### Build dependencies - // Example tcp client instance - var client = new TcpClient(messageFraming: true); +- [Git](http://git-scm.com/) +- [.NET](http://dot.net) - // Example host instance - var host = new Host("127.0.0.1", 3000); +> ###### Build step-by-step + + ```php + # 1. clone repository + $ git clone "https://github.com/alec1o/netly" netly/ + + # 2. build netly project + $ dotnet build -C Release netly/ + # DLL_PATH: netly/src/bin/netstandard2.0/Netly.dll + + # 3. For use Netly.dll you need Byter.dll (a Netly dependecy) + $ git clone "https://github.com/alec1o/byter" byter/ + + # 4. build byter project + $ dotnet build -C Release byter/ + # DLL_PATH: byter/src/bin/netstandard2.0/Byter.dll + + # WARNING: when use Netly.dll must include Byter.dll ``` - _Usage_ + + +##### Demo + +> TcpClient ``Syntax`` + ```csharp - client.OnOpen(() => + using Netly; + using Netly.Core; + + var client = new TcpClient(framing: true); + + // Enable SSL/TLS (onValidate delegate is optional) + client.UseEncryption(enableEncryption: true, onValidate: null); + + client.OnOpen(() => { - // connection opened + // client connected }); - + client.OnClose(() => { - // connection closed + // client disconnected }); - - client.OnError((exception) => - { - // error on open connection + + client.OnError((Exception exception) => + { + // connection close because: 1.Error on connecting, 2.Invalid framing data }); - - client.OnData((data) => + + client.OnData((byte[] data) => { - // buffer/data received + // raw data received }); - - client.OnEvent((name, data) => + + client.OnEvent((string name, byte[] data) => { - // event received: {name: event name} {data: buffer/data received} + // event received (event use netly protocol) }); + + client.OnModify((Socket socket) => + { + // you can modify socket, called before open connection + }); + + client.Open(new Host("127.0.0.1", 8080)); + ``` - // open connection - client.Open(host); - - // send data - client.ToData(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9}); - - // send event - client.ToEvent("name", new byte[] { 1, 2, 3, 4, 5, 6}); +> TcpServer ``Syntax`` - // close connection - client.Close(); - ``` -- ### Server - _Instance_ ```csharp using Netly; using Netly.Core; - - // Example tcp server instance - var server = new TcpServer(messageFraming: true); - - // Example udp server instance - var server = new UdpServer(); - - // Example host instance - var host = new Host("0.0.0.0", 3000); - ``` - _Usage_ - ```csharp - server.OnOpen(() => + + var server = new TcpServer(framing: true); + + // Enable SSL/TLS + byte[] pfxCert = ; + string pfxPass = ; + + server.UseEncryption(pfxCert, pfxPass, SslProtocols.Tls13); // TLS v1.3 + + server.OnOpen(() => { - // connection opened: server start listen client + // server start listen }); - + server.OnClose(() => { - // connection closed: server stop listen client + // server stop listen }); - - server.OnError((exception) => + + server.OnError((Exception exception) => { - // error on open connection + // error on start listen (connecting) }); - - server.OnEnter((client) => + + server.OnData((TcpClient client, byte[] data) => { - // client connected: connection accepted + // a client receive raw data }); - - server.OnExit((client) => + + server.OnEvent((TcpClient client, string name, byte[] data) => { - // client disconnected: connection closed + // a client receive event (event use netly protocol) }); - - server.OnData((client, data) => + + server.OnEnter((TcpClient client) => { - // buffer/data received: {client: client instance} {data: buffer/data received} + // a client connected on server + + client.OnClose(() => + { + // alternative of: TcpServer.OnClose + }); + + client.OnData(() => + { + // alternative of: TcpServer.OnData + }); + + client.OnEvent(() => + { + // alternative of: TcpServer.OnEvent + }); }); - - server.OnEvent((client, name, data) => + + server.OnExit((TcpClient client) => { - // event received: {client: client instance} {name: event name} {data: buffer received} + // a client disconnected from server }); - - // open connection - server.Open(host); - - // broadcast data to clients - server.ToData(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9}); - - // broadcast event to clients - server.ToEvent("name", new byte[] { 1, 2, 3, 4, 5, 6}); - - // close connection - server.Close(); + + server.OnModify((Socket socket) => + { + // you can modify socket, called before listen and bind a port + }); + + server.Open(new Host("127.0.0.1", 8080)); ``` - - -## Currently missing feature -> Below are some missing features that are planned to be added in later versions. - -- [ ] [SslClient and SslServer] Tcp protocol with SSL/TLS encryption.