From 01a4364cc7f90144f4c81b9a6e97bb86156c570c Mon Sep 17 00:00:00 2001 From: Lode Kennes Date: Sat, 9 May 2020 23:18:06 +0200 Subject: [PATCH] first commit --- .gitignore | 360 ++++++++++++++++++ client/cert.pem | 17 + client/index.html | 15 + client/key.pem | 27 ++ client/package-lock.json | 189 +++++++++ client/package.json | 15 + client/script.js | 73 ++++ client/style.css | 0 server/WebRTCDemo.Server/Hubs/SignalingHub.cs | 24 ++ server/WebRTCDemo.Server/Program.cs | 23 ++ .../Properties/launchSettings.json | 30 ++ server/WebRTCDemo.Server/Startup.cs | 61 +++ .../WebRTCDemo.Server.csproj | 8 + .../WebRTCDemo.Server/WebRTCDemo.Server.sln | 16 + .../appsettings.Development.json | 9 + server/WebRTCDemo.Server/appsettings.json | 10 + server/WebRTCDemo.Server/global.json | 5 + 17 files changed, 882 insertions(+) create mode 100644 .gitignore create mode 100644 client/cert.pem create mode 100644 client/index.html create mode 100644 client/key.pem create mode 100644 client/package-lock.json create mode 100644 client/package.json create mode 100644 client/script.js create mode 100644 client/style.css create mode 100644 server/WebRTCDemo.Server/Hubs/SignalingHub.cs create mode 100644 server/WebRTCDemo.Server/Program.cs create mode 100644 server/WebRTCDemo.Server/Properties/launchSettings.json create mode 100644 server/WebRTCDemo.Server/Startup.cs create mode 100644 server/WebRTCDemo.Server/WebRTCDemo.Server.csproj create mode 100644 server/WebRTCDemo.Server/WebRTCDemo.Server.sln create mode 100644 server/WebRTCDemo.Server/appsettings.Development.json create mode 100644 server/WebRTCDemo.Server/appsettings.json create mode 100644 server/WebRTCDemo.Server/global.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6840c18 --- /dev/null +++ b/.gitignore @@ -0,0 +1,360 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore +.idea/ +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*[.json, .xml, .info] + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/client/cert.pem b/client/cert.pem new file mode 100644 index 0000000..06bc3fa --- /dev/null +++ b/client/cert.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICwzCCAaugAwIBAgIJAK1gYPgcHKR8MA0GCSqGSIb3DQEBBQUAMBQxEjAQBgNV +BAMTCWxvY2FsaG9zdDAeFw0yMDA1MDkyMTA1MTFaFw0zMDA1MDcyMTA1MTFaMBQx +EjAQBgNVBAMTCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBANf/u9n9WEIYx3w1mZgtzW5y1PmZkRmMOW7jbOcbSuoT4LlZnRyfdvXBmXm1 +qQvEfSN+1nDBbVyY/q0z6hFCMMyco64vxL2hCk9q94VID4DzBUJ4TaTpB88v6opk +Q75Vftvjri8s2cEnO10ddWP9TaZF0zh97NtmRKMV9UaHUItHqxja/y3rRLhIOeQe +jefwytDSFiqvK8Ukjptz9kneRLp6hxp+ueSaSxKPPnBw8Al4vh/ZMs0OtHtl5/Yr +RuOI4k5Zx0Cn6m4tbGhtshVL8c1WhJ0v2ZGNSv7fE3ZxvyR3IOBCAbSCGcBW6ysp +NYZNgfaFfS4RzrvdvY/8RJFyLM0CAwEAAaMYMBYwFAYDVR0RBA0wC4IJbG9jYWxo +b3N0MA0GCSqGSIb3DQEBBQUAA4IBAQAdcbl/l92oMJwMnkCmc3/fVehlmT+PbLuu +ISAL793X1a1rf1FfTN4Pmv0GR2Ys7sNZhdJSc2qvEcIz/1/Pei9Ifwgl7QLFW7E8 +iAwDwqy0oR+Jaz3yhHD9lm8Lm2491iX6YHvGs2B3WhsGkIo5m5TIjqmttTM/ufY/ +Z31o2QV1Qk1ErKzRM5Rq1BDLS+uNRG5JDTo3ojJ7sUOgxe9DkPZmawCnj3SHUZs9 +YAUPHR2xckFmgikLSga+3y1g6Qw/nSbap6UXU87xR0G/IWc9O8+kaadZhbZFTqrf +hbyV5M0vtsnqNz2cbxti8UBUi4zR14oHAG2fxaR2bZatF10W1snF +-----END CERTIFICATE----- diff --git a/client/index.html b/client/index.html new file mode 100644 index 0000000..6fea411 --- /dev/null +++ b/client/index.html @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/client/key.pem b/client/key.pem new file mode 100644 index 0000000..e3a63ab --- /dev/null +++ b/client/key.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEA1/+72f1YQhjHfDWZmC3NbnLU+ZmRGYw5buNs5xtK6hPguVmd +HJ929cGZebWpC8R9I37WcMFtXJj+rTPqEUIwzJyjri/EvaEKT2r3hUgPgPMFQnhN +pOkHzy/qimRDvlV+2+OuLyzZwSc7XR11Y/1NpkXTOH3s22ZEoxX1RodQi0erGNr/ +LetEuEg55B6N5/DK0NIWKq8rxSSOm3P2Sd5EunqHGn655JpLEo8+cHDwCXi+H9ky +zQ60e2Xn9itG44jiTlnHQKfqbi1saG2yFUvxzVaEnS/ZkY1K/t8TdnG/JHcg4EIB +tIIZwFbrKyk1hk2B9oV9LhHOu929j/xEkXIszQIDAQABAoIBAQCyHrWugfjyKLT4 +fMr4b2zlE9UFL9o0EyqZgvofaqZQeavrrTaej/Htn4UMlP2eMp5vUv1LZnbk0VXT +RuhS6x6K3PEthz7akZ6K906+njoKwF0p/0MoJvLFrGHhVeV3Y9GFSzAsvvOjENMn +ak+P8SbDYvlXsKBOHPuk8Uqeqp+E+kUITSjBAeVQV/rnnmnE/g7yZLYMIt5Yt6uu +aTZgJ1N+F7WrCIjQ/UFdoXCp+fqA1/G8TLKUMSIVj/x8rnpkIHIu4jX9aitLA5ot +JF70anDw+mGKEN87IrXJyOzsMvP37RcbpuWV3F71Mb0rDlRYCCOdAdP3aLTJTgcN +ZlmtFi4BAoGBAO1zIeBl7H+8kbF5uhcjZ+HQKmWmpHE3/ikXcMvPMUq9kpcivtNR +ZR5vixBLSN5MGo4V12gSE8D5nAIXUH8tSn9ptmssQxqTKNlyMLRlkMxTuN6yszGZ +jFGbLML6lE+hbeu8CtU7Ztn8W5xLPfl/GZpZyEe/FO2bMcLgLdNGTavtAoGBAOjf +mPE9dREakolATcIbG1saN4ShGmL1fAS9pYEtNcxbBarL21GGzmRPVK1rHgGB3HEV +tH3HwJUAvwgCw9umuy7FixpLrpJAZHFiIeBopvrTsg/GDvGeJTxAvpReFH8N3AW2 +WSjjbkEaeUxGbWglTt5l+VMZeXVdECwMOc244yhhAoGBAKfkh2iGSOHM8Gs/ub/Q +jgxRxxiW6qEPSUu+wkepmZ3SSwtISwtZ+xi5H+gGg2CDCSe789InLgZ9t7yWxZkW +6h0LHyvKYSwyL2kI370+L1L6Q7ZbPm7sthWhldXLngBsES/khvhchw3M7O2nGgwG +vZCwuPdZ+a9D07yKDHzdsd/FAoGAJT/W5AezmRfKBsBNb9YMKydnaASpBtlDjDKV +rbMAnv6USnyvSTwp+WujHNY8h3sxOrmBFHmGOY9T/0EJ+TGTUWjx1jPy6Zv5NRXA +W3gB9a81FUbWDxn/1MJ6eZsO5j/eSN+hJWQzt6A3dNbzGyyUkAh5uCwj/Hz1YEZY +XKrNUyECgYEA4WkQpSmHhp98UW8k2O/2RBpuJSxrdzZFmyrTBBUO8awVb9D/9Vb9 +78OO+hmzANAfVxuP+flAy2SXxZ+8yFEXcBOGlmn7dSKGEW+tRsNFJa8tqaf6LAML +A14TvcJ/spIcoEnmV3trqG+AnLjGDJSjrP8CMAmwmQ9LQBplmUsjMuY= +-----END RSA PRIVATE KEY----- diff --git a/client/package-lock.json b/client/package-lock.json new file mode 100644 index 0000000..2b95ab2 --- /dev/null +++ b/client/package-lock.json @@ -0,0 +1,189 @@ +{ + "name": "client", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "async": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", + "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "dev": true, + "requires": { + "lodash": "^4.17.14" + } + }, + "basic-auth": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-1.1.0.tgz", + "integrity": "sha1-RSIe5Cn37h5QNb4/UVM/HN/SmIQ=", + "dev": true + }, + "colors": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", + "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", + "dev": true + }, + "corser": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/corser/-/corser-2.0.1.tgz", + "integrity": "sha1-jtolLsqrWEDc2XXOuQ2TcMgZ/4c=", + "dev": true + }, + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ecstatic": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/ecstatic/-/ecstatic-3.3.2.tgz", + "integrity": "sha512-fLf9l1hnwrHI2xn9mEDT7KIi22UDqA2jaCwyCbSUJh9a1V+LEUSL/JO/6TIz/QyuBURWUHrFL5Kg2TtO1bkkog==", + "dev": true, + "requires": { + "he": "^1.1.1", + "mime": "^1.6.0", + "minimist": "^1.1.0", + "url-join": "^2.0.5" + } + }, + "eventemitter3": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.0.tgz", + "integrity": "sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg==", + "dev": true + }, + "follow-redirects": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.11.0.tgz", + "integrity": "sha512-KZm0V+ll8PfBrKwMzdo5D13b1bur9Iq9Zd/RMmAoQQcl2PxxFml8cxXPaaPYVbV0RjNjq1CU7zIzAOqtUPudmA==", + "dev": true, + "requires": { + "debug": "^3.0.0" + } + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true + }, + "http-proxy": { + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.0.tgz", + "integrity": "sha512-84I2iJM/n1d4Hdgc6y2+qY5mDaz2PUVjlg9znE9byl+q0uC3DeByqBGReQu5tpLK0TAqTIXScRUV+dg7+bUPpQ==", + "dev": true, + "requires": { + "eventemitter3": "^4.0.0", + "follow-redirects": "^1.0.0", + "requires-port": "^1.0.0" + } + }, + "http-server": { + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/http-server/-/http-server-0.12.3.tgz", + "integrity": "sha512-be0dKG6pni92bRjq0kvExtj/NrrAd28/8fCXkaI/4piTwQMSDSLMhWyW0NI1V+DBI3aa1HMlQu46/HjVLfmugA==", + "dev": true, + "requires": { + "basic-auth": "^1.0.3", + "colors": "^1.4.0", + "corser": "^2.0.1", + "ecstatic": "^3.3.2", + "http-proxy": "^1.18.0", + "minimist": "^1.2.5", + "opener": "^1.5.1", + "portfinder": "^1.0.25", + "secure-compare": "3.0.1", + "union": "~0.5.0" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "opener": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/opener/-/opener-1.5.1.tgz", + "integrity": "sha512-goYSy5c2UXE4Ra1xixabeVh1guIX/ZV/YokJksb6q2lubWu6UbvPQ20p542/sFIll1nl8JnCyK9oBaOcCWXwvA==", + "dev": true + }, + "portfinder": { + "version": "1.0.26", + "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.26.tgz", + "integrity": "sha512-Xi7mKxJHHMI3rIUrnm/jjUgwhbYMkp/XKEcZX3aG4BrumLpq3nmoQMX+ClYnDZnZ/New7IatC1no5RX0zo1vXQ==", + "dev": true, + "requires": { + "async": "^2.6.2", + "debug": "^3.1.1", + "mkdirp": "^0.5.1" + } + }, + "qs": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz", + "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==", + "dev": true + }, + "requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", + "dev": true + }, + "secure-compare": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/secure-compare/-/secure-compare-3.0.1.tgz", + "integrity": "sha1-8aAymzCLIh+uN7mXTz1XjQypmeM=", + "dev": true + }, + "union": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/union/-/union-0.5.0.tgz", + "integrity": "sha512-N6uOhuW6zO95P3Mel2I2zMsbsanvvtgn6jVqJv4vbVcz/JN0OkL9suomjQGmWtxJQXOCqUJvquc1sMeNz/IwlA==", + "dev": true, + "requires": { + "qs": "^6.4.0" + } + }, + "url-join": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/url-join/-/url-join-2.0.5.tgz", + "integrity": "sha1-WvIvGMBSoACkjXuCxenC4v7tpyg=", + "dev": true + } + } +} diff --git a/client/package.json b/client/package.json new file mode 100644 index 0000000..8b3e165 --- /dev/null +++ b/client/package.json @@ -0,0 +1,15 @@ +{ + "name": "client", + "version": "1.0.0", + "description": "", + "main": "script.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "http-server -S" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "http-server": "0.12.3" + } +} diff --git a/client/script.js b/client/script.js new file mode 100644 index 0000000..6eb3547 --- /dev/null +++ b/client/script.js @@ -0,0 +1,73 @@ +(async function () { + let stream; + + await new Promise((resolve, reject) => { + navigator.getUserMedia({ + video: true, + audio: true + }, (mediaStream) => { + // Success + stream = mediaStream; + document.getElementById("own-video").srcObject = stream; + resolve(); + }, + (e) => { + // Error + }) + }); + + let remoteStream; + const peerConnectionConfig = { + 'iceServers': [ + { 'urls': 'stun:stun.services.mozilla.com' }, + { 'urls': 'stun:stun.l.google.com:19302' }, + ] + }; + + const rtcPeerConnection = new RTCPeerConnection(peerConnectionConfig); + + const connection = new signalR.HubConnectionBuilder() + .withUrl("https://localhost:5001/signaling") + .configureLogging(signalR.LogLevel.Debug) + .build(); + + connection.on("UserConnected", async function () { + console.log("user connected"); + rtcPeerConnection.onicecandidate = function (event) { + if (event.candidate === null) return; + connection.send("Ice", JSON.stringify(event.candidate)); + }; + + rtcPeerConnection.onaddstream = function (event) { + console.log('got stream'); + remoteStream = event.stream; + document.getElementById("remote-video").srcObject = remoteStream; + }; + + rtcPeerConnection.addStream(stream); + + const offer = await rtcPeerConnection.createOffer(); + await rtcPeerConnection.setLocalDescription(offer); + await connection.send("Sdp", JSON.stringify(rtcPeerConnection.localDescription)); + }); + + connection.on("Sdp", async function (sdp) { + const deserialized = JSON.parse(sdp); + console.log("SDP", sdp); + + const remoteDescription = rtcPeerConnection.setRemoteDescription(new RTCSessionDescription(deserialized)); + + if (deserialized.type !== 'offer') return; + const answer = await rtcPeerConnection.createAnswer(); + await rtcPeerConnection.setLocalDescription(answer); + await connection.send("Sdp", JSON.stringify(rtcPeerConnection.localDescription)); + }); + + connection.on("Ice", async function (ice) { + console.log("ICE", ice); + const deserialized = JSON.parse(ice); + await rtcPeerConnection.addIceCandidate(new RTCIceCandidate(deserialized)); + }); + + await connection.start(); +})(); \ No newline at end of file diff --git a/client/style.css b/client/style.css new file mode 100644 index 0000000..e69de29 diff --git a/server/WebRTCDemo.Server/Hubs/SignalingHub.cs b/server/WebRTCDemo.Server/Hubs/SignalingHub.cs new file mode 100644 index 0000000..530fc81 --- /dev/null +++ b/server/WebRTCDemo.Server/Hubs/SignalingHub.cs @@ -0,0 +1,24 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.SignalR; + +namespace WebRTCDemo.Server.Hubs +{ + public class SignalingHub : Hub + { + public override async Task OnConnectedAsync() + { + await Clients.All.SendAsync("UserConnected"); + await base.OnConnectedAsync(); + } + + public async Task Sdp(string message) + { + await Clients.Others.SendAsync("Sdp", message); + } + + public async Task Ice(string message) + { + await Clients.Others.SendAsync("Ice", message); + } + } +} \ No newline at end of file diff --git a/server/WebRTCDemo.Server/Program.cs b/server/WebRTCDemo.Server/Program.cs new file mode 100644 index 0000000..2c321fc --- /dev/null +++ b/server/WebRTCDemo.Server/Program.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace WebRTCDemo.Server +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); + } +} \ No newline at end of file diff --git a/server/WebRTCDemo.Server/Properties/launchSettings.json b/server/WebRTCDemo.Server/Properties/launchSettings.json new file mode 100644 index 0000000..2e8ac74 --- /dev/null +++ b/server/WebRTCDemo.Server/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:62084", + "sslPort": 44393 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "WebRTCDemo.Server": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/server/WebRTCDemo.Server/Startup.cs b/server/WebRTCDemo.Server/Startup.cs new file mode 100644 index 0000000..32ac1ce --- /dev/null +++ b/server/WebRTCDemo.Server/Startup.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.WebSockets; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using WebRTCDemo.Server.Hubs; + +namespace WebRTCDemo.Server +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddWebSockets(options => {}); + services.AddSignalR(); + services.AddControllers(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.UseCors( + options => options.AllowCredentials().WithOrigins("https://127.0.0.1:8080", "https://localhost:8080").AllowAnyMethod().AllowAnyHeader() + ); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseHttpsRedirection(); + + app.UseRouting(); + + app.UseWebSockets(); + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapHub("/signaling"); + endpoints.MapControllers(); + }); + } + } +} \ No newline at end of file diff --git a/server/WebRTCDemo.Server/WebRTCDemo.Server.csproj b/server/WebRTCDemo.Server/WebRTCDemo.Server.csproj new file mode 100644 index 0000000..68ded6d --- /dev/null +++ b/server/WebRTCDemo.Server/WebRTCDemo.Server.csproj @@ -0,0 +1,8 @@ + + + + netcoreapp3.1 + + + + diff --git a/server/WebRTCDemo.Server/WebRTCDemo.Server.sln b/server/WebRTCDemo.Server/WebRTCDemo.Server.sln new file mode 100644 index 0000000..05ae0b8 --- /dev/null +++ b/server/WebRTCDemo.Server/WebRTCDemo.Server.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebRTCDemo.Server", "WebRTCDemo.Server.csproj", "{BED3DE92-C087-446B-9B93-AA9982605340}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BED3DE92-C087-446B-9B93-AA9982605340}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BED3DE92-C087-446B-9B93-AA9982605340}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BED3DE92-C087-446B-9B93-AA9982605340}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BED3DE92-C087-446B-9B93-AA9982605340}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/server/WebRTCDemo.Server/appsettings.Development.json b/server/WebRTCDemo.Server/appsettings.Development.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/server/WebRTCDemo.Server/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/server/WebRTCDemo.Server/appsettings.json b/server/WebRTCDemo.Server/appsettings.json new file mode 100644 index 0000000..d9d9a9b --- /dev/null +++ b/server/WebRTCDemo.Server/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/server/WebRTCDemo.Server/global.json b/server/WebRTCDemo.Server/global.json new file mode 100644 index 0000000..70a59a3 --- /dev/null +++ b/server/WebRTCDemo.Server/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "3.1.201" + } +} \ No newline at end of file