Set socketUser data from frontend

This commit is contained in:
calzoneman 2015-12-30 21:57:46 -08:00
parent 5b44117681
commit 9a262da13d
2 changed files with 9 additions and 2 deletions

View file

@ -19,11 +19,12 @@ export default class FrontendManager {
socket.on('SocketFrameEvent', this.onSocketFrame.bind(this, socket)); socket.on('SocketFrameEvent', this.onSocketFrame.bind(this, socket));
} }
onSocketConnect(frontendConnection, socketID, socketIP) { onSocketConnect(frontendConnection, socketID, socketIP, socketUser) {
const mapKey = frontendConnection.endpoint; const mapKey = frontendConnection.endpoint;
const proxiedSocket = new ProxiedSocket( const proxiedSocket = new ProxiedSocket(
socketID, socketID,
socketIP, socketIP,
socketUser,
this.socketEmitter, this.socketEmitter,
frontendConnection); frontendConnection);

View file

@ -1,11 +1,17 @@
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
export default class ProxiedSocket extends EventEmitter { export default class ProxiedSocket extends EventEmitter {
constructor(socketID, socketIP, socketEmitter, frontendConnection) { constructor(socketID, socketIP, socketUser, socketEmitter, frontendConnection) {
super(); super();
this.id = socketID; this.id = socketID;
this.ip = socketIP; this.ip = socketIP;
this._realip = socketIP; this._realip = socketIP;
if (socketUser) {
this.user = {
name: socketUser.name,
global_rank: socketUser.globalRank
};
}
this.socketEmitter = socketEmitter; this.socketEmitter = socketEmitter;
this.frontendConnection = frontendConnection; this.frontendConnection = frontendConnection;
} }