BananaHemic / Mumble-Unity

Performant Mumble Client For Unity3D
MIT License
77 stars 29 forks source link

Add Channel to server from this client #43

Closed gildas22 closed 3 years ago

gildas22 commented 3 years ago

Hello, I would like to add/remove channels on the server form this client. I manage to do it to remove a channel by adding a new method and using "_tcpConnection.SendMessage(MessageType.ChannelRemove, channeltoremove);" (I am connected as SuperUser in order to have the rights.) But I can't manage to add a new channel. I have tried with a "MessageType.ChannelState" but I'am not sure if it is possible this way? Any advices if it should be possible or not? Thanks, Gildas

BananaHemic commented 3 years ago

Hmm, it's been a while since I've looked at that stuff, but I don't see any reason why adding a channel would fail when removing a channel works. Do you get any messages logged from murmur? It might be that the MumbleProto object wasn't fully initialized

gildas22 commented 3 years ago

Thanks for your fast reply. Unfortunately, I have no specific error/message from murmur. My doubts are that there is a specific "ChannelRemove" message, but there is no "ChannelAdd" message, and I was not sure that "ChannelState" message allows to create a new channel (only "update"?). I willl still look into it and let you know you if I find a solution.

gildas22 commented 3 years ago

Here the solution to create, remove and check channel availability. If you want I can make a pull request. I have also implemented a setPassword method to set a password on a channel but it requires to modify the mumble.cs (proto buf generated). I had to remove the "private" to set ACLChan. Let me know.

    /// <summary>
    /// Check if the channel already exist     
    /// </summary>
    /// <param name="channelName">The name of the channel you want to check</param>
    /// <returns>Whether channel exist</returns>
    public bool IsChannelAvailable(string channelName)
    {           
        return TryGetChannelByName(channelName,out _);
    }

    /// <summary>
    /// Create the channel on the server
    /// The user must have the admin rights
    /// </summary>
    /// <param name="channelName">The name of the channel you want to create</param>
    /// <param name="temporary">temporary Channel, it will be automatically removed when the last user quit</param>
    /// <param name="parent">parent of the new channel, 0=root</param>
    /// <param name="description">text descrption of the channel</param>
    /// <param name="maxusers">0=unlimited users</param>
    /// <returns>Whether adding channel was successful</returns>
    public bool CreateChannel(string channelName, bool temporary, uint parent, string description, uint maxusers)
    {
        if (OurUserState == null)
            return false;
        if (!ConnectionSetupFinished)
            return false;                                         

        ChannelState state = new ChannelState
        {          
            Name = channelName,
            Temporary = temporary,
            Parent = parent,   
            Description=description,
            MaxUsers=maxusers,
            Position=-1
        };

        _tcpConnection.SendMessage<MumbleProto.ChannelState>(MessageType.ChannelState, state);

        return true;
    }

    /// <summary>
    /// Destroy the channel on the server
    /// The user must have the admin rights
    /// </summary>
    /// <param name="channelName">The name of the channel you want to remove</param>      
    public void DestroyChannel(string channelName)
    {
        Channel channel;

        if (!TryGetChannelByName(channelName, out channel))
        {
            Debug.LogError("channel :" + channelName + " to remove not found!");
            return;
        }

        ChannelRemove channeltoremove = new ChannelRemove
        {
            ChannelId = channel.ChannelId
        };

        _tcpConnection.SendMessage<MumbleProto.ChannelRemove>(MessageType.ChannelRemove, channeltoremove);

        return;

    }
bdovaz commented 6 months ago

@BananaHemic @gildas22 when creating a channel I get this error:

Permission denied with fields Name: , Type: MissingCertificate, Reason:

Do you know why this might be?

From Unity I don't have any client certificate configured and I don't want to have them, I want the authentication to be simply with password.

Thanks!

BananaHemic commented 6 months ago

Hmm, I'm not sure. I vaguely recall experiencing something similar, but it's been a few years. I suspect that the issue is with the server configuration. The ACL might only allow users with a certificate registration to make channels.