Merge pull request #10 from amhsirak/develop

feat: pass `socket` to RB input handler
This commit is contained in:
amhsirak
2024-06-08 23:13:41 +05:30
committed by GitHub

View File

@@ -1,5 +1,6 @@
import {Namespace, Socket} from 'socket.io'; import { Namespace, Socket } from 'socket.io';
import logger from "../logger"; import logger from "../logger";
import registerInputHandlers from '../browser-management/inputHandlers'
/** /**
* Opens a websocket canal for duplex data transfer and registers all handlers for this data for the recording session. * Opens a websocket canal for duplex data transfer and registers all handlers for this data for the recording session.
@@ -11,9 +12,10 @@ import logger from "../logger";
export const createSocketConnection = ( export const createSocketConnection = (
io: Namespace, io: Namespace,
callback: (socket: Socket) => void, callback: (socket: Socket) => void,
) => { ) => {
const onConnection = async (socket: Socket) => { const onConnection = async (socket: Socket) => {
logger.log('info',"Client connected " + socket.id); logger.log('info', "Client connected " + socket.id);
registerInputHandlers(socket);
socket.on('disconnect', () => logger.log('info', "Client disconnected " + socket.id)); socket.on('disconnect', () => logger.log('info', "Client disconnected " + socket.id));
callback(socket); callback(socket);
} }
@@ -29,11 +31,11 @@ export const createSocketConnection = (
* @category BrowserManagement * @category BrowserManagement
*/ */
export const createSocketConnectionForRun = ( export const createSocketConnectionForRun = (
io: Namespace, io: Namespace,
callback: (socket: Socket) => void, callback: (socket: Socket) => void,
) => { ) => {
const onConnection = async (socket: Socket) => { const onConnection = async (socket: Socket) => {
logger.log('info',"Client connected " + socket.id); logger.log('info', "Client connected " + socket.id);
socket.on('disconnect', () => logger.log('info', "Client disconnected " + socket.id)); socket.on('disconnect', () => logger.log('info', "Client disconnected " + socket.id));
callback(socket); callback(socket);
} }