Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New docs website #63

Open
alec1o opened this issue Sep 14, 2024 · 4 comments
Open

New docs website #63

alec1o opened this issue Sep 14, 2024 · 4 comments
Labels
Solved Question/Ask solved.

Comments

@alec1o
Copy link
Owner

alec1o commented Sep 14, 2024

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

Screenshot 2024-09-14 214329
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

image

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

@alec1o alec1o self-assigned this Sep 14, 2024
@alec1o alec1o added the Review label Sep 14, 2024
@alec1o alec1o pinned this issue Sep 14, 2024
@alec1o alec1o added the Solved Question/Ask solved. label Oct 7, 2024
@alec1o alec1o removed the Review label Dec 9, 2024
@1101728133
Copy link

When will version 4.0 be ready

@alec1o alec1o removed their assignment Dec 28, 2024
@alec1o
Copy link
Owner Author

alec1o commented Dec 28, 2024

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.

@Drethek
Copy link

Drethek commented Jan 11, 2025

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

@alec1o
Copy link
Owner Author

alec1o commented Jan 11, 2025

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):

public static (string name, byte[] data) Verify(byte[] buffer)
{
using (var r = new Reader(buffer))
{
var key = r.Read<string>(Encoding.ASCII);
var name = r.Read<string>(Encoding.UTF8);
var data = r.Read<byte[]>();
if (r.Success && key is ProtocolKey) return (name, data);
return (null, null);
}
}
public static byte[] Create(string name, byte[] data)
{
using (var w = new Writer())
{
w.Write(ProtocolKey, Encoding.ASCII);
w.Write(name, Encoding.UTF8);
w.Write(data);
return w.GetBytes();
}
}

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Solved Question/Ask solved.
Projects
None yet
Development

No branches or pull requests

3 participants