From f60d76db9a975b71569baf48a081a808828724ee Mon Sep 17 00:00:00 2001 From: Derek S <44935661+Derek-R-S@users.noreply.github.com> Date: Mon, 5 Apr 2021 11:10:20 -0500 Subject: [PATCH 1/2] Git Ignores for solutions --- .../.gitignore | 362 ++++++++++++++++++ .../.gitignore | 362 ++++++++++++++++++ 2 files changed, 724 insertions(+) create mode 100644 LoadBalancerProject-DONT-IMPORT-INTO-UNITY/.gitignore create mode 100644 ServerProject-DONT-IMPORT-INTO-UNITY/.gitignore diff --git a/LoadBalancerProject-DONT-IMPORT-INTO-UNITY/.gitignore b/LoadBalancerProject-DONT-IMPORT-INTO-UNITY/.gitignore new file mode 100644 index 0000000..3a8542d --- /dev/null +++ b/LoadBalancerProject-DONT-IMPORT-INTO-UNITY/.gitignore @@ -0,0 +1,362 @@ +## 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 + +# 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 +coverage*.xml +coverage*.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/ServerProject-DONT-IMPORT-INTO-UNITY/.gitignore b/ServerProject-DONT-IMPORT-INTO-UNITY/.gitignore new file mode 100644 index 0000000..3a8542d --- /dev/null +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/.gitignore @@ -0,0 +1,362 @@ +## 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 + +# 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 +coverage*.xml +coverage*.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 From 77cd0ca4eb096090e87536e1ca5e09d6862304a3 Mon Sep 17 00:00:00 2001 From: Derek S <44935661+Derek-R-S@users.noreply.github.com> Date: Mon, 5 Apr 2021 11:11:38 -0500 Subject: [PATCH 2/2] LRM VS Solution --- ServerProject-DONT-IMPORT-INTO-UNITY/LRM.sln | 25 +++ .../{ => LRM}/BiDictionary.cs | 0 .../{ => LRM}/Compression.cs | 120 +++++------ .../{ => LRM}/Config.cs | 0 .../{ => LRM}/DataHandler.cs | 0 .../{ => LRM}/Endpoint.cs | 202 +++++++++--------- .../LRM/FodyWeavers.xml | 3 + .../LRM/LRM.csproj | 25 +++ .../{ => LRM}/Program.cs | 0 .../{ => LRM}/RelayHandler.cs | 0 .../{ => LRM}/Room.cs | 0 .../{ => LRM}/Transport.cs | 0 12 files changed, 214 insertions(+), 161 deletions(-) create mode 100644 ServerProject-DONT-IMPORT-INTO-UNITY/LRM.sln rename ServerProject-DONT-IMPORT-INTO-UNITY/{ => LRM}/BiDictionary.cs (100%) rename ServerProject-DONT-IMPORT-INTO-UNITY/{ => LRM}/Compression.cs (97%) rename ServerProject-DONT-IMPORT-INTO-UNITY/{ => LRM}/Config.cs (100%) rename ServerProject-DONT-IMPORT-INTO-UNITY/{ => LRM}/DataHandler.cs (100%) rename ServerProject-DONT-IMPORT-INTO-UNITY/{ => LRM}/Endpoint.cs (96%) create mode 100644 ServerProject-DONT-IMPORT-INTO-UNITY/LRM/FodyWeavers.xml create mode 100644 ServerProject-DONT-IMPORT-INTO-UNITY/LRM/LRM.csproj rename ServerProject-DONT-IMPORT-INTO-UNITY/{ => LRM}/Program.cs (100%) rename ServerProject-DONT-IMPORT-INTO-UNITY/{ => LRM}/RelayHandler.cs (100%) rename ServerProject-DONT-IMPORT-INTO-UNITY/{ => LRM}/Room.cs (100%) rename ServerProject-DONT-IMPORT-INTO-UNITY/{ => LRM}/Transport.cs (100%) diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM.sln b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM.sln new file mode 100644 index 0000000..377e7f0 --- /dev/null +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31129.286 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LRM", "LRM\LRM.csproj", "{BA0E55C8-6B24-4690-AC55-1DDDB4F7C05F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BA0E55C8-6B24-4690-AC55-1DDDB4F7C05F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BA0E55C8-6B24-4690-AC55-1DDDB4F7C05F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BA0E55C8-6B24-4690-AC55-1DDDB4F7C05F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BA0E55C8-6B24-4690-AC55-1DDDB4F7C05F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3B4C70D2-0DA3-4638-9D5E-03F35729DC2B} + EndGlobalSection +EndGlobal diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/BiDictionary.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/BiDictionary.cs similarity index 100% rename from ServerProject-DONT-IMPORT-INTO-UNITY/BiDictionary.cs rename to ServerProject-DONT-IMPORT-INTO-UNITY/LRM/BiDictionary.cs diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/Compression.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Compression.cs similarity index 97% rename from ServerProject-DONT-IMPORT-INTO-UNITY/Compression.cs rename to ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Compression.cs index ce43d6b..5eac1a5 100644 --- a/ServerProject-DONT-IMPORT-INTO-UNITY/Compression.cs +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Compression.cs @@ -1,60 +1,60 @@ -using System; -using System.IO; -using System.IO.Compression; -using System.Text; - -namespace LightReflectiveMirror.Compression -{ - internal static class StringCompressor - { - /// - /// Compresses the string. - /// - /// The text. - /// - public static string Compress(this string text) - { - byte[] buffer = Encoding.UTF8.GetBytes(text); - var memoryStream = new MemoryStream(); - using (var gZipStream = new GZipStream(memoryStream, CompressionMode.Compress, true)) - { - gZipStream.Write(buffer, 0, buffer.Length); - } - - memoryStream.Position = 0; - - var compressedData = new byte[memoryStream.Length]; - memoryStream.Read(compressedData, 0, compressedData.Length); - - var gZipBuffer = new byte[compressedData.Length + 4]; - Buffer.BlockCopy(compressedData, 0, gZipBuffer, 4, compressedData.Length); - Buffer.BlockCopy(BitConverter.GetBytes(buffer.Length), 0, gZipBuffer, 0, 4); - return Convert.ToBase64String(gZipBuffer); - } - - /// - /// Decompresses the string. - /// - /// The compressed text. - /// - public static string Decompress(this string compressedText) - { - byte[] gZipBuffer = Convert.FromBase64String(compressedText); - using (var memoryStream = new MemoryStream()) - { - int dataLength = BitConverter.ToInt32(gZipBuffer, 0); - memoryStream.Write(gZipBuffer, 4, gZipBuffer.Length - 4); - - var buffer = new byte[dataLength]; - - memoryStream.Position = 0; - using (var gZipStream = new GZipStream(memoryStream, CompressionMode.Decompress)) - { - gZipStream.Read(buffer, 0, buffer.Length); - } - - return Encoding.UTF8.GetString(buffer); - } - } - } -} +using System; +using System.IO; +using System.IO.Compression; +using System.Text; + +namespace LightReflectiveMirror.Compression +{ + internal static class StringCompressor + { + /// + /// Compresses the string. + /// + /// The text. + /// + public static string Compress(this string text) + { + byte[] buffer = Encoding.UTF8.GetBytes(text); + var memoryStream = new MemoryStream(); + using (var gZipStream = new GZipStream(memoryStream, CompressionMode.Compress, true)) + { + gZipStream.Write(buffer, 0, buffer.Length); + } + + memoryStream.Position = 0; + + var compressedData = new byte[memoryStream.Length]; + memoryStream.Read(compressedData, 0, compressedData.Length); + + var gZipBuffer = new byte[compressedData.Length + 4]; + Buffer.BlockCopy(compressedData, 0, gZipBuffer, 4, compressedData.Length); + Buffer.BlockCopy(BitConverter.GetBytes(buffer.Length), 0, gZipBuffer, 0, 4); + return Convert.ToBase64String(gZipBuffer); + } + + /// + /// Decompresses the string. + /// + /// The compressed text. + /// + public static string Decompress(this string compressedText) + { + byte[] gZipBuffer = Convert.FromBase64String(compressedText); + using (var memoryStream = new MemoryStream()) + { + int dataLength = BitConverter.ToInt32(gZipBuffer, 0); + memoryStream.Write(gZipBuffer, 4, gZipBuffer.Length - 4); + + var buffer = new byte[dataLength]; + + memoryStream.Position = 0; + using (var gZipStream = new GZipStream(memoryStream, CompressionMode.Decompress)) + { + gZipStream.Read(buffer, 0, buffer.Length); + } + + return Encoding.UTF8.GetString(buffer); + } + } + } +} diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/Config.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Config.cs similarity index 100% rename from ServerProject-DONT-IMPORT-INTO-UNITY/Config.cs rename to ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Config.cs diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/DataHandler.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/DataHandler.cs similarity index 100% rename from ServerProject-DONT-IMPORT-INTO-UNITY/DataHandler.cs rename to ServerProject-DONT-IMPORT-INTO-UNITY/LRM/DataHandler.cs diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/Endpoint.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Endpoint.cs similarity index 96% rename from ServerProject-DONT-IMPORT-INTO-UNITY/Endpoint.cs rename to ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Endpoint.cs index e434d53..86af7ac 100644 --- a/ServerProject-DONT-IMPORT-INTO-UNITY/Endpoint.cs +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Endpoint.cs @@ -1,101 +1,101 @@ -using Grapevine; -using LightReflectiveMirror.Compression; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace LightReflectiveMirror.Endpoints -{ - [Serializable] - struct RelayStats - { - public int ConnectedClients; - public int RoomCount; - public int PublicRoomCount; - public TimeSpan Uptime; - } - - [RestResource] - public class Endpoint - { - private List _rooms { get => Program.instance.GetRooms(); } - - private RelayStats _stats { get => new RelayStats - { - ConnectedClients = Program.instance.GetConnections(), - RoomCount = Program.instance.GetRooms().Count, - PublicRoomCount = Program.instance.GetPublicRoomCount(), - Uptime = Program.instance.GetUptime() - }; } - - [RestRoute("Get", "/api/stats")] - public async Task Stats(IHttpContext context) - { - string json = JsonConvert.SerializeObject(_stats, Formatting.Indented); - await context.Response.SendResponseAsync(json); - } - - [RestRoute("Get", "/api/servers")] - public async Task ServerList(IHttpContext context) - { - if (Program.conf.EndpointServerList) - { - string json = JsonConvert.SerializeObject(_rooms, Formatting.Indented); - await context.Response.SendResponseAsync(json); - } - else - await context.Response.SendResponseAsync(HttpStatusCode.Forbidden); - } - - [RestRoute("Get", "/api/compressed/servers")] - public async Task ServerListCompressed(IHttpContext context) - { - if (Program.conf.EndpointServerList) - { - string json = JsonConvert.SerializeObject(_rooms); - await context.Response.SendResponseAsync(json.Compress()); - } - else - await context.Response.SendResponseAsync(HttpStatusCode.Forbidden); - } - } - - public class EndpointServer - { - public bool Start(ushort port = 8080) - { - try - { - var config = new ConfigurationBuilder() - .SetBasePath(System.IO.Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) - .Build(); - - var server = new RestServerBuilder(new ServiceCollection(), config, - (services) => - { - services.AddLogging(configure => configure.AddConsole()); - services.Configure(options => options.MinLevel = LogLevel.None); - }, (server) => - { - server.Prefixes.Add($"http://*:{port}/"); - }).Build(); - - server.Router.Options.SendExceptionMessages = false; - server.Start(); - - return true; - } - catch - { - return false; - } - - } - } -} - +using Grapevine; +using LightReflectiveMirror.Compression; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace LightReflectiveMirror.Endpoints +{ + [Serializable] + struct RelayStats + { + public int ConnectedClients; + public int RoomCount; + public int PublicRoomCount; + public TimeSpan Uptime; + } + + [RestResource] + public class Endpoint + { + private List _rooms { get => Program.instance.GetRooms(); } + + private RelayStats _stats { get => new RelayStats + { + ConnectedClients = Program.instance.GetConnections(), + RoomCount = Program.instance.GetRooms().Count, + PublicRoomCount = Program.instance.GetPublicRoomCount(), + Uptime = Program.instance.GetUptime() + }; } + + [RestRoute("Get", "/api/stats")] + public async Task Stats(IHttpContext context) + { + string json = JsonConvert.SerializeObject(_stats, Formatting.Indented); + await context.Response.SendResponseAsync(json); + } + + [RestRoute("Get", "/api/servers")] + public async Task ServerList(IHttpContext context) + { + if (Program.conf.EndpointServerList) + { + string json = JsonConvert.SerializeObject(_rooms, Formatting.Indented); + await context.Response.SendResponseAsync(json); + } + else + await context.Response.SendResponseAsync(HttpStatusCode.Forbidden); + } + + [RestRoute("Get", "/api/compressed/servers")] + public async Task ServerListCompressed(IHttpContext context) + { + if (Program.conf.EndpointServerList) + { + string json = JsonConvert.SerializeObject(_rooms); + await context.Response.SendResponseAsync(json.Compress()); + } + else + await context.Response.SendResponseAsync(HttpStatusCode.Forbidden); + } + } + + public class EndpointServer + { + public bool Start(ushort port = 8080) + { + try + { + var config = new ConfigurationBuilder() + .SetBasePath(System.IO.Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .Build(); + + var server = new RestServerBuilder(new ServiceCollection(), config, + (services) => + { + services.AddLogging(configure => configure.AddConsole()); + services.Configure(options => options.MinLevel = LogLevel.None); + }, (server) => + { + server.Prefixes.Add($"http://*:{port}/"); + }).Build(); + + server.Router.Options.SendExceptionMessages = false; + server.Start(); + + return true; + } + catch + { + return false; + } + + } + } +} + diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/FodyWeavers.xml b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/FodyWeavers.xml new file mode 100644 index 0000000..5029e70 --- /dev/null +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/LRM.csproj b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/LRM.csproj new file mode 100644 index 0000000..8ddfbee --- /dev/null +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/LRM.csproj @@ -0,0 +1,25 @@ + + + + Exe + net5.0 + + + + true + + + + true + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/Program.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Program.cs similarity index 100% rename from ServerProject-DONT-IMPORT-INTO-UNITY/Program.cs rename to ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Program.cs diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/RelayHandler.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/RelayHandler.cs similarity index 100% rename from ServerProject-DONT-IMPORT-INTO-UNITY/RelayHandler.cs rename to ServerProject-DONT-IMPORT-INTO-UNITY/LRM/RelayHandler.cs diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/Room.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Room.cs similarity index 100% rename from ServerProject-DONT-IMPORT-INTO-UNITY/Room.cs rename to ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Room.cs diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/Transport.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Transport.cs similarity index 100% rename from ServerProject-DONT-IMPORT-INTO-UNITY/Transport.cs rename to ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Transport.cs