Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit 0d08501

Browse files
mreinsteinhach-que
authored andcommitted
ported netcode.io.host to go #2 (#7)
* ported netcode.io.host to go * Update build scripts to build Go helper * Update README * Update README again * Remove .DS_Store * Remove demo server from build
1 parent e7f661f commit 0d08501

31 files changed

+720
-1292
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ netcode.io.wininstall/package.zip
1010
netcode.io.demoserver/.kube/
1111
netcode.io.wininstall/.vs/
1212
/browser/webext-selfdist/*.js
13+
14+
/netcode.io.host/netcode.io.host.exe
15+
/netcode.io.host/netcode.io.host

Jenkinsfile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@ stage('Build') {
22
node('windows') {
33
checkout scm
44
powershell '.\\build\\Build-Win32.ps1'
5-
stash includes: 'netcode.io.demoserver/**', name: 'demoserver'
65
archiveArtifacts 'output/**'
76
}
8-
}
9-
stage('Build Docker') {
10-
node('linux-docker') {
11-
unstash 'demoserver'
12-
sh 'cd netcode.io.demoserver && docker build . -t redpointgames/netcode-demo-server:latest'
13-
sh 'docker push redpointgames/netcode-demo-server:latest'
14-
}
157
}

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,25 @@ The easiest way to install netcode.io is to visit [the demo website](https://net
2121

2222
For this to work, it requires the installation of both a browser extension and a native application helper which performs the actual netcode.io communication. The extension uses the native messaging APIs provided in browsers in order to make netcode.io available via the helper.
2323

24-
To try this out in your browser, you'll first need to build the `netcode.io.host.sln` solution in Visual Studio, then run `Install-Windows.ps1` in Powershell, which will install the netcode.io helper into the Windows registry.
24+
To try this out in your browser, first build the netcode.io.host helper:
25+
26+
#### 1. Get dependencies
27+
```bash
28+
go get github.com/wirepair/netcode
29+
```
30+
31+
#### 2. Platform specific build instructions
32+
33+
* `go build` - for the current OS
34+
* `env GOOS=windows GOARCH=amd64 go build` - to build for Windows (linux-style to set environment variables)
35+
* `env GOOS=linux GOARCH=amd64 go build` - to build for Linux (linux-style to set environment variables)
36+
* `env GOOS=darwin GOARCH=amd64 go build` - to build for Mac (linux-style to set environment variables)
37+
38+
#### 3. Install (run this from the command-line)
39+
40+
`./netcode.io.host`
41+
42+
This should run with no errors, and install itself as a native messaging extension.
2543

2644
After this is done, add the `browser\webext` directory as an unpacked extension.
2745

build/Build-Win32.ps1

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ cd $PSScriptRoot\..
1414
$root = Get-Location
1515

1616
if (Test-Path $root\output) {
17-
rm -Recurse -Force $root\output
17+
Remove-Item -Recurse -Force $root\output
1818
}
1919
mkdir $root\output
2020

@@ -26,32 +26,30 @@ function ZipFiles( $zipfilename, $sourcedir )
2626
$zipfilename, $compressionLevel, $false)
2727
}
2828

29-
echo "Creating Web Extension ZIP (standard)..."
29+
Write-Output "Creating Web Extension ZIP (standard)..."
3030
ZipFiles -zipfilename $root\output\WebExtension.zip -sourcedir $root\browser\webext
3131

32-
echo "Creating Web Extension ZIP (self-dist)..."
33-
cp -Force $root\browser\webext\hostmsg.js $root\browser\webext-selfdist\
34-
cp -Force $root\browser\webext\netcode.js $root\browser\webext-selfdist\
35-
cp -Force $root\browser\webext\netcodecs.js $root\browser\webext-selfdist\
32+
Write-Output "Creating Web Extension ZIP (self-dist)..."
33+
Copy-Item -Force $root\browser\webext\hostmsg.js $root\browser\webext-selfdist\
34+
Copy-Item -Force $root\browser\webext\netcode.js $root\browser\webext-selfdist\
35+
Copy-Item -Force $root\browser\webext\netcodecs.js $root\browser\webext-selfdist\
3636
ZipFiles -zipfilename $root\output\WebExtension-SelfDist.zip -sourcedir $root\browser\webext-selfdist
3737

38-
echo "Building netcode.io helper..."
39-
if (Test-Path $root\netcode.io.host\bin\Release) {
40-
rm -Recurse -Force $root\netcode.io.host\bin\Release
41-
}
42-
if (Test-Path "C:\NuGet\nuget.exe") {
43-
& "C:\NuGet\nuget.exe" restore
44-
}
45-
& "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /m /p:Configuration=Release netcode.io.host.sln
46-
cp $root\browser\hostapp\manifest.windows.relative.chrome.json $root\netcode.io.host\bin\Release\manifest.windows.relative.chrome.json
47-
cp $root\browser\hostapp\manifest.windows.relative.firefox.json $root\netcode.io.host\bin\Release\manifest.windows.relative.firefox.json
48-
49-
echo "Packaging netcode.io helper..."
50-
if (Test-Path $root\netcode.io.wininstall\package.zip) {
51-
rm -Force $root\netcode.io.wininstall\package.zip
52-
}
53-
ZipFiles -zipfilename $root\netcode.io.wininstall\package.zip -sourcedir $root\netcode.io.host\bin\Release
54-
55-
echo "Building netcode.io Windows installer..."
56-
& "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /m /p:Configuration=Release netcode.io.wininstall\netcode.io.wininstall.csproj
57-
cp netcode.io.wininstall\bin\Release\netcode.io.wininstall.exe output\NetcodeInstaller.exe
38+
Write-Output "Building netcode.io helper / installers..."
39+
Push-Location netcode.io.host
40+
try {
41+
go get github.com/wirepair/netcode
42+
go get golang.org/x/sys/windows/registry
43+
$env:GOARCH="amd64"
44+
$env:GOOS="windows"
45+
go build
46+
Move-Item -Force netcode.io.host.exe ..\output\NetcodeInstaller-Windows.exe
47+
$env:GOOS="darwin"
48+
go build
49+
Move-Item -Force netcode.io.host ..\output\NetcodeInstaller-macOS
50+
$env:GOOS="linux"
51+
go build
52+
Move-Item -Force netcode.io.host ..\output\NetcodeInstaller-Linux
53+
} finally {
54+
Pop-Location
55+
}

netcode.io.host/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
netcode.io.host

netcode.io.host/App.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)