<commit_before>var router = require('../lib/socket').Router();
var users = require('../lib/users');

// connection event with no data passed
router.add(function () {
    var ready = true, s = this.request.session;
    if (s.user) {
        console.log(s.user.name + ' connected.');
        if (s.user.openSocket !== this.id) {
            if (s.user.openSocket) {
                router.getIO().sockets.connected[s.user.openSocket]
                    .emit('disconnected', this.id);
                ready = false;
            }
            s.user.openSocket = this.id;
            users.updateSocket(s.user, this.id);
        }
    }
    else {
        console.log('Guest connected.');
    }
    if (ready) this.emit('ready');
});

module.exports = router;<commit_msg>[Fix] Stream connect<commit_after>var router = require('../lib/socket').Router();
var users = require('../lib/users');

// connection event with no data passed
router.add(function () {
    var other = false, ready = true, s = this.request.session;
    if (s.user) {
        console.log(s.user.name + ' connected.');
        if (s.user.openSocket !== this.id) {
            if (s.user.openSocket) {
                other = router.getIO().sockets.connected[s.user.openSocket];
                if (other) {
                    other.emit('disconnected', this.id);
                    ready = false;
                }
            }
            s.user.openSocket = this.id;
            users.updateSocket(s.user, this.id);
        }
    }
    else {
        console.log('Guest connected.');
    }
    if (ready) this.emit('ready');
});

module.exports = router;
{'fraction_non_alphanumeric': 0.15876923076923077, 'fraction_numerical': 0.0, 'mean_word_length': 1.8229166666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3352466', 'n_tokens_mistral': 486, 'n_tokens_neox': 477, 'n_words': 94}