mumble-voip / mumble

Mumble is an open-source, low-latency, high quality voice chat software.
https://www.mumble.info
Other
6.36k stars 1.12k forks source link

Create a custom function for Ice #6004

Closed Neloy262 closed 1 year ago

Neloy262 commented 1 year ago

The issue

I would like to create a custom function in the mumble server and invoke it using Ice. How would I be able to do it?

Mumble version

1.4.0

Mumble component

Server

OS

Linux

Additional information

No response

Krzmbrzl commented 1 year ago

The general process is documented at https://github.com/mumble-voip/mumble/blob/master/docs/dev/ExtendingTheIceInterface.md

The first step obviously is to add the function to the MumbleServer.ice file. After that you should be able to follow the instructions in the linked document.

Let me know if you have further questions

Neloy262 commented 1 year ago

Following the doc I created a simple function that just prints to the console. The code for the impl function is as follows:

static void impl_Server_helloIce(const ::MumbleServer::AMD_Server_helloIcePtr &cb, const ::Ice::Current &current){

    int server_id = u8(current.id.name).toInt();
    std::cout<<"HELLO ICE --------------"<<server_id<<std::endl;
    cb->ice_response();
}

After building I am getting the following error: error: invalid initialization of reference of type ‘const Ice::Current&’ from expression of type ‘int’

this is the part of the code where the error is pointing

ExecEvent *ie = new ExecEvent(boost::bind(&impl_Server_helloIce, cb, QString::fromStdString(current.id.name).toInt()));
Krzmbrzl commented 1 year ago

What is the full error message?

Neloy262 commented 1 year ago
/usr/bin/c++ -DDEBUG -DICE_STATIC_LIBS -DMUMBLE_BUILD_YEAR=2023 -DMUMBLE_TARGET_ARCH=\"x64\" -DMUMBLE_TARGET_OS=\"linux\" -DMUMBLE_VERSION=1.5.0 -DMUMBLE_VERSION_MAJOR=1 -DMUMBLE_VERSION_MINOR=5 -DMUMBLE_VERSION_PATCH=0 -DMURMUR -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_NETWORK_LIB -DQT_RESTRICTED_CAST_FROM_ASCII -DQT_SQL_LIB -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS -DQT_XML_LIB -DSNAPSHOT_BUILD -DTRACY_ON_DEMAND -DUSE_DBUS -DUSE_ICE -DUSE_QSSLDIFFIEHELLMANPARAMETERS -DUSE_ZEROCONF -D_USE_MATH_DEFINES -I"/media/nybsysml/New Volume/Niloy/sentra_dev/mumble-source-code/cmake-build-debug/src/murmur/mumble-server_autogen/include" -I"/media/nybsysml/New Volume/Niloy/sentra_dev/mumble-source-code/src/murmur" -I"/media/nybsysml/New Volume/Niloy/sentra_dev/mumble-source-code/src" -I/usr/include/avahi-compat-libdns_sd -I"/media/nybsysml/New Volume/Niloy/sentra_dev/mumble-source-code/3rdparty/qqbonjour" -I"/media/nybsysml/New Volume/Niloy/sentra_dev/mumble-source-code/cmake-build-debug/src/murmur" -I"/media/nybsysml/New Volume/Niloy/sentra_dev/mumble-source-code/cmake-build-debug/src" -isystem /home/nybsysml/.local/include -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -isystem /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtXml -isystem "/media/nybsysml/New Volume/Niloy/sentra_dev/mumble-source-code/3rdparty/tracy" -isystem "/media/nybsysml/New Volume/Niloy/sentra_dev/mumble-source-code/3rdparty/gsl/include" -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql -isystem /usr/include/x86_64-linux-gnu/qt5/QtDBus -g -fPIE -fvisibility=hidden -Wall -Wextra -Werror -U_FORTIFY_SOURCE -fstack-protector -fPIC -std=gnu++14 -MD -MT src/murmur/CMakeFiles/mumble-server.dir/MumbleServerIce.cpp.o -MF src/murmur/CMakeFiles/mumble-server.dir/MumbleServerIce.cpp.o.d -o src/murmur/CMakeFiles/mumble-server.dir/MumbleServerIce.cpp.o -c '/media/nybsysml/New Volume/Niloy/sentra_dev/mumble-source-code/src/murmur/MumbleServerIce.cpp'
In file included from /media/nybsysml/New Volume/Niloy/sentra_dev/mumble-source-code/cmake-build-debug/src/murmur/MumbleServerIceWrapper.cpp:3,
                 from /media/nybsysml/New Volume/Niloy/sentra_dev/mumble-source-code/src/murmur/MumbleServerIce.cpp:2013:
/usr/include/boost/bind/bind.hpp: In instantiation of ‘void boost::_bi::list2<A1, A2>::operator()(boost::_bi::type<void>, F&, A&, int) [with F = void (*)(const IceUtil::Handle<MumbleServer::AMD_Server_helloIce>&, const Ice::Current&); A = boost::_bi::list0; A1 = boost::_bi::value<IceUtil::Handle<MumbleServer::AMD_Server_helloIce> >; A2 = boost::_bi::value<int>]’:
/usr/include/boost/bind/bind.hpp:1294:50:   required from ‘boost::_bi::bind_t<R, F, L>::result_type boost::_bi::bind_t<R, F, L>::operator()() [with R = void; F = void (*)(const IceUtil::Handle<MumbleServer::AMD_Server_helloIce>&, const Ice::Current&); L = boost::_bi::list2<boost::_bi::value<IceUtil::Handle<MumbleServer::AMD_Server_helloIce> >, boost::_bi::value<int> >; boost::_bi::bind_t<R, F, L>::result_type = void]’
/usr/include/boost/function/function_template.hpp:158:11:   required from ‘static void boost::detail::function::void_function_obj_invoker0<FunctionObj, R>::invoke(boost::detail::function::function_buffer&) [with FunctionObj = boost::_bi::bind_t<void, void (*)(const IceUtil::Handle<MumbleServer::AMD_Server_helloIce>&, const Ice::Current&), boost::_bi::list2<boost::_bi::value<IceUtil::Handle<MumbleServer::AMD_Server_helloIce> >, boost::_bi::value<int> > >; R = void]’
/usr/include/boost/function/function_template.hpp:931:38:   required from ‘void boost::function0<R>::assign_to(Functor) [with Functor = boost::_bi::bind_t<void, void (*)(const IceUtil::Handle<MumbleServer::AMD_Server_helloIce>&, const Ice::Current&), boost::_bi::list2<boost::_bi::value<IceUtil::Handle<MumbleServer::AMD_Server_helloIce> >, boost::_bi::value<int> > >; R = void]’
/usr/include/boost/function/function_template.hpp:720:7:   required from ‘boost::function0<R>::function0(Functor, typename boost::enable_if_<(! boost::is_integral<Functor>::value), int>::type) [with Functor = boost::_bi::bind_t<void, void (*)(const IceUtil::Handle<MumbleServer::AMD_Server_helloIce>&, const Ice::Current&), boost::_bi::list2<boost::_bi::value<IceUtil::Handle<MumbleServer::AMD_Server_helloIce> >, boost::_bi::value<int> > >; R = void; typename boost::enable_if_<(! boost::is_integral<Functor>::value), int>::type = int]’
/usr/include/boost/function/function_template.hpp:1068:16:   required from ‘boost::function<R()>::function(Functor, typename boost::enable_if_<(! boost::is_integral<Functor>::value), int>::type) [with Functor = boost::_bi::bind_t<void, void (*)(const IceUtil::Handle<MumbleServer::AMD_Server_helloIce>&, const Ice::Current&), boost::_bi::list2<boost::_bi::value<IceUtil::Handle<MumbleServer::AMD_Server_helloIce> >, boost::_bi::value<int> > >; R = void; typename boost::enable_if_<(! boost::is_integral<Functor>::value), int>::type = int]’
/media/nybsysml/New Volume/Niloy/sentra_dev/mumble-source-code/cmake-build-debug/src/murmur/MumbleServerIceWrapper.cpp:97:119:   required from here
/usr/include/boost/bind/bind.hpp:319:35: error: invalid initialization of reference of type ‘const Ice::Current&’ from expression of type ‘int’
  319 |         unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
Krzmbrzl commented 1 year ago

MumbleServerIceWrapper.cpp:97:119

This is an auto-generated file that can be found in your build folder (under src/murmur). I assume this is related to how you obtain the server ID.

Why are you not using a plain int for the server ID in the first place? That seems to be what every other function does 👀

Neloy262 commented 1 year ago

I did it like that just to utilize the current function argument.

Neloy262 commented 1 year ago

The auto-generated function declaration contained const ::Ice::Current &current as a parameter.

Krzmbrzl commented 1 year ago

Do you have the source code available somewhere? I have the feeling it won't work in this remote debugging kind of way. I have to see the entire project in order to comment on this.

Neloy262 commented 1 year ago

github link: https://github.com/Neloy262/Mumble

please check the debug branch.

the *impl function is implemented inside MumbleServerIce.cpp line 1976

Krzmbrzl commented 1 year ago

Alright - have a look at https://github.com/Neloy262/Mumble/blob/6127ab2730af6ea326e81b1943afbcc8941b1175/src/murmur/MumbleServerIce.cpp#L896 which. There you can see that the server ID is simply passed in as a plain int parameter.

All functions taking a Ice::Current argument, at first glance, appear to be more or less "internal" function that don't show up in the ice file.

If you look closer, the conversion from the current argument into the plain integer is performed in the auto-generated MumbleServerIceWrapper.cpp file where it creates the ExecEvent instance.

Neloy262 commented 1 year ago

Thanks, this solved my problem.