jan*_*han 5 javascript c# webrtc asp.net-core-mvc
我使用 SignalR 创建了一个 .net core 聊天应用程序,并使用 WebRTC 进行视频通话。由于我需要使用服务器方法将 SDP 发送到接收者,因此我创建了一个集线器方法调用“SendOffer”。当我单击视频通话按钮时,我调用了这个“SendOffer”方法。我已将客户端代码放在下面
var connection = new signalR.HubConnectionBuilder()
.withUrl('/chat')
.build();
const Peer = new RTCPeerConnection();
const video = document.querySelector('video');
const constraints = {
'video': true,
'audio': true
}
document.getElementById("sendVideo").addEventListener("click", function (event) {
navigator.mediaDevices.getUserMedia({
video: true,
audio: true,
}).then(function (stream) {
video.srcObject = stream
video.play();
//Peer.addStream(stream);
Peer.createOffer()
.then(sdp => Peer.setLocalDescription(sdp))
.then(function () {
console.log(Peer.localDescription);
//connection.invoke("SendOffer", Peer.localDescription).catch(function (err) {
// return console.error(err.toString());
connection.invoke("SendOffer", Peer.localDescription);
})
});
})
Run Code Online (Sandbox Code Playgroud)
但这会在控制台日志中给出错误并且不起作用。打击是错误
signalr.js:2088 未捕获(承诺中)错误:由于服务器上的错误,无法调用“SendOffer”。在 _this.callbacks。(signalr.js:2088) 在 HubConnection.processIncomingData (signalr.js:2182) 在 WebSocketTransport.HubConnection.connection.onreceive (signalr.js:1905) 在 WebSocket.webSocket.onmessage (signalr.js:3949)
任何人都可以帮我解决这个错误。
| 归档时间: |
|
| 查看次数: |
7333 次 |
| 最近记录: |