Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ngOnInit() {
this._hubConnection = new signalR.HubConnectionBuilder()
.withUrl('https://localhost:44324/loopy')
.configureLogging(signalR.LogLevel.Trace)
.build();
this._hubConnection.start().catch(err => console.error(err.toString()));
this._hubConnection.on('Send', (data: any) => {
const received = `Received: ${data}`;
this.messages.push(received);
});
}
ngOnInit() {
this._hubConnection = new signalR.HubConnectionBuilder()
.withUrl('https://localhost:44324/zub')
.configureLogging(signalR.LogLevel.Trace)
.build();
this._hubConnection.stop();
this._hubConnection.start().catch(err => {
console.error(err.toString());
});
this._hubConnection.on('ImageMessage', (data: any) => {
console.log(data);
this.images.push(data);
});
}
private init() {
this._hubConnection = new signalR.HubConnectionBuilder()
.withUrl('https://localhost:44324/looney')
.configureLogging(signalR.LogLevel.Information)
.build();
this._hubConnection.start().catch(err => console.error(err.toString()));
this._hubConnection.on('Send', (newsItem: NewsItem) => {
this.store.dispatch(new NewsActions.ReceivedItemAction(newsItem));
});
this._hubConnection.on('JoinGroup', (data: string) => {
console.log('recieved data from the hub');
console.log(data);
this.store.dispatch(new NewsActions.ReceivedGroupJoinedAction(data));
});
this._hubConnection.on('LeaveGroup', (data: string) => {
this.store.dispatch(new NewsActions.ReceivedGroupLeftAction(data));
constructor(props: IGameProps) {
super(props);
const location = document.location || new Location();
const connection = new signalR.HubConnectionBuilder()
.withUrl(`${location.origin}/gameHub`,
{ transport: signalR.HttpTransportType.WebSockets, skipNegotiation: true })
.configureLogging(signalR.LogLevel.Information)
.withAutomaticReconnect()
.withHubProtocol(new MessagePackHubProtocol())
.build();
connection.onclose = e => {
if (e) {
this.addError(`Connection closed with error: "${(e || '')}"`);
} else {
this.addMessage(MessageType.Info, 'Disconnected');
}
};
connection.onreconnecting((e) => {
this.addMessage(MessageType.Info, `Connection lost ("${e}"). Reconnecting.`);
});