RTCMultiConnection icon indicating copy to clipboard operation
RTCMultiConnection copied to clipboard

'Userid already taken' in `connection.onUserIdAlreadyTaken`

Open ghost opened this issue 6 years ago • 4 comments

"Userid already taken" After a short Internet disconnect, the user cannot join the room - is a big problem. The function connection.onUserIdAlreadyTaken from the RTCMultiConnection.js library generates a new userID and tries join to the room:

connection.onUserIdAlreadyTaken = function(useridAlreadyTaken, yourNewUserId) {
	if (connection.enableLogs) {
		console.warn('Userid already taken.', useridAlreadyTaken, 'Your new userid:', yourNewUserId);
	}
	connection.userid = connection.token();
	connection.join(connection.sessionid);
};

But in a short time, the Signaling-Server.js server does not know that this user needs to be disabled, because Join does not work and the user does not connect.

I propose a solution

In my case, it helps if connection.onUserIdAlreadyTaken closes a socket before connection.join:

connection.close ();
connection.closeSocket ();

Then, after connecting the Internet, the server will disconnect the user and after that the user will be able to join the room.

connection.onUserIdAlreadyTaken = function(useridAlreadyTaken, yourNewUserId) {
	if (connection.enableLogs) {
		console.warn('Userid already taken.', useridAlreadyTaken, 'Your new userid:', yourNewUserId);
	}

	connection.close (); 
	connection.closeSocket (); 

	connection.userid = connection.token();
	connection.join(connection.sessionid);
};

ghost avatar Nov 21 '18 10:11 ghost

closing socket is making problem

webleb avatar Mar 27 '22 21:03 webleb

does anyone have alternative solution?

webleb avatar Mar 27 '22 21:03 webleb

@grimace @grimace @muaz-khan @dansandland

webleb avatar Mar 27 '22 21:03 webleb

"Userid already taken" After a short Internet disconnect, the user cannot join the room - is a big problem. The function connection.onUserIdAlreadyTaken from the RTCMultiConnection.js library generates a new userID and tries join to the room:

connection.onUserIdAlreadyTaken = function(useridAlreadyTaken, yourNewUserId) {
	if (connection.enableLogs) {
		console.warn('Userid already taken.', useridAlreadyTaken, 'Your new userid:', yourNewUserId);
	}
	connection.userid = connection.token();
	connection.join(connection.sessionid);
};

But in a short time, the Signaling-Server.js server does not know that this user needs to be disabled, because Join does not work and the user does not connect.

I propose a solution

In my case, it helps if connection.onUserIdAlreadyTaken closes a socket before connection.join:

connection.close ();
connection.closeSocket ();

Then, after connecting the Internet, the server will disconnect the user and after that the user will be able to join the room.

connection.onUserIdAlreadyTaken = function(useridAlreadyTaken, yourNewUserId) {
	if (connection.enableLogs) {
		console.warn('Userid already taken.', useridAlreadyTaken, 'Your new userid:', yourNewUserId);
	}

	connection.close (); 
	connection.closeSocket (); 

	connection.userid = connection.token();
	connection.join(connection.sessionid);
};

closing socket is making problem

webleb avatar Mar 27 '22 21:03 webleb