<commit_before>import {Injectable} from '@angular/core';
import {AuthService} from './auth.service';
import {Observable} from 'rxjs/Observable';
import C from '../constants';
import * as io from "socket.io-client";


@Injectable()
export class SocketService {

  private socket : any;

  constructor(authService: AuthService) {
    this.socket = io.connect(C.socketUrl, {query: "token=123"});//authService.token});
    this.socket.on('connect', function(){
      console.log('Socket connection established!');
    });

    //TODO remove only for testing
    this.createEmail().subscribe((email:any)=>{
      console.log('create email: '+email.subject);
    })
  }

  createEmail(){
    return new Observable(observer => {
      this.socket.on('create_email', (email) => {
        observer.next(JSON.parse(email));
      });
      return () => {
        this.socket.disconnect();
      };
    });
  }


}
<commit_msg>socket receive update msg<commit_after>import {Injectable} from '@angular/core';
import {AuthService} from './auth.service';
import {Observable} from 'rxjs/Observable';
import C from '../constants';
import * as io from "socket.io-client";


@Injectable()
export class SocketService {

  private socket : any;

  constructor(authService: AuthService) {
    this.socket = io.connect(C.socketUrl, {query: "token=123"});//authService.token});
    this.socket.on('connect', function(){
      console.log('Socket connection established!');
    });

    //TODO remove only for testing
    this.createEmail().subscribe((email:any)=>{
      console.log('create email: '+email.subject);
    });
        //TODO remove only for testing
    this.updateEmail().subscribe((email:any)=>{
      console.log('update email: '+email.subject);
    });
  }

  createEmail(){
    return new Observable(observer => {
      this.socket.on('create_email', (email) => {
        observer.next(JSON.parse(email));
      });
      return () => {
        this.socket.disconnect();
      };
    });
  }

  updateEmail(){
    return new Observable(observer => {
      this.socket.on('update_email', (email) => {
        observer.next(JSON.parse(email));
      });
      return () => {
        this.socket.disconnect();
      };
    });
  }




}

{'fraction_non_alphanumeric': 0.17048003589053387, 'fraction_numerical': 0.0026917900403768506, 'mean_word_length': 3.1068139963167587, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3213128', 'n_tokens_mistral': 680, 'n_tokens_neox': 655, 'n_words': 135}