.NET Core第35天_整併signalr及peer.js(WebRTC)搭建的直播串流功能模組
使用.net6 mvc 在此先來更改一下預設範本的HomeController.cs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 using Microsoft.AspNetCore.Mvc ; using System.Diagnostics ; namespace BingoSys.Controllers { public class HomeController : Controller { public IActionResult Index () { return Redirect ( $ "/{Guid.NewGuid()}" ); } [HttpGet("/{roomId}")] public IActionResult Room ( string roomId) { ViewBag.roomId = roomId; return View (); } } } 預設加入直播房空間都需要有一個獨一無二的id,在此用guid來實踐 接著到微軟signalr的文檔介紹 https://dotnet.microsoft.com/en-us/apps/aspnet/signalr Get Started 點入後 https://learn.microsoft.com/zh-tw/aspnet/core/tutorials/signalr?view=aspnetcore-6.0&WT.mc_id=dotnet-35129-website&tabs=visual-studio 新增用戶端連結 SignalR 庫 這裡我們透過libman來安裝client端需要的signalr js libman install @microsoft/signalr@latest -p unpkg -d wwwroot/js/signalr --files dist/browser/signalr.js --fi