Can any help me, im not getting continous data from web socket, its giving only on first call
import { Injectable } from '@angular/core';
import * as io from 'socket.io-client';
@Injectable()
export class SocketService {
private _baseUrl = 'http://kaboom.rksv.net/watch';
private socket: SocketIOClient.Socket;
constructor() {
}
socketInit = () => {
this.socket = io.connect(this._baseUrl, {
transports: ['websocket', 'polling'],
forceNew: true,
reconnection: true,
reconnectionDelay: 1000,
reconnectionDelayMax: 5000,
reconnectionAttempts: Infinity
});
this.socket.on('connect', () => {
this.socket.on('data', (data) => {
console.log(data);
});
});
this.socket.on('disconnect', function () {
console.log('disconnected from server');
});
this.socket.on('error', (err) => {
console.log(err);
});
}
sub = () => {
this.socket.emit('sub', {
state: !0
});
}
}


Shailendra Sahu8 reputationPosted Jul 14, 2018, 8:51 PM EDT
Karthikeyan KRank #554 · 4.4K reputationPosted Aug 24, 2018, 9:21 PM EDT
Shailendra Sahu8 reputationPosted Aug 24, 2018, 11:08 PM EDT
Karthikeyan KRank #554 · 4.4K reputationPosted Aug 24, 2018, 11:33 PM EDT