Skip to content

Instantly share code, notes, and snippets.

@BMLande
Created February 7, 2019 07:32
Show Gist options
  • Save BMLande/236d2bd5b7bbec6d76fb6a49d3c3da8f to your computer and use it in GitHub Desktop.
Save BMLande/236d2bd5b7bbec6d76fb6a49d3c3da8f to your computer and use it in GitHub Desktop.
Websocket Service
import { Injectable } from '@angular/core';
import * as Stomp from 'stompjs';
import * as SockJS from 'sockjs-client';
@Injectable({ providedIn: 'root' })
export class WebSocketService {
//connect to websocket server
public connect() {
let socket = new SockJS("http://192.168.1.9:8080/websocketapp");
let stompClient = Stomp.over(socket);
return stompClient;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment