Networking server

Hi,
I want to build my own networking server but still leverage the messaging functions provided by Needle Networking. Specifically, I’m interested in accessing the underlying code or protocols that handle messaging within Needle Networking so I can implement the same messaging system while extending the functionality for my own purposes.

Additionally, I plan to implement this in .NET to integrate it into the rest of my system. Could I get access to the code or documentation that explains how Needle handles messaging, and would it be possible to extend or modify that system for custom use cases?

Hi Vydymil,

To build your own networking server while leveraging the messaging functions provided by Needle Networking, you can access the core networking functionality through the this.context.connection object available in your components.

The essential messaging functions are implemented using WebSocket connections and support both JSON and FlatBuffers for data transmission. Here’s a brief overview of how you can extend the messaging system:

  1. Sending Messages:

    • Use the send method to transmit messages:
      this.context.connection.send(key: string, data: IModel | object | boolean | string | number | null);
      
    • For binary data, use:
      this.context.connection.sendBinary(arr: Uint8Array);
      
  2. Receiving Messages:

    • To listen for messages, use:
      this.context.connection.beginListen(key: string, callback: (data) => void);
      
    • For binary messages:
      this.context.connection.beginListenBinary(identifier: string, callback: (data: ByteBuffer) => void);
      
  3. Connection Management:

    • You can manage user states and room events, such as joining or leaving, using specific event types defined in the program:
      this.context.beginListen(RoomEvents.JoinedRoom, () => { });
      

To implement this in .NET, you may want to translate these structures into C# equivalents. You can generate matching C# “stub components” that will interface with your networking logic.

For further details on the available networking methods and custom behaviors, you can refer to the documentation (see networking).

If you need help with specific parts of the implementation or connecting it to your .NET system, let me know!

3 replies left
thread_vG0S6ElFLm2a61MubeLxu6F2
Reply to this message to continue the conversation

So, basically, I’m trying to figure out the message types and transmission structures Needle uses for networking. I’m sticking with Needle on the client side, but for the backend, I want to run my own C# server because we already have an event-driven system in place. The node implementation you suggest doesn’t really work for us, and I don’t want to mess around with proxy sniffing to reverse-engineer the messages either. I already went through the documentation, and didn’t find this stuff. Maybe I can describe it more closely in DM.

Hi, we don’t have the code for the networking server publicly available and because of that no public documentation for the internal server available either.

Would you mind describing a bit more about your usecase via hi@needle.tools?

Okay, will do.