mirror of
https://github.com/jorisvink/kore
synced 2025-03-10 04:59:02 -04:00
expose kore_websocket_send() to python.
This commit is contained in:
parent
e4d87b72a0
commit
30666618f8
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static PyObject *python_exported_log(PyObject *, PyObject *);
|
static PyObject *python_exported_log(PyObject *, PyObject *);
|
||||||
|
static PyObject *python_websocket_send(PyObject *, PyObject *);
|
||||||
static PyObject *python_websocket_broadcast(PyObject *, PyObject *);
|
static PyObject *python_websocket_broadcast(PyObject *, PyObject *);
|
||||||
|
|
||||||
#define METHOD(n, c, a) { n, (PyCFunction)c, a, NULL }
|
#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[] = {
|
static struct PyMethodDef pykore_methods[] = {
|
||||||
METHOD("log", python_exported_log, METH_VARARGS),
|
METHOD("log", python_exported_log, METH_VARARGS),
|
||||||
|
METHOD("websocket_send", python_websocket_send, METH_VARARGS),
|
||||||
METHOD("websocket_broadcast", python_websocket_broadcast, METH_VARARGS),
|
METHOD("websocket_broadcast", python_websocket_broadcast, METH_VARARGS),
|
||||||
{ NULL, NULL, 0, NULL }
|
{ NULL, NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
|
20
src/python.c
20
src/python.c
@ -773,6 +773,26 @@ python_websocket_broadcast(PyObject *self, PyObject *args)
|
|||||||
Py_RETURN_TRUE;
|
Py_RETURN_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 *
|
static PyObject *
|
||||||
pyhttp_get_host(struct pyhttp_request *pyreq, void *closure)
|
pyhttp_get_host(struct pyhttp_request *pyreq, void *closure)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user