<commit_before>/**
 * Create a stream of messages via a websocket.
 *
 * @constructor
 * @param bufferSize Size of buffer containing messages, when having more message in buffer then it drops the first one's
 * @param client Path for Socket
 * @param stream Path of stream
 *
 * @example
 *  var activityStream = new ActivityStream(50, 'fr-ws', '/topic/activities');
 *  var buffer = activityStream.getBuffer().getArr();
 */

define(
    ['require', 'jquery', './CircularBuffer', 'sockjs'],
    function(require, $, CircularBuffer, SockJS) {
        'use strict';

        function ActivityStream(bufferSize, client, stream) {
            var _self = this;
            this.buffer = new CircularBuffer(bufferSize);
            this.socket.client = new SockJS(client);

            this.socket.client.onopen = function() {
                console.log('socket.client open');
            };
            this.socket.client.onclose = function() {
                console.log('socket.client close');
            };

            this.socket.stomp = window.Stomp.over(this.socket.client); // window.Stomp needed when import Stomp via requirejs
            this.socket.stomp.connect({}, function(frame) {
                _self.socket.stomp.subscribe(stream, function(message) {
                    _self.buffer.add(JSON.parse(message.body));
                });<commit_msg>add origin to socks<commit_after>/**
 * Create a stream of messages via a websocket.
 *
 * @constructor
 * @param bufferSize Size of buffer containing messages, when having more message in buffer then it drops the first one's
 * @param client Path for Socket
 * @param stream Path of stream
 *
 * @example
 *  var activityStream = new ActivityStream(50, 'fr-ws', '/topic/activities');
 *  var buffer = activityStream.getBuffer().getArr();
 */

define(
    ['require', 'jquery', './CircularBuffer', 'sockjs'],
    function(require, $, CircularBuffer, SockJS) {
        'use strict';

        function ActivityStream(bufferSize, client, stream) {
            var _self = this;
            this.buffer = new CircularBuffer(bufferSize);
            this.socket.client = new SockJS(window.location.origin + "/" + client);

            this.socket.client.onopen = function() {
                console.log('socket.client open');
            };
            this.socket.client.onclose = function() {
                console.log('socket.client close');
            };

            this.socket.stomp = window.Stomp.over(this.socket.client); // window.Stomp needed when import Stomp via requirejs
            this.socket.stomp.connect({}, function(frame) {
                _self.socket.stomp.subscribe(stream, function(message) {
                    _self.buffer.add(JSON.parse(message.body));
                });
{'fraction_non_alphanumeric': 0.12332730560578661, 'fraction_numerical': 0.0014466546112115732, 'mean_word_length': 2.4275092936802976, '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': '5563463', 'n_tokens_mistral': 747, 'n_tokens_neox': 726, 'n_words': 192}