kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit f78e8f2fd2e3118b01f49431aa95767de134d3b2
parent 6a43dd529c529fae196e822352ef3687bbb7811a
Author: Joris Vink <joris@coders.se>
Date:   Mon, 30 Jan 2017 21:48:58 +0100

allow None as source for kore.websocket_broadcast.

This allows kore.websocket_broadcast() to be used to relay the
messages back to all clients rather then all except the sender.

Diffstat:
src/python.c | 18+++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/python.c b/src/python.c @@ -744,17 +744,29 @@ pyhttp_websocket_handshake(struct pyhttp_request *pyreq, PyObject *args) static PyObject * python_websocket_broadcast(PyObject *self, PyObject *args) { + struct connection *c; struct pyconnection *pyc; Py_buffer data; + PyObject *pysrc; int op, broadcast; - if (!PyArg_ParseTuple(args, "O!iy*i", - &pyconnection_type, &pyc, &op, &data, &broadcast)) { + if (!PyArg_ParseTuple(args, "Oiy*i", &pysrc, &op, &data, &broadcast)) { PyErr_SetString(PyExc_TypeError, "invalid parameters"); return (NULL); } - kore_websocket_broadcast(pyc->c, op, data.buf, data.len, broadcast); + if (pysrc == Py_None) { + c = NULL; + } else { + if (!PyObject_TypeCheck(pysrc, &pyconnection_type)) { + PyErr_SetString(PyExc_TypeError, "invalid parameters"); + return (NULL); + } + pyc = (struct pyconnection *)pysrc; + c = pyc->c; + } + + kore_websocket_broadcast(c, op, data.buf, data.len, broadcast); PyBuffer_Release(&data); Py_RETURN_TRUE;