Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

LLAPI: description for NetworkTransport.SendMulticast/ StartSendMulticast/FinishSendMulticast please

Discussion in 'Multiplayer' started by spacefrog, May 24, 2017.

  1. spacefrog

    spacefrog

    Joined:
    Jun 14, 2009
    Posts:
    734
    I got to send the same data from one host to many clients as often as possible and wanted to use multicast for this
    The UNET LLAPI/Network transport documentation about multicast is as sparse and unsatisfying as can be. There are also no samples to be found about the NetworkTransport's Multicast methods

    https://docs.unity3d.com/ScriptReference/Networking.NetworkTransport.SendMulticast.html
    Add a connection for the multicast send.

    https://docs.unity3d.com/ScriptReference/Networking.NetworkTransport.StartSendMulticast.html
    Start to multicast send.

    https://docs.unity3d.com/ScriptReference/Networking.NetworkTransport.FinishSendMulticast.html
    Finalizes sending of a message to a group of connections. Only one multicast message at a time is allowed per host.

    Are those methods officially supported ?

    Could anyone give me a headstart how those three functions are supposed to be used ? Including sample code maybe ? This would'nt need to cover general usage of the NetworkTransport API, as this i already understand...
    Thanks ...
     
    donnysobonny likes this.
  2. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    220
    +1 would love clarification on this too. I currently resort to making individual Send() calls to each client from the server-side when I need to send a message to all clients. Would be good it multicasting worked if it made things more efficient...
     
  3. TomPo

    TomPo

    Joined:
    Nov 30, 2013
    Posts:
    86
    +1 as well.
    Right now is like looping the list and sending a message one by one. Documentation is poor.
    Same way as QoS f.g. (Un)ReliableFragmented. How to use it ?
     
  4. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    220
    @TomPo The *Fragmented channels are simply used to send large messages.

    Say for example your maxPacket is 1440. If you were to try and Send() a message on a non-fragmented channel which is larger than your maxPacket size UNET will throw up an error telling you that you can't do that. If however you send a message lager than your maxPacket on a fragmented channel, the message is split up into smaller chunks and then re-assembled on the other end.

    You basically use it in cases where you want to send thousands of bytes in a single message (for example, when a player connects and you have to send them loads of data about the objects in the game etc)
     
  5. TomPo

    TomPo

    Joined:
    Nov 30, 2013
    Posts:
    86
    thank you for the reply. So have two more questions regarding this.
    Is this done automatically ?
    sending/reading implementations is someway different or it's done as standard data event ?
     
  6. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    220
    I'm not actually 100% sure because i've never tested that, but I would assume that it's not. If you are thinking though to use a fragmented channel for everything just be sure that all messages get transmitted (big or small) this would be a very bad idea. There is added overhead in the buffering, sorting and other things that need to happen to send and receive fragmented messages so you should only send fragmented messages when you know that you need to.

    As far as using the API is concerned, it's simply a case of changing the channel that you're using to a fragmented one. The fragmentation on the sending-end and de-fragmentation on the receiving end happens under-the-hood.