<commit_before>/* jshint -W097 */// jshint strict:false
/*jslint node: true */
"use strict";

var express =           require('express');
var socketio =          require('socket.io');
var session;// =           require('express-session');
var cookieParser;// =      require('cookie-parser');
var bodyParser;// =        require('body-parser');
var AdapterStore;// =      require(__dirname + '/../../lib/session.js')(session);
var passportSocketIo;// =  require(__dirname + "/lib/passport.socketio.js");
var password;// =          require(__dirname + '/../../lib/password.js');
var passport;// =          require('passport');
var LocalStrategy;// =     require('passport-local').Strategy;
var flash;// =             require('connect-flash'); // TODO report error to user

var webServer =  null;
var store =      null;
var objects =    {};
var states =     {};
var secret =     '<KEY>'; // Will be generated by first start
var userKey =    'connect.sid';

var isAuthUsed = false;

var adapter = require(__dirname + '/../../lib/adapter.js')({
    name:           'admin',
    install: function (callback) {
        if (typeof callback === 'function') callback();
    },
    objectChange: function (id, obj) {
        objects[id] = obj;

        webServer.io.sockets.emit('objectChange', id, obj);
    },
    stateChange: function (id, state) {
        states[id] = state;
        webServer.io.sockets.emit('stateChange', id, state);
    },
    unload: function (callback) {
        try {
            adapter.log.info("terminating http" + (webServer.settings.secure ? "s" : "") + " server on port " + webServer.settings.port);
            webServer.server.close();

            callback();
        } catch (e) {
            callback();
        }
    },
    ready: function () {
        adapter.getForeignObject("system.adapter.admin", function (err, obj) {
            if (!err && obj) {
                if (!obj.native.secret) {
                    require('crypto').randomBytes(24, function(ex, buf) {
                        secret = buf.toString('hex');
                        adapter.extendForeignObject("system.adapter.admin", {native: {secret: secret}});
                        main();
                    });
                }else {
                    secret = obj.native.secret;
                    main();
                }
            } else {
                adapter.logger.error("Cannot find object system.adapter.admin");
            }
        });
    }
});

function main() {
    adapter.subscribeForeignStates('*');<commit_msg>(Bluefox) subscribe mode for adapter.<commit_after>/* jshint -W097 */// jshint strict:false
/*jslint node: true */
"use strict";

var express =           require('express');
var socketio =          require('socket.io');
var session;// =           require('express-session');
var cookieParser;// =      require('cookie-parser');
var bodyParser;// =        require('body-parser');
var AdapterStore;// =      require(__dirname + '/../../lib/session.js')(session);
var passportSocketIo;// =  require(__dirname + "/lib/passport.socketio.js");
var password;// =          require(__dirname + '/../../lib/password.js');
var passport;// =          require('passport');
var LocalStrategy;// =     require('passport-local').Strategy;
var flash;// =             require('connect-flash'); // TODO report error to user

var webServer =  null;
var store =      null;
var objects =    {};
var states =     {};
var secret =     '<KEY>'; // Will be generated by first start
var userKey =    'connect.sid';

var isAuthUsed = false;

var adapter = require(__dirname + '/../../lib/adapter.js')({
    name:           'admin',
    install: function (callback) {
        if (typeof callback === 'function') callback();
    },
    objectChange: function (id, obj) {
        objects[id] = obj;

        webServer.io.sockets.emit('objectChange', id, obj);
    },
    stateChange: function (id, state) {
        states[id] = state;
        webServer.io.sockets.emit('stateChange', id, state);
    },
    unload: function (callback) {
        try {
            adapter.log.info("terminating http" + (webServer.settings.secure ? "s" : "") + " server on port " + webServer.settings.port);
            webServer.server.close();

            callback();
        } catch (e) {
            callback();
        }
    },
    ready: function () {
        adapter.getForeignObject("system.adapter.admin", function (err, obj) {
            if (!err && obj) {
                if (!obj.native.secret) {
                    require('crypto').randomBytes(24, function (ex, buf) {
                        secret = buf.toString('hex');
                        adapter.extendForeignObject("system.adapter.admin", {native: {secret: secret}});
                        main();
                    });
                }else {
                    secret = obj.native.secret;
                    main();
                }
            } else {
                adapter.logger.error("Cannot find object system.adapter.admin");
            }
        });
    }
});

function main() {
    adapter.subscribeForeignStates('*');
{'fraction_non_alphanumeric': 0.15958488349324457, 'fraction_numerical': 0.001958096729978461, 'mean_word_length': 1.9138619509412436, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5839165', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1362, 'n_words': 320}