From 39ddca9751d84a1c80da7db09e5c02df6cee96f8 Mon Sep 17 00:00:00 2001 From: "Stephen R. van den Berg" <srb@cuci.nl> Date: Sat, 24 Sep 2016 23:43:03 +0200 Subject: [PATCH] SocketIO: Use variant to enforce compile-time checks. --- lib/modules/Protocols.pmod/SocketIO.pmod | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/modules/Protocols.pmod/SocketIO.pmod b/lib/modules/Protocols.pmod/SocketIO.pmod index 74c23f28bd..fbae8017c2 100644 --- a/lib/modules/Protocols.pmod/SocketIO.pmod +++ b/lib/modules/Protocols.pmod/SocketIO.pmod @@ -267,11 +267,12 @@ class Client { } //! Send text or binary events. - final void emit(string|function(mixed, mixed ...:void) ack_cb, - mixed ... data) { - if (!stringp(ack_cb) || !stringp(data[0])) - DUSERERROR("Event must be of type string."); - write(ack_cb, @data); + final variant void emit(function(mixed, mixed ...:void) ack_cb, + string event, mixed ... data) { + write(ack_cb, event, @data); + } + final variant void emit(string event, mixed ... data) { + write(event, @data); } private void send(int type, void|string|array data, -- GitLab