Netly
Netly copied to clipboard
New docs website
Now [09/14/2024] netly.docs.kezero.com website is offline and not acessible, this reason that's why is going be hard deployment of new website version.
The new website version is working fine but Docusauros can't build it static because generated markdown conflict with docusauros (i don't know why). I tried deploy website on vercel, render.
New website
This website have included content of version 3.1.x api and manual, use drop down with
4.0.0 and select 3.1.0
Old website
Currently this website is working on render since of [09/18/2024], using Free version over Docker and Docs branch, Working at netly.docs.kezero.com
When will version 4.0 be ready
Netly 4.0 is almost ready. The only thing left is to perform unit tests for HTTP, RUDP, and WebSocket. While I’ve already found and fixed some bugs during personal usage, it’s essential to cover all possible use cases and validate behavior with automated tests.
The delay isn’t due to a lack of time but rather a lack of motivation. I want to ensure the version is stable and reliable before the official release. So, Netly 4.0 will be released as soon as all tests pass successfully.
Hi alec1o, first of all, thank you for the library! It's really handy and very clean, I'm having a great time using it. I was trying to establish a socket "link" with the Event method between:
Server (C#) <-> Client (Unity) Server (C#) <-> Client (Typescript)
The link between C# <> Unity works perfectly, everything is sent and received flawlessly (of course, it's the same library). But when it comes to Server <> Typescript, I have an issue. I can't find a way to send/receive events. Sending data seems to work, although I haven't tested it much since I prefer using the event method, but I can't find any way to send/receive events.
Would you be able to help me with this? Thanks again
Hi @Drethek,
Thanks for liking this library! <3
Regarding your question, sending and receiving events is quite straightforward. Essentially, you need to include some "prefix" bytes before your actual data to allow Netly to detect if your data is "normal (RAW)" or "custom (EVENT)".
Source (Event: Creation and Verification): https://github.com/alec1o/Netly/blob/ca15f401d1b9733da1efeac200139c0b5aa63416/src/netly/partials/NetlyEnvironment.EventManager.cs#L12-L36
For example, before sending a buffer via TCP, UDP, RUDP, etc., we create a new buffer using EventManager.Create(<event name>, <original buffer>). To receive the buffer, you must always try to detect if the current data is an event by checking the "prefix" added in EventManager.Create. Use EventManager.Verify(<buffer received>) to detect the prefix. If it matches, it will parse the data to detect the event name and event buffer. If there is an issue, it will return null, and the data will be submitted to RawDataReceived instead of EventReceived. In other words, all data that is not successfully parsed as an event is considered raw data.
Example usage:
using Byter;
using Netly;
// SEND
byte[] rawBuffer = "Hello World".GetBytes();
string eventName = "welcome";
// Note: (NetlyEnvironment) is available on v4.0.0 and later; older versions use (EventManager)
byte[] finalBuffer = NetlyEnvironment.EventManager.Create(eventName, rawBuffer);
// Socket.Send(finalBuffer)
// The final buffer is the data sent when using events.
// RECEIVE
byte[] rawReceivedBuffer = ...;
// Detect if the data is an event or not.
(string name, byte[] data) result = NetlyEnvironment.EventManager.Verify(rawReceivedBuffer);
if (result.data == null || result.data.Length <= 0)
{
Console.WriteLine($"RAW DATA RECEIVED: {rawReceivedBuffer.GetString()}");
}
else
{
Console.WriteLine($"EVENT RECEIVED ({result.name}): {result.data.GetString()}");
}
I believe if the .NET side sends an event, your TypeScript application might see it as "broken" (e.g., "Ny://" and broken words, after the event name and buffer if it is UTF-8 encoded).
If you encounter any issues while reimplementing EventManager on the TypeScript side, feel free to open an issue for assistance. Please share your TypeScript socket source so I can use it as a base to implement a seamless API for EventManager in TypeScript