如何访问SignalR内核中的invocationId?

问题描述 投票:0回答:1

我正在在Azure上使用SignalR Core创建应用。现在,我需要将调用的请求与返回的值和回调进行匹配。我想使用invocationId确保将要执行的方法是最新调用的请求。为了避免在所附的图片中发生这种情况。

var _this.latestInvokeId = ??
connection.invoke('getData', _this.ID)
    .then(function (data) {
        if(this.invocationId === _this.latestInvokeId)
            console.log('Use the data', data)
    })
    .catch(function (error) {
        console.log(error);
    });

[在短时间内多次调用getData时,我想确保使用正确的响应。因此,需要忽略invocationId 8的响应,而仅使用invocationId 9的响应。enter image description here

javascript asp.net-core-signalr signalr-client
1个回答
0
投票

我实现了一个新的ID,该ID在请求中发送,并且可以在返回值时进行验证。

© www.soinside.com 2019 - 2024. All rights reserved.