Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return { cookie: document.cookie };
}
@NgModule({
bootstrap: [AppComponent],
imports: [
BrowserModule.withServerTransition({
appId: 'my-app-id' // make sure this matches with your Server NgModule
}),
BrowserAnimationsModule,
BrowserTransferStateModule,
// Our Common AppModule
AppModule,
SignalRModule.forRoot(createConfig)
],
providers: [
{
// We need this for our Http calls since they'll be using an ORIGIN_URL provided in main.server
// (Also remember the Server requires Absolute URLs)
provide: ORIGIN_URL,
useFactory: (getOriginUrl)
}, {
// The server provides these in main.server
provide: REQUEST,
useFactory: (getRequest)
}
]
})
export class BrowserAppModule {
}
ngOnInit() {
const onMessageSent$ = new BroadcastEventListener('OnMessageSent');
this._connection.listen(onMessageSent$);
this._subscription = onMessageSent$.subscribe((chatMessage: ChatMessage) => {
this.chatMessages.push(chatMessage);
console.log('chat messages', this.chatMessages);
});
}
export function createConfig(): SignalRConfiguration {
const signalRConfig = new SignalRConfiguration();
signalRConfig.hubName = 'Ng2SignalRHub';
signalRConfig.qs = { user: 'donald' };
signalRConfig.url = 'http://ng2-signalr-backend.azurewebsites.net/';
signalRConfig.logging = true;
return signalRConfig;
}