Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valve sockets networking #465

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5506291
First go
Yamashi Oct 27, 2021
959e353
Fix weirdness with C++ callbacks
Yamashi Oct 27, 2021
d7eb965
Almost working fragmentation code
Yamashi Oct 27, 2021
ecf76e4
Fix bad fragmentation logic
Yamashi Oct 27, 2021
50a7c90
Update NetworkProvider.cs
Yamashi Oct 27, 2021
f08f700
Update NetworkProvider.cs
Yamashi Oct 27, 2021
3cb014e
Native DLLs now load correctly
Yamashi Oct 28, 2021
95a5aec
Clean up TODOs
Yamashi Oct 28, 2021
95c4ce6
Display ping as computed by the network layer
Yamashi Oct 28, 2021
8792ee5
Add reliable/unreliable packet handling
Yamashi Oct 28, 2021
8c3c2d5
Exception thrown when packet did not have the Network attributes
Yamashi Oct 28, 2021
5aa7658
FirstOrDefault's arg is the predicate not the value you want to return!
Yamashi Oct 28, 2021
e2af67e
Fix callback error when switching between Client and Server mode
Yamashi Oct 28, 2021
de3c05d
Delete websocket-sharp
Yamashi Oct 28, 2021
eef16c3
Release poll group when stopping the server
Yamashi Oct 28, 2021
ebc54a4
Some explanation regarding why we store a provider instance
Yamashi Oct 28, 2021
68665a1
Code convention & cleanup
Yamashi Oct 28, 2021
3309b7d
Cleanup
PhantomGamers Oct 28, 2021
fdb2a68
Show time it took to join in debug messages
PhantomGamers Sep 7, 2021
fdf96a1
enable VALVESOCKETS_SPAN
PhantomGamers Oct 28, 2021
a4ec19f
Fix reliable packets being reassembled unordered
Yamashi Oct 28, 2021
e02e6e9
Update GameNetworkingSockets prebuilt libs to 1.3.0
PhantomGamers Oct 29, 2021
3321783
Merge branch 'master' into pr/465
PhantomGamers Oct 29, 2021
c4f72c2
Run polling in a background thread
Yamashi Oct 29, 2021
91d2b85
Remove unused code
Yamashi Oct 29, 2021
cf984f2
abort worker thread on stop
PhantomGamers Oct 29, 2021
4c048f1
Revert "abort worker thread on stop"
PhantomGamers Oct 29, 2021
4bdd0ef
don't poll after client or server exits
PhantomGamers Oct 29, 2021
a812d43
sleep for longer if polling is disabled
PhantomGamers Oct 29, 2021
895eb14
Merge remote-tracking branch 'upstream/master' into valve-sockets
Yamashi Oct 31, 2021
46d3412
Merge branch 'master' into pr/465
PhantomGamers Nov 26, 2021
89966e4
update GameNetworkingSockets
PhantomGamers Nov 26, 2021
d23888f
Merge remote-tracking branch 'upstream/master' into valve-sockets
Yamashi Nov 28, 2021
4edc3f1
Fix packet decode failure
Yamashi Nov 28, 2021
b0005e4
Merge branch 'master' into pr/465
PhantomGamers Jan 6, 2022
2cc55e8
Merge commit '250968aa1847ab79970cf0601c95c047fa92604e' into valve-so…
starfi5h Feb 18, 2022
91f1801
merge-fix
starfi5h Feb 18, 2022
e322399
hide debug message
starfi5h Feb 18, 2022
b82a140
merge main 0.8.4
starfi5h Mar 19, 2022
2f30c54
Set SendRateMin 5 Mb/s, show progress during login
starfi5h Apr 20, 2022
c66a58d
Merge branch 'master' into @valve
starfi5h Apr 24, 2022
57387b0
Merge branch 'master' (0.8.6) into valve-socket
starfi5h Apr 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Nebula.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,22 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NebulaWorld", "NebulaWorld\NebulaWorld.csproj", "{28AEA139-FB22-4672-AF51-28B728CF2978}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "websocket-sharp", "dep\websocket-sharp\websocket-sharp\websocket-sharp.csproj", "{B357BAC7-529E-4D81-A0D2-71041B19C8DE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NebulaNetwork", "NebulaNetwork\NebulaNetwork.csproj", "{36A3D8AE-2A0A-4A1F-8A65-4FB61B01F779}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NebulaAPI", "NebulaAPI\NebulaAPI.csproj", "{B59DB3BB-DBA2-42AF-B4F1-32A9A6A273D2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NebulaAPI", "NebulaAPI\NebulaAPI.csproj", "{B59DB3BB-DBA2-42AF-B4F1-32A9A6A273D2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ValveSockets", "dep\valve.sockets\ValveSockets.csproj", "{D4EEDD8E-0ED6-4426-A3F0-3642A04434D6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{47B9362C-E91B-4AE4-979B-7D811AB4D1EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47B9362C-E91B-4AE4-979B-7D811AB4D1EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47B9362C-E91B-4AE4-979B-7D811AB4D1EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47B9362C-E91B-4AE4-979B-7D811AB4D1EA}.Release|Any CPU.Build.0 = Release|Any CPU
{C6237195-F77C-40C0-B06A-4AD51CAD314D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C6237195-F77C-40C0-B06A-4AD51CAD314D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6237195-F77C-40C0-B06A-4AD51CAD314D}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -39,22 +43,18 @@ Global
{28AEA139-FB22-4672-AF51-28B728CF2978}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28AEA139-FB22-4672-AF51-28B728CF2978}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28AEA139-FB22-4672-AF51-28B728CF2978}.Release|Any CPU.Build.0 = Release|Any CPU
{B357BAC7-529E-4D81-A0D2-71041B19C8DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B357BAC7-529E-4D81-A0D2-71041B19C8DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B357BAC7-529E-4D81-A0D2-71041B19C8DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B357BAC7-529E-4D81-A0D2-71041B19C8DE}.Release|Any CPU.Build.0 = Release|Any CPU
{36A3D8AE-2A0A-4A1F-8A65-4FB61B01F779}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{36A3D8AE-2A0A-4A1F-8A65-4FB61B01F779}.Debug|Any CPU.Build.0 = Debug|Any CPU
{36A3D8AE-2A0A-4A1F-8A65-4FB61B01F779}.Release|Any CPU.ActiveCfg = Release|Any CPU
{36A3D8AE-2A0A-4A1F-8A65-4FB61B01F779}.Release|Any CPU.Build.0 = Release|Any CPU
{47B9362C-E91B-4AE4-979B-7D811AB4D1EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47B9362C-E91B-4AE4-979B-7D811AB4D1EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47B9362C-E91B-4AE4-979B-7D811AB4D1EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47B9362C-E91B-4AE4-979B-7D811AB4D1EA}.Release|Any CPU.Build.0 = Release|Any CPU
{B59DB3BB-DBA2-42AF-B4F1-32A9A6A273D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B59DB3BB-DBA2-42AF-B4F1-32A9A6A273D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B59DB3BB-DBA2-42AF-B4F1-32A9A6A273D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B59DB3BB-DBA2-42AF-B4F1-32A9A6A273D2}.Release|Any CPU.Build.0 = Release|Any CPU
{D4EEDD8E-0ED6-4426-A3F0-3642A04434D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4EEDD8E-0ED6-4426-A3F0-3642A04434D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4EEDD8E-0ED6-4426-A3F0-3642A04434D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4EEDD8E-0ED6-4426-A3F0-3642A04434D6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
10 changes: 10 additions & 0 deletions NebulaAPI/Packets/NetworkOptionAttributes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace NebulaAPI
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class NetworkOptionsAttribute : Attribute
{
public bool Reliable = true;
}
}
2 changes: 1 addition & 1 deletion NebulaModel/NebulaModel.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\dep\websocket-sharp\websocket-sharp\websocket-sharp.csproj" />
<ProjectReference Include="..\dep\valve.sockets\ValveSockets.csproj" />
<ProjectReference Include="..\NebulaAPI\NebulaAPI.csproj" Private="false" />
</ItemGroup>

Expand Down
58 changes: 58 additions & 0 deletions NebulaModel/NetworkProvider.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using NebulaAPI;
using NebulaModel.Logger;
using NebulaModel.Networking.Serialization;
using System;
using System.Threading;
using Valve.Sockets;

namespace NebulaModel
{
Expand All @@ -10,12 +13,67 @@ public abstract class NetworkProvider : IDisposable, INetworkProvider

public IPlayerManager PlayerManager { get; }

protected static NetworkingSockets Sockets { get; private set; }

protected static NetworkingUtils Utils { get; private set; }

protected static NetworkProvider Provider { get; set; }

protected static Thread Worker { get; private set; }

protected static bool ShouldPoll { get; set; } = false;

static NetworkProvider()
{
Library.Initialize();

Sockets = new NetworkingSockets();
Utils = new NetworkingUtils();

#if DEBUG
Utils.SetDebugCallback(DebugType.Everything, (DebugType type, string message) =>
{
Log.Debug(message);
});
#endif

// We have to store a static instance to the current NetworkProvider as this callback comes from native code and
// therefore has to be a flat cdecl call, it cannot capture anything or have any context
Utils.SetStatusCallback((ref StatusInfo info) =>
{
Provider?.OnEvent(ref info);
});

// Set high speeds
Configuration configSendRateMax = new Configuration();
configSendRateMax.data.Int32 = 0x10000000;
configSendRateMax.dataType = ConfigurationDataType.Int32;
configSendRateMax.value = ConfigurationValue.SendRateMax;

Configuration configSendRateMin = new Configuration();
configSendRateMin.data.Int32 = 5 * 1024 * 1024; // Make it user configurable?
configSendRateMin.dataType = ConfigurationDataType.Int32;
configSendRateMin.value = ConfigurationValue.SendRateMin;

Configuration configSendBuffer = new Configuration();
configSendBuffer.data.Int32 = 0x1000000;
configSendBuffer.dataType = ConfigurationDataType.Int32;
configSendBuffer.value = ConfigurationValue.SendBufferSize;

Utils.SetConfigurationValue(configSendRateMax, ConfigurationScope.Global, new IntPtr());
Utils.SetConfigurationValue(configSendRateMin, ConfigurationScope.Global, new IntPtr());
Utils.SetConfigurationValue(configSendBuffer, ConfigurationScope.Global, new IntPtr());
}

protected NetworkProvider(IPlayerManager playerManager)
{
Provider = this;
PacketProcessor = new NetPacketProcessor();
PlayerManager = playerManager;
}

protected abstract void OnEvent(ref StatusInfo info);

public abstract void Start();

public abstract void Stop();
Expand Down
Loading