<commit_before>import {IBackend} from "./IBackend";
import {ParameterInfo} from "./ParameterInfo";
import {Injectable, Inject} from "angular2/core";
import {DummyBackend} from "./DummyBackend";
import {ParameterUpdateListener} from "./ParameterUpdateListener";
import {SocketHandler} from "./SocketHandler";
import {APP_CONFIG, Config} from "../Config";


@Injectable()
export class Backend implements IBackend {
    private backend:IBackend = new DummyBackend();
    private websocketConnection:SocketHandler;


    constructor(@Inject(APP_CONFIG) private config:Config) {
        
        console.log("Web socket end point: " +config.WEB_SOCKET_ENDPOINT);
        
        this.websocketConnection = new SocketHandler(config.WEB_SOCKET_ENDPOINT);
// this.websocketConnection.connect();
        
        this.websocketConnection.getDataStream().subscribe(data => {
           console.log("Got data: " +data[1]);
        },
        error => {
            console.log("Error");
        });
    }


    getBlockLengthfunction():number {
        return this.backend.getBlockLength();
    }

    getRangeStart():number {
        return this.backend.getRangeStart();
    }
<commit_msg>Adding test of websockets to Backend.<commit_after>import {IBackend} from "./IBackend";
import {ParameterInfo} from "./ParameterInfo";
import {Injectable, Inject} from "angular2/core";
import {DummyBackend} from "./DummyBackend";
import {ParameterUpdateListener} from "./ParameterUpdateListener";
import {SocketHandler} from "./SocketHandler";
import {APP_CONFIG, Config} from "../Config";


@Injectable()
export class Backend implements IBackend {
    private backend:IBackend = new DummyBackend();
    private websocketConnection:SocketHandler;


    constructor(@Inject(APP_CONFIG) private config:Config) {
        this.websocketConnection = new SocketHandler(config.WEB_SOCKET_ENDPOINT);
        this.websocketConnection.connect();

        this.websocketConnection.getDataStream().subscribe(data => {
                console.log("Got data from: " + data.origin);
                console.log("Message data: " + data.data);
            },
            error => {
                console.log("Error");
            });
    }


    getBlockLengthfunction():number {
        return this.backend.getBlockLength();
    }

    getRangeStart():number {
        return this.backend.getRangeStart();
    }

{'fraction_non_alphanumeric': 0.12363330529857022, 'fraction_numerical': 0.001261564339781329, 'mean_word_length': 3.301989150090416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2933893', 'n_tokens_mistral': 643, 'n_tokens_neox': 639, 'n_words': 136}