forked from cory/tildefriends
Use tf_ssb_connection_rpc_send_json everywhere I can. Less code, and fixes some leaks.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4122 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
28
src/ssb.js.c
28
src/ssb.js.c
@ -709,33 +709,6 @@ static JSValue _tf_ssb_createTunnel(JSContext* context, JSValueConst this_val, i
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
||||
static JSValue _tf_ssb_connectionSendJson(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
|
||||
{
|
||||
tf_ssb_t* ssb = JS_GetOpaque(this_val, _tf_ssb_classId);
|
||||
const char* connection_id = JS_ToCString(context, argv[0]);
|
||||
tf_ssb_connection_t* connection = tf_ssb_connection_get(ssb, connection_id);
|
||||
|
||||
JSValue message_val = JS_JSONStringify(context, argv[1], JS_NULL, JS_NULL);
|
||||
size_t size;
|
||||
const char* message = JS_ToCStringLen(context, &size, message_val);
|
||||
|
||||
uint32_t request_number = tf_ssb_connection_next_request_number(connection);
|
||||
|
||||
tf_ssb_connection_rpc_send(
|
||||
connection,
|
||||
k_ssb_rpc_flag_json | k_ssb_rpc_flag_stream,
|
||||
request_number,
|
||||
(const uint8_t*)message,
|
||||
size,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
JS_FreeCString(context, connection_id);
|
||||
JS_FreeCString(context, message);
|
||||
JS_FreeValue(context, message_val);
|
||||
return JS_NewInt32(context, request_number);
|
||||
}
|
||||
|
||||
static JSValue _tf_ssb_followingDeep(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
|
||||
{
|
||||
int depth = 2;
|
||||
@ -807,7 +780,6 @@ void tf_ssb_register(JSContext* context, tf_ssb_t* ssb)
|
||||
JS_SetPropertyStr(context, object, "messageContentGet", JS_NewCFunction(context, _tf_ssb_messageContentGet, "messageContentGet", 1));
|
||||
JS_SetPropertyStr(context, object, "connections", JS_NewCFunction(context, _tf_ssb_connections, "connections", 0));
|
||||
JS_SetPropertyStr(context, object, "getConnection", JS_NewCFunction(context, _tf_ssb_getConnection, "getConnection", 1));
|
||||
JS_SetPropertyStr(context, object, "connectionSendJson", JS_NewCFunction(context, _tf_ssb_connectionSendJson, "connectionSendJson", 2));
|
||||
JS_SetPropertyStr(context, object, "closeConnection", JS_NewCFunction(context, _tf_ssb_closeConnection, "closeConnection", 1));
|
||||
JS_SetPropertyStr(context, object, "sqlStream", JS_NewCFunction(context, _tf_ssb_sqlStream, "sqlStream", 3));
|
||||
JS_SetPropertyStr(context, object, "storeMessage", JS_NewCFunction(context, _tf_ssb_storeMessage, "storeMessage", 1));
|
||||
|
Reference in New Issue
Block a user