我已使用Signalr 2.4.0库显示实时数据。我已经从服务器调用了一个方法,并且侦听器会自动调用并将票证计数发送给我。它适用于Chrome,Safari和Firefox,但不适用于IE11。在IE11上,未调用监听器,并且我们没有获取实时票数。 我创建了如下连接:
eventDetailHubCon() {
this.eventDetailConnection = $.hubConnection('https://Test.eeeee.com/signalr/hubs', { useDefaultPath: false });
this.eventDetailConnection.start().catch(err => console.error('SharedService connection Error:', err.toString()));
//create a proxy object
this.eventDetailcathub = this.eventDetailConnection.createHubProxy('TestingHub');
}
invoked the method
signalRInit(eventId, alternateKey) {
try {
const hub = this.testService.getEventRegHub();
hub.invoke('testEvent', Key, eventId);
} catch (err) {
console.log("error");
}
}
const hub = this.testService.getEventRegHub();
hub.on('testListner', (abc, TixAvailableToPublic) => {
if (this.ref == abc) {
this.remainingEventTickets = EventTixAvailableToPublic;
this.isOrAre = this.remainingEventTickets > 1 ? 'are' 'is';
this.ticketWordForRemainingTickets = this.remainingEventTickets > 1 ? 'tickets' 'ticket';
}
});