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 30666618f8ac1d068bdabca5b899e74e232d93a1
parent e4d87b72a0334579c096c3cc22bf0514d24dd9f9
Author: Joris Vink <joris@coders.se>
Date:   Mon, 30 Jan 2017 22:00:03 +0100

expose kore_websocket_send() to python.

Diffstat:
includes/python_methods.h | 2++
src/python.c | 20++++++++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/includes/python_methods.h b/includes/python_methods.h @@ -15,6 +15,7 @@ */ static PyObject *python_exported_log(PyObject *, PyObject *); +static PyObject *python_websocket_send(PyObject *, PyObject *); static PyObject *python_websocket_broadcast(PyObject *, PyObject *); #define METHOD(n, c, a) { n, (PyCFunction)c, a, NULL } @@ -24,6 +25,7 @@ static PyObject *python_websocket_broadcast(PyObject *, PyObject *); static struct PyMethodDef pykore_methods[] = { METHOD("log", python_exported_log, METH_VARARGS), + METHOD("websocket_send", python_websocket_send, METH_VARARGS), METHOD("websocket_broadcast", python_websocket_broadcast, METH_VARARGS), { NULL, NULL, 0, NULL } }; diff --git a/src/python.c b/src/python.c @@ -774,6 +774,26 @@ python_websocket_broadcast(PyObject *self, PyObject *args) } static PyObject * +python_websocket_send(PyObject *self, PyObject *args) +{ + int op; + struct pyconnection *pyc; + Py_buffer data; + + if (!PyArg_ParseTuple(args, "O!iy*", + &pyconnection_type, &pyc, &op, &data)) { + PyErr_SetString(PyExc_TypeError, "invalid parameters"); + return (NULL); + } + + + kore_websocket_send(pyc->c, op, data.buf, data.len); + PyBuffer_Release(&data); + + Py_RETURN_TRUE; +} + +static PyObject * pyhttp_get_host(struct pyhttp_request *pyreq, void *closure) { PyObject *host;