adrenak / univoice

Voice chat/VoIP solution for unity.
http://www.vatsalambastha.com/univoice
MIT License
363 stars 36 forks source link

Is there a way for user data transmission? #25

Closed zeroone-ved closed 5 months ago

zeroone-ved commented 1 year ago

I want to transfer some basic user data(eg. alias, description) after entering the room, is there a way to do that, or what should I do? Data might be changed during the room lifecycle(user also might enter or leave the room), everyone should be notified with the newest data.

adrenak commented 1 year ago

Hi @zeroone-ved there's no API for this currently, but this would be a great enhancement. Currently UniVoice only has APIs related to audio and chat members:

public event Action OnCreatedChatroom;
public event Action<Exception> OnChatroomCreationFailed;
public event Action OnClosedChatroom;

public event Action<short> OnJoinedChatroom;
public event Action<Exception> OnChatroomJoinFailed;
public event Action OnLeftChatroom; 

public event Action<short> OnPeerJoinedChatroom;
public event Action<short> OnPeerLeftChatroom;

public event Action<short, ChatroomAudioSegment> OnAudioReceived;
public event Action<short, ChatroomAudioSegment> OnAudioSent;

Data like what you've described will currently have to be transmitted via the underlying network you're using.

zeroone-ved commented 1 year ago

Hi @adrenak I've just posted a commit to make synchronization between peers available. I also extend the interface of IChatroomNetwork, which might cause errors in the 3rd implementation, so that I leave it in my local.

Maybe I'll create another pull request after all is ready, or someone could just do it simply like this:

public interface IChatroomNetwork : IDisposable {
    event Action<short, string> OnCommonDataReceived;
    event Action<short, string> OnCommonDataSent;

    void SendCommonData(short peerID, string data);
}