【问题标题】:Ionic SignalR Warning: No client method with the name 'X' foundIonic SignalR 警告:找不到名称为“X”的客户端方法
【发布时间】:2021-11-07 19:36:33
【问题描述】:

我有一个 ABP.IO v4.4.2 项目(.NET Core / Angular / Ionic) 我在角度和离子(Android 应用)上使用 SignalR

当我向 Web 应用程序(Angular 或 Ionic)中的所有客户端发送 signalR 它给了我警告并继续代码

Warning: No client method with the name 'XX' found.

但是当我向 Android 应用程序中的所有客户端发送 signalR 时,它会给我同样的警告并停止

只有当我将 SignalR 发送给所有客户端时才会发生这种情况

C# 代码

 public async Task HandleEventAsync(DriverClientBookingUpdateEto bookingUpdateEto)
        {

            if (bookingUpdateEto.BookingTimeFrame == BookingTimeFrame.Future)
            {
                await _hubContext.Clients.All.SendAsync("DriverClientBookingUpdate", bookingUpdateEto);
            }

            else
            {
                string _groupName = bookingUpdateEto.Id.ToString();

                if (bookingUpdateEto.ConnectionIds.Count == 0)
                {
                    await _hubContext.Clients.Group(_groupName).SendAsync("DriverClientBookingUpdate", bookingUpdateEto);
                }

                else if (bookingUpdateEto.ConnectionIds.Count == 1)
                {
                    await _hubContext.Clients.Client(bookingUpdateEto.ConnectionIds[0]).SendAsync("DriverClientBookingUpdate", bookingUpdateEto);
                }

                else if (bookingUpdateEto.ConnectionIds.Count > 1)
                {
                    AddSurroundingDriversConnectionIdToGroup(bookingUpdateEto.ConnectionIds, _groupName);
                    await _hubContext.Clients.Group(_groupName).SendAsync("DriverClientBookingUpdate", bookingUpdateEto);
                }
            }
        }

打字稿代码

    private registerSignalEvents() {
    
        this.hubConnection.on('DriverClientBookingUpdate', (order: OrderModel) => {
          this.orderSvc.handleOrderUpdate(order);
        });
      }

【问题讨论】:

  • 它是如何“停止”的?堆栈跟踪是否存在异常?

标签: asp.net angular signalr ionic4 abp


【解决方案1】:

我刚刚在 handleOrderUpdate() 方法中添加了console.log() 来尝试调试它。 现在它可以工作了。我不知道为什么;真是难以预料

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-10
    相关资源
    最近更新 更多