Compare commits

..

2 Commits

Author SHA1 Message Date
Derrick Hammer 402508ca64
*rename handlers to match naming scheme 2023-04-15 03:58:53 -04:00
Derrick Hammer ba38f7670f
*Add api method to create swarms 2023-04-15 03:57:34 -04:00
1 changed files with 9 additions and 4 deletions

View File

@ -75,12 +75,13 @@ addHandler("socketListenEvent", handleSocketListenEvent, {
}); });
addHandler("socketWrite", handleWriteSocketEvent); addHandler("socketWrite", handleWriteSocketEvent);
addHandler("socketClose", handleCloseSocketEvent); addHandler("socketClose", handleCloseSocketEvent);
addHandler("createProtomuxChannel", createProtomuxChannel, { addHandler("createProtomuxChannel", handleCreateProtomuxChannel, {
receiveUpdates: true, receiveUpdates: true,
}); });
addHandler("createProtomuxMessage", createProtomuxMessage, { addHandler("createProtomuxMessage", handleCreateProtomuxMessage, {
receiveUpdates: true, receiveUpdates: true,
}); });
addHandler("createSwarm", handleCreateSwarm);
async function handlePresentSeed(aq: ActiveQuery) { async function handlePresentSeed(aq: ActiveQuery) {
const pubkey = await ed.getPublicKey(aq.callerInput.rootKey); const pubkey = await ed.getPublicKey(aq.callerInput.rootKey);
@ -425,7 +426,7 @@ async function handleGetSocketInfo(aq: ActiveQuery) {
}); });
} }
async function createProtomuxChannel(aq: ActiveQuery) { async function handleCreateProtomuxChannel(aq: ActiveQuery) {
const socket = validateConnection(aq); const socket = validateConnection(aq);
if (!socket) { if (!socket) {
@ -488,7 +489,7 @@ async function createProtomuxChannel(aq: ActiveQuery) {
aq.sendUpdate(channelId); aq.sendUpdate(channelId);
} }
async function createProtomuxMessage(aq: ActiveQuery) { async function handleCreateProtomuxMessage(aq: ActiveQuery) {
const socket = validateConnection(aq); const socket = validateConnection(aq);
if (!socket) { if (!socket) {
@ -589,6 +590,10 @@ async function createProtomuxMessage(aq: ActiveQuery) {
}); });
} }
async function handleCreateSwarm(aq: ActiveQuery) {
aq.respond(await createSwarm());
}
function getSwarmToSocketConnectionId(socket: any) { function getSwarmToSocketConnectionId(socket: any) {
for (const conn of connections) { for (const conn of connections) {
if (conn[1].conn === socket) { if (conn[1].conn === socket) {