Squashed commit of the following:

commit dd00d53895b824fbe4170c4a34b104303f722ccd
Merge: 2b3698e cb9ea12
Author: Robin Linus <robin_woll@capira.de>
Date:   Wed Feb 10 00:27:32 2016 -0600

    Merge branch 'name-device' into merge123

    # Conflicts:
    #	app/elements/buddy-finder/buddy-avatar.html
    #	app/elements/buddy-finder/buddy-finder.html
    #	app/elements/buddy-finder/personal-avatar.html
    #	app/index.html

commit cb9ea1235001f0cc23514cb622ce711cdc0538af
Author: Robin Linus <robin_woll@capira.de>
Date:   Tue Feb 9 23:43:49 2016 -0600

    #13 Feature Request: Name your device

commit 6fa43b56f4e705a19e68b62bc671a4948b6968fb
Author: Robin Linus <robin_woll@capira.de>
Date:   Fri Jan 1 19:54:56 2016 +0100

    Initial

commit fc55c86f5cf95039355d85be7409e68f27246696
Author: Robin Linus <robin_woll@capira.de>
Date:   Fri Jan 1 18:06:27 2016 +0100

    Fix fullscreen layout on iOS
This commit is contained in:
Robin Linus 2016-02-10 08:58:09 -06:00
parent 2b3698ece0
commit e66598d77f
8 changed files with 210 additions and 16 deletions

View file

@ -47,11 +47,11 @@ exports.create = function(server) {
}
// Wait for new user connections
bs.on('connection', function(client) {
//console.log('connection received!', client._socket.upgradeReq.connection.remoteAddress);
client.uuidRaw = guid();
//ip is hashed to prevent injections by spoofing the 'x-forwarded-for' header
client.hashedIp = hash(getIP(client._socket));
client.hashedIp = 1;
// client.hashedIp = hash(getIP(client._socket));
client.deviceName = getDeviceName(client._socket.upgradeReq);
@ -62,10 +62,20 @@ exports.create = function(server) {
client.send({
isSystemEvent: true,
type: 'handshake',
name: client.deviceName,
uuid: client.uuid
});
return;
}
if (meta && meta.serverMsg === 'device-name') {
//max name length = 40
if (meta.name && meta.name.length > 40) {
return;
}
client.name = meta.name;
return;
}
meta.from = client.uuid;
// broadcast to the other client
@ -104,7 +114,8 @@ exports.create = function(server) {
socket: client,
contact: {
peerId: client.uuid,
name: client.deviceName,
name: client.name || client.deviceName,
device: client.name ? client.deviceName : undefined
}
});
});
@ -129,6 +140,7 @@ exports.create = function(server) {
isSystemEvent: true,
type: 'buddies'
};
//send only if state changed
if (currState !== socket.lastState) {
socket.send(msg);
socket.lastState = currState;