From 637664d95ad5e2ad72b91998dc4685bf0fe6cdeb Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 17 Mar 2014 18:26:56 +0100 Subject: command, lua: change script_message semantics Change script_message to broadcast the message to all clients. Add a new script_message_to command, which does what the old script_message command did. This is intended as simplification, although it might lead to chaos too. --- player/client.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'player/client.c') diff --git a/player/client.c b/player/client.c index 675410893d..42d2fb2bb8 100644 --- a/player/client.c +++ b/player/client.c @@ -339,6 +339,7 @@ static void status_reply(struct mpv_handle *ctx, int event, } // set ev->data to a new copy of the original data +// (done only for message types that are broadcast) static void dup_event_data(struct mpv_event *ev) { switch (ev->event_id) { @@ -346,6 +347,17 @@ static void dup_event_data(struct mpv_event *ev) case MPV_EVENT_UNPAUSE: ev->data = talloc_memdup(NULL, ev->data, sizeof(mpv_event_pause_reason)); break; + case MPV_EVENT_CLIENT_MESSAGE: { + struct mpv_event_client_message *src = ev->data; + struct mpv_event_client_message *msg = + talloc_zero(NULL, struct mpv_event_client_message); + for (int n = 0; n < src->num_args; n++) { + MP_TARRAY_APPEND(msg, msg->args, msg->num_args, + talloc_strdup(msg, src->args[n])); + } + ev->data = msg; + break; + } default: // Doesn't use events with memory allocation. if (ev->data) -- cgit v1.2.3