commit 7bc8bb42e21391a7da15f65bed8bcdd5249d5a36
parent 5485967547ddc8d6839512a5c3cceafc57d0cb76
Author: Joris Vink <joris@coders.se>
Date: Mon, 30 Jan 2017 20:30:42 +0100
implement kore_websockat_broadcast.
Diffstat:
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/examples/python/src/websockets.py b/examples/python/src/websockets.py
@@ -6,7 +6,6 @@ def onconnect(c):
kore.log(kore.LOG_INFO, "%s: py connected" % c)
def onmessage(c, op, data):
- kore.log(kore.LOG_INFO, "%s: got message" % c)
kore.websocket_broadcast(c, op, data, kore.WEBSOCKET_BROADCAST_GLOBAL)
def ondisconnect(c):
diff --git a/src/python.c b/src/python.c
@@ -742,7 +742,18 @@ pyhttp_websocket_handshake(struct pyhttp_request *pyreq, PyObject *args)
static PyObject *
python_websocket_broadcast(PyObject *self, PyObject *args)
{
- printf("websocket_broadcast\n");
+ struct pyconnection *pyc;
+ Py_buffer data;
+ int op, broadcast;
+
+ if (!PyArg_ParseTuple(args, "O!iy*i",
+ &pyconnection_type, &pyc, &op, &data, &broadcast)) {
+ PyErr_SetString(PyExc_TypeError, "invalid parameters");
+ return (NULL);
+ }
+
+ kore_websocket_broadcast(pyc->c, op, data.buf, data.len, broadcast);
+ PyBuffer_Release(&data);
Py_RETURN_TRUE;
}