Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function initializeConnection(options: CircuitStartOptions, logger: Logger, circuit: CircuitDescriptor): Promise {
const hubProtocol = new MessagePackHubProtocol();
(hubProtocol as unknown as { name: string }).name = 'blazorpack';
const connectionBuilder = new signalR.HubConnectionBuilder()
.withUrl('_blazor')
.withHubProtocol(hubProtocol);
options.configureSignalR(connectionBuilder);
const connection = connectionBuilder.build();
setEventDispatcher((descriptor, args) => {
connection.send('DispatchBrowserEvent', JSON.stringify(descriptor), JSON.stringify(args));
});
// Configure navigation via SignalR
window['Blazor']._internal.navigationManager.listenForNavigationEvents((uri: string, intercepted: boolean): Promise => {
return connection.send('OnLocationChanged', uri, intercepted);
});
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));
});
ngOnInit() {
this.config = [
{
name: 'message',
type: FieldTypes.Textbox,
label: 'Message',
validation: [Validators.required],
},
{
name: 'button',
type: FieldTypes.Button,
label: 'Send',
onSubmit: this.sendMessage.bind(this),
},
];
this.hub = new HubConnectionBuilder().withUrl(`${this.baseUrl}chathub`).build();
this.hub.on('send', (data: any) => {
const received = `Received: ${data}`;
this.messages.push(received);
});
this.hub
.start()
.then(() => console.log('Hub connection started'))
.catch(err => console.log('Error while establishing connection: ' + err));
}
}
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);
});
}
ngOnInit() {
this._hubConnection = new HubConnectionBuilder().withUrl(`${this.baseUrl}shapeHub`).build();
this._hubConnection.on('shapeMoved', function(x, y) {
this.element.nativeElement.css({ left: x, top: y });
});
const target = this.element.nativeElement;
const mouseup = fromEvent(target, 'mouseup');
const mousemove = fromEvent(document, 'mousemove');
const mousedown = fromEvent(target, 'mousedown');
const mousedrag = mousedown.pipe(
flatMap((md: any) => {
const startX = md.clientX + window.scrollX,
startY = md.clientY + window.scrollY,
startLeft = parseInt(md.target.style.left, 10) || 0,
startTop = parseInt(md.target.style.top, 10) || 0;
private register() {
this._hubConnection = new HubConnectionBuilder()
.withUrl(this.SignalrHubUrl + '/hub/notificationhub', {
accessTokenFactory: () => this.securityService.GetToken()
})
.configureLogging(LogLevel.Information)
.withAutomaticReconnect()
.build();
}
private createConnection() {
this.hubConnection = new HubConnectionBuilder()
.withUrl(environment.baseUrls.server + 'coolmessages')
.withAutomaticReconnect()
.configureLogging(LogLevel.Information)
.build();
}
function getConnectionBuilder(transportType?: HttpTransportType, url?: string, options?: IHttpConnectionOptions): HubConnectionBuilder {
let actualOptions: IHttpConnectionOptions = options || {};
if (transportType) {
actualOptions.transport = transportType;
}
actualOptions = { ...actualOptions, ...commonOptions };
return new HubConnectionBuilder()
.configureLogging(TestLogger.instance)
.withUrl(url || TESTHUBENDPOINT_URL, actualOptions);
}