blob: 2a6e5d78a4de0963a4c6b12a2bb570e09e6f44b7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import { Injectable } from '@angular/core';
import * as signalR from "@microsoft/signalr";
import Shared from '../Shared';
import { CookieService } from 'ngx-cookie-service';
@Injectable({
providedIn: 'root'
})
export class SignalRService {
public hubConnection?: signalR.HubConnection;
public startConnection = () => {
this.hubConnection = new signalR.HubConnectionBuilder()
.withUrl('http://localhost:5283/chatHub', {
accessTokenFactory: () => this.cookie.get("token"),
withCredentials: false
}).build();
this.hubConnection.on("Notify", (message: string) => {
console.log(" " + message);
});
this.hubConnection
.start()
.then(() => console.log("con Started"))
.catch(err => console.log("Error" + err))
}
constructor(private cookie: CookieService) { }
}
|