diff --git a/.gitignore b/.gitignore index a4df080..8f3fde8 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ LiteNetLib4Mirror/sysinfo.txt # Crashlytics generated file LiteNetLib4Mirror/crashlytics-build.properties +/.vs/slnx.sqlite diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json new file mode 100644 index 0000000..f8b4888 --- /dev/null +++ b/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": null +} \ No newline at end of file diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 0000000..6b61141 --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,6 @@ +{ + "ExpandedNodes": [ + "" + ], + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000..1fda735 Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/LiteNetLib4Mirror/Assets/Mirror/Runtime/Transport/LiteNetLib4Mirror/LiteNetLib4MirrorNetworkManager.cs b/LiteNetLib4Mirror/Assets/Mirror/Runtime/Transport/LiteNetLib4Mirror/LiteNetLib4MirrorNetworkManager.cs index 08607ce..aa3046c 100644 --- a/LiteNetLib4Mirror/Assets/Mirror/Runtime/Transport/LiteNetLib4Mirror/LiteNetLib4MirrorNetworkManager.cs +++ b/LiteNetLib4Mirror/Assets/Mirror/Runtime/Transport/LiteNetLib4Mirror/LiteNetLib4MirrorNetworkManager.cs @@ -87,7 +87,7 @@ public void StartHost(string serverIPv4BindAddress, string serverIPv6BindAddress #if DISABLE_IPV6 public bool StartServer(string serverIPv4BindAddress, ushort port, ushort maxPlayers) #else - public bool StartServer(string serverIPv4BindAddress, string serverIPv6BindAddress, ushort port, ushort maxPlayers) + public void StartServer(string serverIPv4BindAddress, string serverIPv6BindAddress, ushort port, ushort maxPlayers) #endif { networkAddress = serverIPv4BindAddress; @@ -99,7 +99,7 @@ public bool StartServer(string serverIPv4BindAddress, string serverIPv6BindAddre #endif LiteNetLib4MirrorTransport.Singleton.port = port; LiteNetLib4MirrorTransport.Singleton.maxConnections = maxPlayers; - return StartServer(); + StartServer(); } /// @@ -126,7 +126,7 @@ public void StartHost(ushort port, ushort maxPlayers) /// /// Port /// Connection limit - public bool StartServer(ushort port, ushort maxPlayers) + public void StartServer(ushort port, ushort maxPlayers) { networkAddress = "127.0.0.1"; maxConnections = maxPlayers; @@ -136,14 +136,14 @@ public bool StartServer(ushort port, ushort maxPlayers) #endif LiteNetLib4MirrorTransport.Singleton.port = port; LiteNetLib4MirrorTransport.Singleton.maxConnections = maxPlayers; - return StartServer(); + StartServer(); } public void DisconnectConnection(NetworkConnection conn, string message = null) { LiteNetLib4MirrorServer.DisconnectMessage = message; conn.Disconnect(); - conn.Dispose(); + //conn.Dispose(); LiteNetLib4MirrorServer.DisconnectMessage = null; } } diff --git a/LiteNetLib4Mirror/Assets/Mirror/Runtime/Transport/LiteNetLib4Mirror/LiteNetLib4MirrorTransport.cs b/LiteNetLib4Mirror/Assets/Mirror/Runtime/Transport/LiteNetLib4Mirror/LiteNetLib4MirrorTransport.cs index 393b131..881b038 100644 --- a/LiteNetLib4Mirror/Assets/Mirror/Runtime/Transport/LiteNetLib4Mirror/LiteNetLib4MirrorTransport.cs +++ b/LiteNetLib4Mirror/Assets/Mirror/Runtime/Transport/LiteNetLib4Mirror/LiteNetLib4MirrorTransport.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Net; using LiteNetLib; using LiteNetLib.Utils; using LiteNetLib4Mirror.Open.Nat; @@ -180,6 +181,30 @@ private void OnDestroy() #endregion #region Transport Overrides + public const string Scheme = "litenet"; + + public override Uri ServerUri() + { + UriBuilder builder = new UriBuilder(); + builder.Scheme = Scheme; + builder.Host = Dns.GetHostName(); + builder.Port = port; + return builder.Uri; + } + + public override void ClientConnect(Uri uri) + { + if (uri.Scheme != Scheme) + throw new ArgumentException($"Invalid url {uri}, use {Scheme}://host:port instead", nameof(uri)); + + port = uri.IsDefaultPort ? port : (ushort)uri.Port; + clientAddress = uri.Host; + + ConnectWriter.Reset(); + GetConnectData(ConnectWriter); + LiteNetLib4MirrorClient.ConnectClient(ConnectWriter); + } + public override bool Available() { return Application.platform != RuntimePlatform.WebGLPlayer;