swapping to webview webrtc setup as temp solution

will build a custom C# webrtc implementation later
This commit is contained in:
2026-03-26 03:32:58 -04:00
parent 3d5c35fb15
commit a5772d7579
9 changed files with 266 additions and 149 deletions

View File

@@ -1,6 +1,8 @@
using System.Text.Json;
using RelayServer.Services;
using WebSocketSharp.Server;
using Microsoft.AspNetCore.SignalR;
using Microsoft.AspNetCore.Builder;
using RelayServer.Models;
var surrealService = new SurrealService();
@@ -12,6 +14,14 @@ await using var db = await surrealService.ConnectAsync();
ChatTest.ClientKeyService = new ClientKeyService(db);
ChatTest.Db = db;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSignalR();
var app = builder.Build();
app.MapGet("/", () => "Server Running!");
app.MapHub<WebRtcHub>("/webrtc");
app.Run();
var wssv = new WebSocketServer("ws://localhost:1337");
wssv.AddWebSocketService<ChatTest>("/");
wssv.Start();
@@ -146,4 +156,25 @@ static string GetRecordId(object? id)
var table = root.GetProperty("Table").GetString() ?? string.Empty;
return $"{table}:{recordId}";
}
public class WebRtcHub : Hub
{
public async Task SendOffer(string targetConnectionId, string sdp)
{
await Clients.Client(targetConnectionId)
.SendAsync("ReceiveOffer", Context.ConnectionId, sdp);
}
public async Task SendAnswer(string targetConnectionId, string sdp)
{
await Clients.Client(targetConnectionId)
.SendAsync("ReceiveAnswer", Context.ConnectionId, sdp);
}
public async Task SendIceCandidate(string targetConnectionId, string candidate)
{
await Clients.Client(targetConnectionId)
.SendAsync("ReceiveIceCandidate", Context.ConnectionId, candidate);
}
}