TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Karthikeyan K
NA
5.5k
1.4m
Angular with web socket
May 9 2018 1:10 AM
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
});
}
}
Reply
Answers (
4
)
NodeJS is mandatory for the Angular Project Development?
Web API with angularjs application in Visual Studio 2017