Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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.`);
});