desc
This commit is contained in:
@@ -15,3 +15,9 @@ DB_DATABASE=callDB
|
||||
DB_USERNAME=callDbUser
|
||||
DB_PASSWORD=replace_with_db_password
|
||||
|
||||
# Coturn TURN server settings
|
||||
TURN_URL=turn:turn.intaleqapp.com:3478
|
||||
TURN_USERNAME=intaleq_call_user
|
||||
TURN_CREDENTIAL=intaleq_call_password_secret
|
||||
|
||||
|
||||
|
||||
@@ -42,4 +42,7 @@ export const config = {
|
||||
dbDatabase: process.env.DB_DATABASE || 'callDB',
|
||||
dbUsername: process.env.DB_USERNAME || '',
|
||||
dbPassword: process.env.DB_PASSWORD || '',
|
||||
turnUrl: process.env.TURN_URL || '',
|
||||
turnUsername: process.env.TURN_USERNAME || '',
|
||||
turnCredential: process.env.TURN_CREDENTIAL || '',
|
||||
};
|
||||
|
||||
@@ -33,7 +33,7 @@ export const ErrPayloadTooLarge = 'payload_too_large';
|
||||
export const ErrRateLimited = 'rate_limited';
|
||||
|
||||
// Helper constructors for encoding server messages
|
||||
export const newAuthenticated = (userID) => JSON.stringify({ type: TypeAuthenticated, user_id: userID });
|
||||
export const newAuthenticated = (userID, iceServers) => JSON.stringify({ type: TypeAuthenticated, user_id: userID, ice_servers: iceServers });
|
||||
export const newSessionCreated = (sessionID, rideID, expiresIn) => JSON.stringify({ type: TypeSessionCreated, session_id: sessionID, ride_id: rideID, expires_in: expiresIn });
|
||||
export const newSessionJoined = (sessionID, rideID) => JSON.stringify({ type: TypeSessionJoined, session_id: sessionID, ride_id: rideID });
|
||||
export const newParticipantJoined = (role) => JSON.stringify({ type: TypeParticipantJoined, role });
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { logger } from '../logger/logger.js';
|
||||
import * as protocol from '../protocol/messages.js';
|
||||
import { logSessionActive, logSessionInitiator, logSessionEnded } from '../db/db.js';
|
||||
import { config } from '../config/config.js';
|
||||
|
||||
/**
|
||||
* Hub is the central coordinator for all active call sessions and client sockets.
|
||||
@@ -303,8 +304,26 @@ export class Hub {
|
||||
remote_ip: connectionIP
|
||||
});
|
||||
|
||||
// Confirm successful authentication to the client
|
||||
client.send(protocol.newAuthenticated(client.userID));
|
||||
// Prepare ICE servers configuration dynamically
|
||||
const iceServers = [
|
||||
{ urls: 'stun:stun.l.google.com:19302' },
|
||||
{ urls: 'stun:stun1.l.google.com:19302' }
|
||||
];
|
||||
if (config.turnUrl) {
|
||||
iceServers.push({
|
||||
urls: `${config.turnUrl}?transport=udp`,
|
||||
username: config.turnUsername,
|
||||
credential: config.turnCredential
|
||||
});
|
||||
iceServers.push({
|
||||
urls: `${config.turnUrl}?transport=tcp`,
|
||||
username: config.turnUsername,
|
||||
credential: config.turnCredential
|
||||
});
|
||||
}
|
||||
|
||||
// Confirm successful authentication to the client with the dynamic ICE servers configuration
|
||||
client.send(protocol.newAuthenticated(client.userID, iceServers));
|
||||
|
||||
// Trigger WebRTC active session joined if both are connected
|
||||
if (sess.driverConn && sess.passengerConn) {
|
||||
|
||||
Reference in New Issue
Block a user