javascript - 以角度结束http请求
问题描述
我正在开发一个 Angular 应用程序,但我的 HTTP 获取遇到了一些问题。我每 70 毫秒获取一次 HTTP,但由于某种原因,我总是有一个或多个未决。我想知道是否有一种方法可以跳过那些待处理的请求,或者我是否可以设置超时?
这是我的 HTTP 获取:
public getData(): Observable<any> {
return this.httpClient.get('http://IP_ADRESS:3490/testStream', {responseType: 'arraybuffer'});
}
public putData(): void {
this.canChangePicture = false;
let comp: number;
this.getData().subscribe((resp) => {
console.log(resp);
const responseArray: Uint8ClampedArray = new Uint8ClampedArray(resp);
const newTabTemp: Uint8ClampedArray = new Uint8ClampedArray(this.maxHeight * this.maxWidth * 4);
comp = 0;
for (let i = 0; i < this.maxHeight * this.maxWidth * 4; i = i + 4) {
newTabTemp[i] = responseArray[comp];
newTabTemp[i + 1] = responseArray[comp];
newTabTemp[i + 2] = responseArray[comp];
newTabTemp[i + 3] = 255;
comp = comp + 1;
}
let nouvData: ImageData;
nouvData = new ImageData(newTabTemp, this.maxWidth, this.maxHeight);
this.contextVideo.putImageData(nouvData, BORDERX / 2, BORDERY / 2);
this.canChangePicture = true;
});
}
解决方案
推荐阅读
- javascript - 通过 chrome 扩展程序登录 laravel nova 网络应用程序。419 错误 csrf 令牌不匹配
- scala - 新 StreamingContext 上的 NoSuchMethodError
- regex - 在 Google Sheet 中提取 url 域根目录
- excel - 如何使用两个条件执行 sumproduct?
- javascript - 当嵌入到 expo-av 的视频组件中时,expo-camera 返回的视频 url 给出了空白屏幕
- excel - 在单元格中使用内部颜色来选择要存储在字符串中的电子邮件地址
- javascript - 使用时位置不突出显示
- python - 如何清除 tkinter 的标签文本
- spring - Spring Boot:同一个tomcat不同属性中的多个WAR部署
- javascript - DOM 被另一个脚本完全更新后触发 javascript