mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Use separate hub method params for signaling.
This commit is contained in:
parent
6060d32fb8
commit
8abdbf7986
@ -28,7 +28,7 @@ namespace Remotely.Desktop.Core.Services
|
||||
Task SendCtrlAltDelToAgent();
|
||||
Task SendDeviceInfo(string serviceID, string machineName, string deviceID);
|
||||
Task SendDtoToViewer<T>(T baseDto, string viewerId);
|
||||
Task SendIceCandidateToBrowser(string candidateJson, string viewerConnectionID);
|
||||
Task SendIceCandidateToBrowser(string candidate, string sdpMid, ushort sdpMLineIndex, string usernameFragment, string viewerConnectionID);
|
||||
Task SendMessageToViewer(string viewerID, string message);
|
||||
Task SendRtcOfferToBrowser(string sdp, string viewerID, IceServerModel[] iceServers);
|
||||
Task SendViewerConnected(string viewerConnectionId);
|
||||
@ -164,9 +164,9 @@ namespace Remotely.Desktop.Core.Services
|
||||
var serializedDto = MessagePack.MessagePackSerializer.Serialize(baseDto);
|
||||
return Connection.SendAsync("SendDtoToBrowser", serializedDto, viewerId);
|
||||
}
|
||||
public async Task SendIceCandidateToBrowser(string candidateJson, string viewerConnectionID)
|
||||
public async Task SendIceCandidateToBrowser(string candidate, string sdpMid, ushort sdpMLineIndex, string usernameFragment, string viewerConnectionID)
|
||||
{
|
||||
await Connection.SendAsync("SendIceCandidateToBrowser", candidateJson, viewerConnectionID);
|
||||
await Connection.SendAsync("SendIceCandidateToBrowser", candidate, sdpMid, sdpMLineIndex, usernameFragment, viewerConnectionID);
|
||||
}
|
||||
|
||||
public async Task SendRtcOfferToBrowser(string sdp, string viewerID, IceServerModel[] iceServers)
|
||||
@ -237,13 +237,13 @@ namespace Remotely.Desktop.Core.Services
|
||||
});
|
||||
|
||||
|
||||
Connection.On("ReceiveIceCandidate", (string candidateJson, string viewerID) =>
|
||||
Connection.On("ReceiveIceCandidate", (string candidate, string sdpMid, ushort sdpMLineIndex, string usernameFragment, string viewerID) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (conductor.Viewers.TryGetValue(viewerID, out var viewer))
|
||||
{
|
||||
viewer.RtcSession.AddIceCandidate(candidateJson);
|
||||
viewer.RtcSession.AddIceCandidate(candidate, sdpMid, sdpMLineIndex, usernameFragment);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@ -104,8 +104,11 @@ namespace Remotely.Desktop.Core.Services
|
||||
};
|
||||
RtcSession.IceCandidateReady += async (sender, candidate) =>
|
||||
{
|
||||
var candidateJson = JsonSerializer.Serialize(candidate);
|
||||
await CasterSocket.SendIceCandidateToBrowser(candidateJson, ViewerConnectionID);
|
||||
await CasterSocket.SendIceCandidateToBrowser(candidate.candidate,
|
||||
candidate.sdpMid,
|
||||
candidate.sdpMLineIndex,
|
||||
candidate.usernameFragment,
|
||||
ViewerConnectionID);
|
||||
};
|
||||
|
||||
await RtcSession.Init(iceServers);
|
||||
|
||||
@ -40,10 +40,17 @@ namespace Remotely.Desktop.Core.Services
|
||||
private IDtoMessageHandler RtcMessageHandler { get; }
|
||||
private Timer DataChannelBufferMonitor { get; }
|
||||
private Viewer Viewer { get; }
|
||||
public void AddIceCandidate(string candidateJson)
|
||||
public void AddIceCandidate(string candidate, string sdpMid, ushort sdpMLineIndex, string usernameFragment)
|
||||
{
|
||||
var candidate = JsonSerializer.Deserialize<RTCIceCandidateInit>(candidateJson);
|
||||
PeerSession.addIceCandidate(candidate);
|
||||
var rtcCandidate = new RTCIceCandidateInit()
|
||||
{
|
||||
candidate = candidate,
|
||||
sdpMid = sdpMid,
|
||||
sdpMLineIndex = sdpMLineIndex,
|
||||
usernameFragment = usernameFragment
|
||||
};
|
||||
|
||||
PeerSession.addIceCandidate(rtcCandidate);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@ -168,11 +168,11 @@ namespace Remotely.Server.Hubs
|
||||
return ViewerHubContext.Clients.Client(viewerId).SendAsync("SendDtoToBrowser", dto);
|
||||
}
|
||||
|
||||
public Task SendIceCandidateToBrowser(string candidateJson, string viewerID)
|
||||
public Task SendIceCandidateToBrowser(string candidate, string sdpMid, ushort sdpMLineIndex, string usernameFragment, string viewerID)
|
||||
{
|
||||
if (_appConfig.UseWebRtc)
|
||||
{
|
||||
return ViewerHubContext.Clients.Client(viewerID).SendAsync("ReceiveIceCandidate", candidateJson);
|
||||
return ViewerHubContext.Clients.Client(viewerID).SendAsync("ReceiveIceCandidate", candidate, sdpMid, sdpMLineIndex, usernameFragment);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
||||
@ -122,9 +122,9 @@ namespace Remotely.Server.Hubs
|
||||
return base.OnDisconnectedAsync(exception);
|
||||
}
|
||||
|
||||
public Task SendIceCandidateToAgent(string candidateJson)
|
||||
public Task SendIceCandidateToAgent(string candidate, string sdpMid, ushort sdpMLineIndex, string usernameFragment)
|
||||
{
|
||||
return CasterHubContext.Clients.Client(ScreenCasterID).SendAsync("ReceiveIceCandidate", candidateJson, Context.ConnectionId);
|
||||
return CasterHubContext.Clients.Client(ScreenCasterID).SendAsync("ReceiveIceCandidate", candidate, sdpMid, sdpMLineIndex, usernameFragment, Context.ConnectionId);
|
||||
}
|
||||
|
||||
public Task SendRtcAnswerToAgent(string sdp)
|
||||
|
||||
@ -84,17 +84,20 @@ export class RtcSession {
|
||||
await ViewerApp.ViewerHubConnection.SendRtcAnswer(this.PeerConnection.localDescription);
|
||||
console.log("Set RTC offer.");
|
||||
}
|
||||
async ReceiveCandidate(candidate: RTCIceCandidate) {
|
||||
async ReceiveCandidate(candidate: string, sdpMid: string, sdpMLineIndex: number, usernameFragment: string) {
|
||||
When(() => !!this.PeerConnection).then(async () => {
|
||||
if (!candidate.candidate.startsWith("candidate:")) {
|
||||
var normalizedCandidate = {} as any;
|
||||
Object.assign(normalizedCandidate, candidate);
|
||||
normalizedCandidate.candidate = `candidate:${candidate.candidate}`;
|
||||
await this.PeerConnection.addIceCandidate(normalizedCandidate);
|
||||
}
|
||||
else {
|
||||
await this.PeerConnection.addIceCandidate(candidate);
|
||||
if (!candidate.startsWith("candidate:")) {
|
||||
candidate = `candidate:${candidate}`;
|
||||
}
|
||||
|
||||
var rtcCandidate = {
|
||||
candidate: candidate,
|
||||
sdpMid: sdpMid,
|
||||
sdpMLineIndex: sdpMLineIndex,
|
||||
usernameFragment: usernameFragment
|
||||
} as RTCIceCandidateInit;
|
||||
|
||||
await this.PeerConnection.addIceCandidate(rtcCandidate);
|
||||
console.log("Set ICE candidate.", candidate);
|
||||
});
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ export class ViewerHubConnection {
|
||||
|
||||
SendIceCandidate(candidate: RTCIceCandidate) {
|
||||
if (candidate) {
|
||||
this.Connection.invoke("SendIceCandidateToAgent", JSON.stringify(candidate));
|
||||
this.Connection.invoke("SendIceCandidateToAgent", candidate.candidate, candidate.sdpMid, candidate.sdpMLineIndex, candidate.usernameFragment);
|
||||
}
|
||||
else {
|
||||
this.Connection.invoke("SendIceCandidateToAgent", "{}");
|
||||
@ -147,10 +147,9 @@ export class ViewerHubConnection {
|
||||
await ViewerApp.RtcSession.ReceiveRtcOffer(sdp);
|
||||
|
||||
});
|
||||
hubConnection.on("ReceiveIceCandidate", async (candidateJson: string) => {
|
||||
var candidate = JSON.parse(candidateJson);
|
||||
hubConnection.on("ReceiveIceCandidate", async (candidate: string, sdpMid: string, sdpMLineIndex: number, usernameFragment: string) => {
|
||||
console.log("Ice candidate received.", candidate);
|
||||
await ViewerApp.RtcSession.ReceiveCandidate(candidate);
|
||||
await ViewerApp.RtcSession.ReceiveCandidate(candidate, sdpMid, sdpMLineIndex, usernameFragment);
|
||||
});
|
||||
hubConnection.on("ShowMessage", (message: string) => {
|
||||
ShowMessage(message);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user