Cleanup and handling of events.
parent
0299e5f661
commit
38cf88aa62
|
|
@ -305,7 +305,7 @@ export default class RoomClient
|
||||||
|
|
||||||
login()
|
login()
|
||||||
{
|
{
|
||||||
const url = `/auth/login?id=${this._signalingSocket.io.engine.id}`;
|
const url = `/auth/login?id=${this._signalingSocket.io.engine.id}&roomId=${this._roomId}&peerId=${this._peerId}`;
|
||||||
|
|
||||||
this._loginWindow = window.open(url, 'loginWindow');
|
this._loginWindow = window.open(url, 'loginWindow');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,32 +34,6 @@ class Lobby extends EventEmitter
|
||||||
this._peers = {};
|
this._peers = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
authCallback(data, roomLocked)
|
|
||||||
{
|
|
||||||
logger.debug('authCallback() | [data:"%o", roomLocked:"%s"]', data, roomLocked);
|
|
||||||
|
|
||||||
const {
|
|
||||||
peerId,
|
|
||||||
displayName,
|
|
||||||
picture
|
|
||||||
} = data;
|
|
||||||
|
|
||||||
const peer = this._peers[peerId];
|
|
||||||
|
|
||||||
if (peer)
|
|
||||||
{
|
|
||||||
this._notification(peer.socket, 'auth', {
|
|
||||||
displayName : displayName,
|
|
||||||
picture : picture
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!roomLocked)
|
|
||||||
{
|
|
||||||
this.promotePeer(peerId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
peerList()
|
peerList()
|
||||||
{
|
{
|
||||||
logger.info('peerList()');
|
logger.info('peerList()');
|
||||||
|
|
|
||||||
|
|
@ -179,9 +179,9 @@ class Room extends EventEmitter
|
||||||
logStatus()
|
logStatus()
|
||||||
{
|
{
|
||||||
logger.info(
|
logger.info(
|
||||||
'logStatus() [room id:"%s", peers:%s]',
|
'logStatus() [room id:"%s", peers:%o]',
|
||||||
this._roomId,
|
this._roomId,
|
||||||
this._peers.size
|
this._peers
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,28 +241,16 @@ class Room extends EventEmitter
|
||||||
return this._locked;
|
return this._locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
authCallback(data)
|
peerAuthenticated(peerid)
|
||||||
{
|
{
|
||||||
logger.debug('authCallback()');
|
logger.debug('peerAuthenticated() | [peerId:"%s"]', peerId);
|
||||||
|
|
||||||
const {
|
if (!this._locked)
|
||||||
peerId,
|
|
||||||
displayName,
|
|
||||||
picture
|
|
||||||
} = data;
|
|
||||||
|
|
||||||
const peer = this._peers[peerId];
|
|
||||||
|
|
||||||
if (peer)
|
|
||||||
{
|
{
|
||||||
this._notification(peer.socket, 'auth', {
|
if (!Boolean(this._peers[peerid]))
|
||||||
displayName : displayName,
|
{
|
||||||
picture : picture
|
this._lobby.promotePeer(peerId);
|
||||||
});
|
}
|
||||||
}
|
|
||||||
else if (this._lobby.hasPeer(peerId))
|
|
||||||
{
|
|
||||||
this._lobby.authCallback(data, this._locked);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -215,8 +215,10 @@ async function setupAuth(oidcIssuer)
|
||||||
{
|
{
|
||||||
passport.authenticate('oidc', {
|
passport.authenticate('oidc', {
|
||||||
state : base64.encode(JSON.stringify({
|
state : base64.encode(JSON.stringify({
|
||||||
id : req.query.id,
|
id : req.query.id,
|
||||||
code : utils.random(10)
|
roomId : req.query.roomId,
|
||||||
|
peerId : req.query.peerId,
|
||||||
|
code : utils.random(10)
|
||||||
}))
|
}))
|
||||||
})(req, res, next);
|
})(req, res, next);
|
||||||
});
|
});
|
||||||
|
|
@ -256,7 +258,9 @@ async function setupAuth(oidcIssuer)
|
||||||
photo = '/static/media/buddy.403cb9f6.svg';
|
photo = '/static/media/buddy.403cb9f6.svg';
|
||||||
}
|
}
|
||||||
|
|
||||||
// const room = rooms.get(state.roomId);
|
const room = rooms.get(state.roomId);
|
||||||
|
|
||||||
|
room.peerAuthenticated(state.peerId);
|
||||||
|
|
||||||
io.sockets.socket(state.id).emit('notification',
|
io.sockets.socket(state.id).emit('notification',
|
||||||
{
|
{
|
||||||
|
|
@ -315,7 +319,7 @@ async function runHttpsServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a protoo WebSocketServer to allow WebSocket connections from browsers.
|
* Create a WebSocketServer to allow WebSocket connections from browsers.
|
||||||
*/
|
*/
|
||||||
async function runWebSocketServer()
|
async function runWebSocketServer()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue