Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Mapping of IDataChannels

Discussion in 'Unity Render Streaming' started by cp-, Feb 24, 2023.

  1. cp-

    cp-

    Joined:
    Mar 29, 2018
    Posts:
    78
    Hi @kazuki_unity729 , I got a question regarding the mapping of IDataChannels. I saw this part here:

    Code (CSharp):
    1. /// todo(kazuki)::
    2. public void OnAddChannel(SignalingEventData data)
    3. {
    4.     var obj = dictObj[data.connectionId];
    5.     var channels = obj.GetComponentsInChildren<IDataChannel>();
    6.     var channel = channels.FirstOrDefault(_ => !_.IsLocal && !_.IsConnected);
    7.     channel?.SetChannel(data);
    8. }
    The comment tells me it's not really complete :)

    So I wonder how would it work if I have more than one IDataChannel per connection. Like in the Multiplay example: There's one channel for input and the additional one, MultiplayChannel (latter does not seem to be used in the current sample though).

    Does the js-client have to keep a particular order for the channels to be mapped correctly? Or would this need additional logic and is not yet possible?

    Cheers
     
  2. cp-

    cp-

    Joined:
    Mar 29, 2018
    Posts:
    78
    Ok, after some tinkering I think it's safe to say that, yes, in the current implementation the mapping is done solely based on the order the channels are registered (on both sides).

    But there's also the
    data.channel.label
    on Unity's side which gets set in JS, e.g. for the input channel by calling
    renderstreaming.createDataChannel("input");


    I guess this is intended for exactly this. Matching the channels based on a magic string:
    Code (CSharp):
    1. var channel = channels.FirstOrDefault(_ => _.Label == data.channel.Label && !_.IsLocal && !_.IsConnected);
     
  3. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    We have a plan to implement that determining the component of receiver side using labels but we haven't started the development yet.