geldata / geldata/gel-editor-plugin

im haveing trouble deleteing an extra 'const createPool = edged.createPool'

Open
#29 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
37
Forks
10
PR merge metrics
No merged PRs in 30d

Description

whenever i delete the 2nd 'const createPool = edged.createPool' it breaks my code any advice on how to fix it? im only haveing it send call logs to the database

`const { createPool } = require('edgedb');

if (!crypto.timingSafeEqual(calculatedTag, authTag)) {
throw new Error('Message authentication failed');
}

class RtcSignalingService extends Service {
constructor(options) {
super(options);
this.sessions = {};
}

async create(data, params) {
const { sessionId, offer } = data;
const { user } = params;
this.sessions[sessionId] = {
caller: user._id,
startTime: new Date(), //record the start time
};

if (!this.sessions[sessionId]) {
this.sessions[sessionId] = { caller: user._id };
} else {
this.sessions[sessionId].callee = user._id;
}

const session = this.sessions[sessionId];
const otherUserId = session.caller === user._id ? session.callee : session.caller;

this.app.channel(`user/${otherUserId}`).send({
event: 'offer',
offer,
from: user._id,
sessionId,
});

return { sessionId };
}

async patch(id, data, params) {
const { sessionId, answer } = data;
const { user } = params;

const session = this.sessions[sessionId];
const otherUserId = session.caller === user._id ? session.callee : session.caller;

this.app.channel(`user/${otherUserId}`).send({
event: 'answer',
answer,
from: user._id,
sessionId,
});

return {};
}

async remove(id, params) {
const { sessionId } = params.query;
const session = this.sessions[sessionId];
await this.insertCallRecord(
sessionId,
session.caller,
session.callee,
session.startTime,
new Date() //Record the end time
);
delete this.sessions[sessionId];
return {};
}

async insertCallRecord(sessionId, callerId, calleeId, startTime, endTime) {
const query = `
INSERT Call {
sessionId := $sessionId,
caller := (SELECT User FILTER .id = $callerId),
callee := (SELECT User FILTER .id = $calleeId),
startTime := $startTime,
endTime := $endTime,
}
`;
const connectionPool = createPool({
host: process.env.HOST,
port: process.env.PORT,
user: process.env.ADMIN,
password: process.env.PASSWORD,
database: process.env.VOICE_LOGS
});
await connectionPool.query(query, {
sessionId,
callerId,
calleeId,
startTime,
endTime,
});
}
}

module.exports = function(app) {
app.use('/rtc-signaling', new RtcSignalingService());
};

//on caller side
const session = this.sessions[sessionId];
const otherUserId = session.caller === user._id ? session.callee : session.caller;
const callerOffer = await pc.createOffer();
await pc.setLocalDescription(callerOffer);

//send the offer to the other party via signaling server
this.app.channel(`user/${otherUserId}`).send({
event: 'offer',
offer: callerOffer.toJSON(),
from: user._id,
sessionId,
});

// On the callee side:
const { from: incomingOtherUserId, sessionId } = data;
const calleeOffer = new RTCSessionDescription(data.offer);
await pc.setRemoteDescription(calleeOffer);
const answer = await pc.createAnswer();
await pc.setLocalDescription(answer);

//send the answer to the caller via the signaling server
this.app.channel(`user/${otherUserId}`).send({
event: 'answer',
answer: answer.toJSON(),
from: user._id,
sessionId,
});

const createPool = edged.createPool
![calllogs](https://user-images.githubusercontent.com/88816813/237032223-59ee2f09-21dc-42c1-977c-83d8c9237ac7.png)
`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.