I want to integrate a WebSocket client to my angular2 application.
I frist tried to do this using sock.js https://github.com/sockjs/sockjs-client
and created a SockJS object like this:
export class Core {
private sock: any;
constructor (private router: Router) {
this.sock = new SockJS(AppSettings.WEBSOCK_ENDPOINT);
}
}
import {$WebSocket} from 'angular2-websocket/angular2-websocket'
var ws = new $WebSocket("url");
As you may see in
https://github.com/afrad/angular2-websocket/blob/master/angular2-websocket.ts
the other parameters are optional
constructor(private url:string, private protocols?:Array<string>, private config?: WebSocketConfig ) {
you might also like this it has working socket angular example (using socket.io)