Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Question Send data related to an event

Discussion in 'Unity Transport' started by Sabbaga, Nov 7, 2022.

  1. Sabbaga

    Sabbaga

    Joined:
    Sep 24, 2021
    Posts:
    2
    I'm writing a custom server-client network library with the transport package to use in my projects. When i'm sending data, the first byte is always an operation id. I have some ids that are related to events such us client connected to server=> receive assigned id, disconnected from server=> reason, and so on. Is there a way to make these custom events related to the popevent so i can eliminate the need of "internal operation id".

    And as a possible feature request, when calling driver.connect(endpoint), a connection internal id could become the same as the one from the other side, for exemple, a client connection id could become the same as the respective server connection id.
     
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    150
    So, if I understand correctly, you would like to be able to specify extra data for
    Connect
    and
    Disconnect
    events? If that's the case, then unfortunately that's not possible currently. We have discussed adding this in the past, but since the requirements could vary greatly from user to user, we erred on the side of minimalism and letting people build this themselves.

    If you are certain that say a
    Connect
    event will always be followed by a certain operation ID, then you could write a wrapper for
    PopEvent
    (could even be an extension method to
    NetworkDriver
    ) that swallows the original
    Connect
    event, and then re-emits it when that certain operation ID is received, along with any additional data that the operation carries.

    Regarding having the same connection IDs server-side and client-side, I understand how this could be useful, but that is not something that we are likely to offer as a feature. For performance reasons, our connection IDs are basically indices into internal data structures, which makes them hard to share across instances. It would also require us to break the protocol used to establish connections (old clients could not connect to new servers, and vice versa), which is not something we wish to do anymore at this point.
     
  3. Sabbaga

    Sabbaga

    Joined:
    Sep 24, 2021
    Posts:
    2
    I understand, i will keep things as they are, thank you for the respons.