<commit_before>// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

const AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
const UserStore = require('./user_store.jsx');
const PostStore = require('./post_store.jsx');
const ChannelStore = require('./channel_store.jsx');
const BrowserStore = require('./browser_store.jsx');
const ErrorStore = require('./error_store.jsx');
const EventEmitter = require('events').EventEmitter;

const Utils = require('../utils/utils.jsx');
const AsyncClient = require('../utils/async_client.jsx');

const Constants = require('../utils/constants.jsx');
const ActionTypes = Constants.ActionTypes;
const SocketEvents = Constants.SocketEvents;

const CHANGE_EVENT = 'change';

var conn;

class SocketStoreClass extends EventEmitter {
    constructor() {
        super();

        this.initialize = this.initialize.bind(this);
        this.emitChange = this.emitChange.bind(this);
        this.addChangeListener = this.addChangeListener.bind(this);
        this.removeChangeListener = this.removeChangeListener.bind(this);
        this.sendMessage = this.sendMessage.bind(this);
        this.failCount = 0;

        this.initialize();
    }
    initialize() {
        if (!UserStore.getCurrentId()) {
            return;
        }

        if (!global.window.mm_session_token_index) {
            return;
        }
<commit_msg>Fix websocket not connecting when session index is 0<commit_after>// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

const AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
const UserStore = require('./user_store.jsx');
const PostStore = require('./post_store.jsx');
const ChannelStore = require('./channel_store.jsx');
const BrowserStore = require('./browser_store.jsx');
const ErrorStore = require('./error_store.jsx');
const EventEmitter = require('events').EventEmitter;

const Utils = require('../utils/utils.jsx');
const AsyncClient = require('../utils/async_client.jsx');

const Constants = require('../utils/constants.jsx');
const ActionTypes = Constants.ActionTypes;
const SocketEvents = Constants.SocketEvents;

const CHANGE_EVENT = 'change';

var conn;

class SocketStoreClass extends EventEmitter {
    constructor() {
        super();

        this.initialize = this.initialize.bind(this);
        this.emitChange = this.emitChange.bind(this);
        this.addChangeListener = this.addChangeListener.bind(this);
        this.removeChangeListener = this.removeChangeListener.bind(this);
        this.sendMessage = this.sendMessage.bind(this);
        this.failCount = 0;

        this.initialize();
    }
    initialize() {
        if (!UserStore.getCurrentId()) {
            return;
        }

        if (!global.window.hasOwnProperty('mm_session_token_index')) {
            return;
        }

{'fraction_non_alphanumeric': 0.1335178139052231, 'fraction_numerical': 0.0038049117952265654, 'mean_word_length': 3.511700468018721, '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': '1537112', 'n_tokens_mistral': 820, 'n_tokens_neox': 805, 'n_words': 170}