Closed Nanddeep closed 7 months ago
I am using signalr-no-jquery in Ionic and the API server is in C#. The connection starts with websockets but the client event doesn't get triggered when
Clients.Client(Context.ConnectionId).broadcast(new { NotificationType = "MESSAGE_RECEIVED" });
is called on the OnConnected() method on the API. Below is the code:
private path: string = 'http://localhost/ABCAPI/'; private proxy: string = 'notificationHub'; private connection: any; private hubProxy: any; messageReceived = new EventEmitter<any>(); connectionEstablished = new EventEmitter<boolean>(); connectionExists = false; constructor() { this.connection = hubConnection(this.path,{ useDefaultPath: true, transport:["serverSentEvents","longPolling"] }); this.hubProxy = this.connection.createHubProxy('ABCServer'); this.registerOnserverEvents(); this.startConnection(); } private startConnection(): void { this.connection.start() .done((data: any) => { console.log('SignalR Connected with: ' + data.transport.name); console.log('Now connected, connection ID=' + data.id); this.connectionEstablished.emit(true); this.connectionExists = true; }) .fail((error: any) => { console.log('SignalR Could not connect: ' + error); this.connectionEstablished.emit(false); } private registerOnserverEvents(): void { this.hubProxy.on('broadcast', (data: any) => { console.log(data); this.messageReceived.emit(data); }); }
Any suggestions?
Clients.Client should be writed before connection start.
Hi..did anyone manage to fix this issue?
hi anyone has same issue? I can not got event of data...
I am using signalr-no-jquery in Ionic and the API server is in C#. The connection starts with websockets but the client event doesn't get triggered when
Clients.Client(Context.ConnectionId).broadcast(new { NotificationType = "MESSAGE_RECEIVED" });
is called on the OnConnected() method on the API. Below is the code:
Any suggestions?