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

Transport Rewrite #679

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
751fc45
starting on interfaces
James-Frowen Mar 9, 2021
35e2e69
adding methods to socket and using endpoint
James-Frowen Mar 9, 2021
6fff3b5
udp socket
James-Frowen Mar 9, 2021
a186797
moving buffer outside ISocket
James-Frowen Mar 9, 2021
2a572c1
adding bytesReceived to recieve
James-Frowen Mar 9, 2021
e04109e
adding bind/close to Isocket
James-Frowen Mar 9, 2021
f7cf9e8
adding supported to transportv2
James-Frowen Mar 9, 2021
bdaeb07
adding ReceiveLoop
James-Frowen Mar 9, 2021
6780e50
dropping raw from name
James-Frowen Mar 9, 2021
d610844
fixing typo
James-Frowen Mar 9, 2021
9468637
moving types to their own files
James-Frowen Mar 9, 2021
f939176
removing to and swapping order
James-Frowen Mar 9, 2021
a110271
splitting createsocket to server/client
James-Frowen Mar 9, 2021
a6ad740
adding Connect
James-Frowen Mar 9, 2021
fadbae7
adding new connections to ReceiveLoop
James-Frowen Mar 9, 2021
2689320
adding Validate for new connections
James-Frowen Mar 9, 2021
0066bcb
namespace
James-Frowen Mar 9, 2021
8ba241d
new connection stuff
James-Frowen Mar 9, 2021
c05e3ec
removing Obsolete error
James-Frowen Mar 11, 2021
0819a35
making send methods private
James-Frowen Mar 11, 2021
9764c57
adding send notify and unreliable
James-Frowen Mar 11, 2021
01d7355
adding on connection update
James-Frowen Mar 11, 2021
46d5a0d
more connection updates
James-Frowen Mar 11, 2021
4d7722d
implementing HandleCommand
James-Frowen Mar 11, 2021
4bc6f1b
implementing connect method
James-Frowen Mar 11, 2021
c17ddbe
adding PeerUpdater
James-Frowen Mar 11, 2021
d0f5b8f
Starting to use New Peer clas
James-Frowen Mar 11, 2021
9029af5
moving SocketLayer to its own asmdef
James-Frowen Mar 11, 2021
d8de89f
adding reference to socket layer
James-Frowen Mar 11, 2021
bf9239e
implemenent part of receive and making networkplayer sealed
James-Frowen Mar 11, 2021
b4bb4a0
implementing udp trasnport
James-Frowen Mar 11, 2021
cf9df6b
Peer.Connect return Connection
James-Frowen Mar 24, 2021
749f17d
fixing logger not found
James-Frowen Mar 24, 2021
0a6599d
NetworkWorld
James-Frowen Mar 25, 2021
38312aa
Message broker
James-Frowen Mar 25, 2021
f2a9853
fixing compile errors in runtime
James-Frowen Mar 25, 2021
a9da428
adding IDataHandler to peer
James-Frowen Mar 26, 2021
158ded0
using IdataHandler and starting to remove InetworkPlayer
James-Frowen Mar 26, 2021
ad99197
fully removng INetworkPlayers
James-Frowen Mar 26, 2021
49d6a8d
removing message handler
James-Frowen Mar 26, 2021
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
2 changes: 1 addition & 1 deletion Assets/Mirage/Authenticators/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using System.Reflection;

[assembly: AssemblyVersion("82.0.0")]
[assembly: AssemblyVersion("84.0.0")]
14 changes: 7 additions & 7 deletions Assets/Mirage/Authenticators/BasicAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public struct AuthResponseMessage
public string Message;
}

public override void OnServerAuthenticate(INetworkPlayer player)
public override void OnServerAuthenticate(NetworkPlayer player)
{
// wait for AuthRequestMessage from client
player.RegisterHandler<AuthRequestMessage>(OnAuthRequestMessage);
player.MessageReceiver.RegisterHandler<AuthRequestMessage>(OnAuthRequestMessage);
}

public override void OnClientAuthenticate(INetworkPlayer player)
public override void OnClientAuthenticate(NetworkPlayer player)
{
player.RegisterHandler<AuthResponseMessage>(OnAuthResponseMessage);
player.MessageReceiver.RegisterHandler<AuthResponseMessage>(OnAuthResponseMessage);

var authRequestMessage = new AuthRequestMessage
{
Expand All @@ -46,7 +46,7 @@ public override void OnClientAuthenticate(INetworkPlayer player)
player.Send(authRequestMessage);
}

public void OnAuthRequestMessage(INetworkPlayer player, AuthRequestMessage msg)
public void OnAuthRequestMessage(NetworkPlayer player, AuthRequestMessage msg)
{
if (logger.LogEnabled()) logger.LogFormat(LogType.Log, "Authentication Request: {0} {1}", msg.AuthUsername, msg.AuthPassword);

Expand Down Expand Up @@ -81,13 +81,13 @@ public void OnAuthRequestMessage(INetworkPlayer player, AuthRequestMessage msg)
}
}

public IEnumerator DelayedDisconnect(INetworkPlayer player, float waitTime)
public IEnumerator DelayedDisconnect(NetworkPlayer player, float waitTime)
{
yield return new WaitForSeconds(waitTime);
player.Connection?.Disconnect();
}

public void OnAuthResponseMessage(INetworkPlayer player, AuthResponseMessage msg)
public void OnAuthResponseMessage(NetworkPlayer player, AuthResponseMessage msg)
{
if (msg.Code == 100)
{
Expand Down
12 changes: 6 additions & 6 deletions Assets/Mirage/Authenticators/TimeoutAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ public void Awake()
Authenticator.OnServerAuthenticated += HandleServerAuthenticated;
}

private readonly HashSet<INetworkPlayer> pendingAuthentication = new HashSet<INetworkPlayer>();
private readonly HashSet<NetworkPlayer> pendingAuthentication = new HashSet<NetworkPlayer>();

private void HandleServerAuthenticated(INetworkPlayer player)
private void HandleServerAuthenticated(NetworkPlayer player)
{
pendingAuthentication.Remove(player);
base.OnClientAuthenticate(player);
}

private void HandleClientAuthenticated(INetworkPlayer player)
private void HandleClientAuthenticated(NetworkPlayer player)
{
pendingAuthentication.Remove(player);
base.OnServerAuthenticate(player);
}

public override void OnClientAuthenticate(INetworkPlayer player)
public override void OnClientAuthenticate(NetworkPlayer player)
{
pendingAuthentication.Add(player);
Authenticator.OnClientAuthenticate(player);
Expand All @@ -48,15 +48,15 @@ public override void OnClientAuthenticate(INetworkPlayer player)
StartCoroutine(BeginAuthentication(player));
}

public override void OnServerAuthenticate(INetworkPlayer player)
public override void OnServerAuthenticate(NetworkPlayer player)
{
pendingAuthentication.Add(player);
Authenticator.OnServerAuthenticate(player);
if (Timeout > 0)
StartCoroutine(BeginAuthentication(player));
}

IEnumerator BeginAuthentication(INetworkPlayer player)
IEnumerator BeginAuthentication(NetworkPlayer player)
{
if (logger.LogEnabled()) logger.Log($"Authentication countdown started {player} {Timeout}");

Expand Down
24 changes: 24 additions & 0 deletions Assets/Mirage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# [84.0.0](https://github.com/MirageNet/Mirage/compare/v83.0.0...v84.0.0) (2021-03-24)


### Code Refactoring

* using interface instead of network server ([#722](https://github.com/MirageNet/Mirage/issues/722)) ([7312bd8](https://github.com/MirageNet/Mirage/commit/7312bd8cd83f2133f9d0a6162dea9689630d88f2))


### BREAKING CHANGES

* fields and parameters using NetworkServer are now using INetworkServer Instead

# [83.0.0](https://github.com/MirageNet/Mirage/compare/v82.0.0...v83.0.0) (2021-03-24)


### Code Refactoring

* using interface instead of network client ([#721](https://github.com/MirageNet/Mirage/issues/721)) ([703596a](https://github.com/MirageNet/Mirage/commit/703596aa4678eeef6e6e89b8877fceb8062e4476))


### BREAKING CHANGES

* fields and parameters using NetworkClient are now using INetworkClient Instead

# [82.0.0](https://github.com/MirageNet/Mirage/compare/v81.0.2...v82.0.0) (2021-03-24)


Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirage/Components/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using System.Reflection;

[assembly: AssemblyVersion("82.0.0")]
[assembly: AssemblyVersion("84.0.0")]
3 changes: 1 addition & 2 deletions Assets/Mirage/Components/HeadlessAutoStart.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Serialization;
Expand All @@ -24,7 +23,7 @@ void Start()
// some transports might not be ready until Start.
if (Server && SystemInfo.graphicsDeviceType == GraphicsDeviceType.Null && startOnHeadless)
{
Server.ListenAsync().Forget();
Server.Listen();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirage/Components/LobbyReady.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class LobbyReady : MonoBehaviour

// just a cached memory area where we can collect connections
// for broadcasting messages
private static readonly List<INetworkPlayer> playerCache = new List<INetworkPlayer>();
private static readonly List<NetworkPlayer> playerCache = new List<NetworkPlayer>();

public void SetAllClientsNotReady()
{
Expand Down
4 changes: 2 additions & 2 deletions Assets/Mirage/Components/NetworkMatchChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void RebuildMatchObservers(Guid specificMatch)
/// </summary>
/// <param name="player">Network connection of a player.</param>
/// <returns>True if the player can see this object.</returns>
public override bool OnCheckObserver(INetworkPlayer player)
public override bool OnCheckObserver(NetworkPlayer player)
{
// Not Visible if not in a match
if (MatchId == Guid.Empty)
Expand All @@ -125,7 +125,7 @@ public override bool OnCheckObserver(INetworkPlayer player)
/// </summary>
/// <param name="observers">The new set of observers for this object.</param>
/// <param name="initialize">True if the set of observers is being built for the first time.</param>
public override void OnRebuildObservers(HashSet<INetworkPlayer> observers, bool initialize)
public override void OnRebuildObservers(HashSet<NetworkPlayer> observers, bool initialize)
{
if (currentMatch == Guid.Empty) return;

Expand Down
6 changes: 3 additions & 3 deletions Assets/Mirage/Components/NetworkProximityChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void RebuildObservers()

/// <param name="player">Network connection of a player.</param>
/// <returns>True if the player can see this object.</returns>
public override bool OnCheckObserver(INetworkPlayer player)
public override bool OnCheckObserver(NetworkPlayer player)
{
if (ForceHidden)
return false;
Expand All @@ -73,7 +73,7 @@ public override bool OnCheckObserver(INetworkPlayer player)
/// </summary>
/// <param name="observers">The new set of observers for this object.</param>
/// <param name="initialize">True if the set of observers is being built for the first time.</param>
public override void OnRebuildObservers(HashSet<INetworkPlayer> observers, bool initialize)
public override void OnRebuildObservers(HashSet<NetworkPlayer> observers, bool initialize)
{
// if force hidden then return without adding any observers.
if (ForceHidden)
Expand All @@ -89,7 +89,7 @@ public override void OnRebuildObservers(HashSet<INetworkPlayer> observers, bool
// magnitude faster. if we have 10k monsters and run a sphere
// cast 10k times, we will see a noticeable lag even with physics
// layers. but checking to every connection is fast.
foreach (INetworkPlayer player in Server.Players)
foreach (NetworkPlayer player in Server.Players)
{
// check distance
if (player != null && player.Identity != null && Vector3.Distance(player.Identity.transform.position, position) < VisibilityRange)
Expand Down
4 changes: 2 additions & 2 deletions Assets/Mirage/Components/NetworkSceneChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void RebuildSceneObservers()
/// </summary>
/// <param name="player">Network connection of a player.</param>
/// <returns>True if the player can see this object.</returns>
public override bool OnCheckObserver(INetworkPlayer player)
public override bool OnCheckObserver(NetworkPlayer player)
{
if (forceHidden)
return false;
Expand All @@ -103,7 +103,7 @@ public override bool OnCheckObserver(INetworkPlayer player)
/// </summary>
/// <param name="observers">The new set of observers for this object.</param>
/// <param name="initialize">True if the set of observers is being built for the first time.</param>
public override void OnRebuildObservers(HashSet<INetworkPlayer> observers, bool initialize)
public override void OnRebuildObservers(HashSet<NetworkPlayer> observers, bool initialize)
{
// If forceHidden then return without adding any observers.
if (forceHidden)
Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirage/Editor/NetworkInformationPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ float DrawObservers(NetworkIdentity identity, float initialX, float Y)
observerRect.x += 20;
observerRect.y += observerRect.height;

foreach (INetworkPlayer player in identity.observers)
foreach (NetworkPlayer player in identity.observers)
{
GUI.Label(observerRect, player.Connection.GetEndPointAddress() + ":" + player, styles.ComponentName);
observerRect.y += observerRect.height;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirage/Editor/NetworkMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static GameObject CreateNetworkManager()
networkClient.Transport = transport;

NetworkServer networkServer = go.GetComponent<NetworkServer>();
networkServer.Transport = transport;
networkServer.Peer = transport;

ServerObjectManager serverObjectManager = go.GetComponent<ServerObjectManager>();
serverObjectManager.Server = networkServer;
Expand Down
3 changes: 2 additions & 1 deletion Assets/Mirage/Mirage.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "Mirage",
"references": [
"UniTask",
"UniTask.Linq"
"UniTask.Linq",
"Mirage.SocketLayer"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirage/Runtime/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: AssemblyVersion("82.0.0")]
[assembly: AssemblyVersion("84.0.0")]

[assembly: InternalsVisibleTo("Mirage.Tests.Common")]
[assembly: InternalsVisibleTo("Mirage.Tests")]
Expand Down
8 changes: 4 additions & 4 deletions Assets/Mirage/Runtime/CharacterSpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ void OnDestroy()
}
}

private void OnServerAuthenticated(INetworkPlayer player)
private void OnServerAuthenticated(NetworkPlayer player)
{
// wait for client to send us an AddPlayerMessage
player.RegisterHandler<AddCharacterMessage>(OnServerAddPlayerInternal);
Server.MessageReceiver.RegisterHandler<AddCharacterMessage>(OnServerAddPlayerInternal);
}

/// <summary>
Expand All @@ -104,7 +104,7 @@ public virtual void RequestServerSpawnPlayer()
Client.Send(new AddCharacterMessage());
}

void OnServerAddPlayerInternal(INetworkPlayer player, AddCharacterMessage msg)
void OnServerAddPlayerInternal(NetworkPlayer player, AddCharacterMessage msg)
{
logger.Log("CharacterSpawner.OnServerAddPlayer");

Expand All @@ -121,7 +121,7 @@ void OnServerAddPlayerInternal(INetworkPlayer player, AddCharacterMessage msg)
/// <para>The default implementation for this function creates a new player object from the playerPrefab.</para>
/// </summary>
/// <param name="player">Connection from client.</param>
public virtual void OnServerAddPlayer(INetworkPlayer player)
public virtual void OnServerAddPlayer(NetworkPlayer player)
{
Transform startPos = GetStartPosition();
NetworkIdentity character = startPos != null
Expand Down
Loading