forked from cory/tildefriends
Fix one lingering call to ssb.connectionSendJson.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4129 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -90,7 +90,6 @@ bool tf_ssb_whoami(tf_ssb_t* ssb, char* out_id, size_t out_id_size);
|
||||
|
||||
void tf_ssb_visit_broadcasts(tf_ssb_t* ssb, void (*callback)(const char* host, const struct sockaddr_in* addr, tf_ssb_connection_t* tunnel, const uint8_t* pub, void* user_data), void* user_data);
|
||||
|
||||
tf_ssb_connection_t* tf_ssb_get_connection(tf_ssb_t* ssb, const char* id);
|
||||
const char** tf_ssb_get_connection_ids(tf_ssb_t* ssb);
|
||||
int tf_ssb_get_connections(tf_ssb_t* ssb, tf_ssb_connection_t** out_connections, int out_connections_count);
|
||||
void tf_ssb_connect(tf_ssb_t* ssb, const char* host, int port, const uint8_t* key);
|
||||
|
33
src/ssb.js.c
33
src/ssb.js.c
@ -698,15 +698,38 @@ static JSValue _tf_ssb_hmacsha256_verify(JSContext* context, JSValueConst this_v
|
||||
|
||||
static JSValue _tf_ssb_createTunnel(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
|
||||
{
|
||||
JSValue result = JS_UNDEFINED;
|
||||
tf_ssb_t* ssb = JS_GetOpaque(this_val, _tf_ssb_classId);
|
||||
const char* portal_id = JS_ToCString(context, argv[0]);
|
||||
int32_t request_number = 0;
|
||||
JS_ToInt32(context, &request_number, argv[1]);
|
||||
const char* target_id = JS_ToCString(context, argv[2]);
|
||||
tf_ssb_connection_tunnel_create(ssb, portal_id, request_number, target_id);
|
||||
const char* target_id = JS_ToCString(context, argv[1]);
|
||||
|
||||
tf_ssb_connection_t* connection = tf_ssb_connection_get(ssb, portal_id);
|
||||
if (connection)
|
||||
{
|
||||
// let request_number = await tfrpc.rpc.connectionSendJson(portal, {name: ['tunnel', 'connect'], args: [{portal: portal, target: target}], type: 'duplex'});
|
||||
int32_t request_number = tf_ssb_connection_next_request_number(connection);
|
||||
JSValue message = JS_NewObject(context);
|
||||
JSValue name = JS_NewArray(context);
|
||||
JS_SetPropertyUint32(context, name, 0, JS_NewString(context, "tunnel"));
|
||||
JS_SetPropertyUint32(context, name, 1, JS_NewString(context, "connect"));
|
||||
JS_SetPropertyStr(context, message, "name", name);
|
||||
JSValue arg = JS_NewObject(context);
|
||||
JS_SetPropertyStr(context, arg, "portal", JS_NewString(context, portal_id));
|
||||
JS_SetPropertyStr(context, arg, "target", JS_NewString(context, target_id));
|
||||
JSValue args = JS_NewArray(context);
|
||||
JS_SetPropertyUint32(context, args, 0, arg);
|
||||
JS_SetPropertyStr(context, message, "args", args);
|
||||
JS_SetPropertyStr(context, message, "type", JS_NewString(context, "duplex"));
|
||||
tf_ssb_connection_rpc_send_json(connection, k_ssb_rpc_flag_stream, request_number, message, NULL, NULL, NULL);
|
||||
JS_FreeValue(context, message);
|
||||
|
||||
tf_ssb_connection_tunnel_create(ssb, portal_id, request_number, target_id);
|
||||
result = JS_TRUE;
|
||||
}
|
||||
|
||||
JS_FreeCString(context, target_id);
|
||||
JS_FreeCString(context, portal_id);
|
||||
return JS_UNDEFINED;
|
||||
return result;
|
||||
}
|
||||
|
||||
static JSValue _tf_ssb_followingDeep(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
|
||||
|
Reference in New Issue
Block a user