Skip to content
This repository has been archived by the owner on Jan 29, 2021. It is now read-only.

Update to Mirror 9 #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ LiteNetLib4Mirror/sysinfo.txt

# Crashlytics generated file
LiteNetLib4Mirror/crashlytics-build.properties
/.vs/slnx.sqlite
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
6 changes: 6 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file added .vs/slnx.sqlite
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -99,7 +99,7 @@ public bool StartServer(string serverIPv4BindAddress, string serverIPv6BindAddre
#endif
LiteNetLib4MirrorTransport.Singleton.port = port;
LiteNetLib4MirrorTransport.Singleton.maxConnections = maxPlayers;
return StartServer();
StartServer();
}

/// <summary>
Expand All @@ -126,7 +126,7 @@ public void StartHost(ushort port, ushort maxPlayers)
/// </summary>
/// <param name="port">Port</param>
/// <param name="maxPlayers">Connection limit</param>
public bool StartServer(ushort port, ushort maxPlayers)
public void StartServer(ushort port, ushort maxPlayers)
{
networkAddress = "127.0.0.1";
maxConnections = maxPlayers;
Expand All @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Net;
using LiteNetLib;
using LiteNetLib.Utils;
using LiteNetLib4Mirror.Open.Nat;
Expand Down Expand Up @@ -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;
Expand Down