如何访问 SignalR 核心中的 invocationId?
How to access the invocationId in SignalR core?
我正在 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 的响应。
我实现了一个根据请求发送的新 ID,并且可以在返回值时进行验证。
我正在 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 的响应。
我实现了一个根据请求发送的新 ID,并且可以在返回值时进行验证。