Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How I can make a simple custom transport layer of Netcode of gameobject?

Discussion in 'Game Server Hosting' started by sompod44, Nov 2, 2023.

  1. sompod44

    sompod44

    Joined:
    Nov 2, 2018
    Posts:
    3
    To understand the custom transport layer. I created one as a test class.
    And I added that script with NetworkManager just to check the mechanism of working custom transport. But I just noticed that PullEvent only calling. Now my question is why the Send Override method was not called.
    Which crucial part I am missing? Please save my life.


    Screenshot 2023-11-01 030023.png Screenshot 2023-11-01 030159.png
     
  2. sompod44

    sompod44

    Joined:
    Nov 2, 2018
    Posts:
    3
    I got this reply in the discord channel. And that is definitely helped me a lot.
    [
    A NetworkTransport implementation returns information to NGO through network events. Those are returned by PullEvent or by calling InvokeOnTransportEvent from anywhere in the transport (typically its Update method). There are three types of events: Connect (to inform when a new connection is established), Disconnect (to inform that a connection was closed), and Data (to inform of the arrival of a new data message). Before NGO will send anything, it needs an active connection on which to send it on. This means it must first be informed of a new connection through a Connect event. Generally StartClient will start the process of establishing a new connection and once that's done, a Connect event will be emitted. For servers, you usually passively listen for new connections and once one is made, you generate a Connect event too. Before that, NGO will never call the Send method. I'd suggest looking at existing NetworkTransport implementations if you want more details of how this all works. Many implementations are provided by the community here: https://github.com/Unity-Technologies/multiplayer-community-contributions/tree/main/Transports
    ]