Jump to content
Mumble forums

Mumble plugin sendData


LilyC
 Share

Recommended Posts

I am trying to use the Mumble API along with the Mumble JSON Bridge CLI to send a message to another user running Mumble and the JSON bridge plugin. Currently I am trying to use the sendData function, though I am curious if this is the correct approach or if there is another way to accomplish this.

 

Regardless if it's the correct approach or not, I have a few questions about how the sendData function is meant to work with the Mumble JSON Bridge CLI. Following the examples in the readme, I tried sending data like:

{
    "message_type": "api_call",
    "message": {
        "function": "sendData",
        "parameter": {
            "connection": 0,
            "receivers": ["userID1", "userID2"],
            "data": [1],
            "data_id": "1"
        }
    }
}

 

This parses correctly, but causes an error which kills the pipe (I am assuming this happens because the plugin crashes?).

 

I am not sure what the data or dataID should be or if this is causing issue. I know the documentation mentions the data is a sequence of bytes, but when I tried sending a sequence of bytes in the CLI call, it gave me a parsing error. I am also not sure what the dataID should be.

Link to comment
Share on other sites

  • Administrators

Let me address your topics in reverse:

On 11/17/2021 at 4:16 PM, LilyC said:

I know the documentation mentions the data is a sequence of bytes, but when I tried sending a sequence of bytes in the CLI call, it gave me a parsing error.

How did you try to send a "sequence of bytes" via JSON? Afaik JSON does not have the concept of bytes. I guess the corresponding type to use in JSON would be a string (where the string represents the "sequence of bytes").

 

As a sidenote: When working with the JSON API, you can orient yourself at the API functions as defined here: https://github.com/mumble-voip/mumble-plugin-cpp/blob/8b6f41f39e428b4a15d4a02c7df82b8174cff95b/include/mumble/plugin/MumbleAPI.h

 

On 11/17/2021 at 4:16 PM, LilyC said:

This parses correctly, but causes an error which kills the pipe (I am assuming this happens because the plugin crashes?).

Hm, that sounds a bit odd... Does Mumble crash with it? If not, then its probably not the plugin that crashes but rather the CLI itself. Is there any kind of output that you are getting or any kind of backtrace (did you try running it through a debugger?)?

 

On 11/17/2021 at 4:16 PM, LilyC said:

how the sendData function is meant to work with the Mumble JSON Bridge CLI

I guess not at all. Sending stuff out should work (or rather: should be possible to get to work) but receiving data would require the JSON bridge to be able to pass events along (thus it would require a connection in the other direction (Mumble -> outside world) as well). However, this is currently not supported, so even if you get to send the data out, I don't think it would currently be possible to receive that via the JSON API.

 

 

In general the sendData process works like this:

  • Plugin loaded by client A sends a sequence of bytes (the "payload") along with an ID to client B
  • Once client B receives the message, it iterates over all currently loaded plugins to tell them that a message was reveived
  • Each of these plugins is supposed to look at the ID in order to figure out whether or not the message is directed at it. Therefore the ID would usually be prefixed by that plugin's name or another identifier that it will be able to recognize
  • If the ID is found to be known, it can then interpret the message payload in the appropriate way (it is supposed to know the binary format of that byte sequence (e.g. is it a string or a fixed binary format to encode some other information)
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...