mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Merged master
This commit is contained in:
commit
e5c13d06c6
@ -540,14 +540,6 @@ void FinishStartHost()
|
||||
public void StopHost()
|
||||
{
|
||||
OnStopHost();
|
||||
|
||||
// calling OnTransportDisconnected was needed to fix
|
||||
// https://github.com/vis2k/Mirror/issues/1515
|
||||
// so that the host client receives a DisconnectMessage
|
||||
// TODO reevaluate if this is still needed after all the disconnect
|
||||
// fixes, and try to put this into LocalConnection.Disconnect!
|
||||
NetworkServer.OnTransportDisconnected(NetworkConnection.LocalConnectionId);
|
||||
|
||||
StopClient();
|
||||
StopServer();
|
||||
}
|
||||
@ -600,6 +592,12 @@ public void StopClient()
|
||||
if (mode == NetworkManagerMode.Offline)
|
||||
return;
|
||||
|
||||
// For Host client, call OnServerDisconnect before NetworkClient.Disconnect
|
||||
// because we need NetworkServer.localConnection to not be null
|
||||
// NetworkClient.Disconnect will set it null.
|
||||
if (mode == NetworkManagerMode.Host)
|
||||
OnServerDisconnect(NetworkServer.localConnection);
|
||||
|
||||
// ask client -> transport to disconnect.
|
||||
// handle voluntary and involuntary disconnects in OnClientDisconnect.
|
||||
//
|
||||
|
@ -335,11 +335,7 @@ public static Sprite ReadSprite(this NetworkReader reader)
|
||||
return Sprite.Create(texture, reader.ReadRect(), reader.ReadVector2());
|
||||
}
|
||||
|
||||
public static DateTime ReadDateTime(this NetworkReader reader)
|
||||
{
|
||||
return DateTime.FromOADate(reader.ReadDouble());
|
||||
}
|
||||
|
||||
public static DateTime ReadDateTime(this NetworkReader reader) => DateTime.FromOADate(reader.ReadDouble());
|
||||
public static DateTime? ReadDateTimeNullable(this NetworkReader reader) => reader.ReadBool() ? ReadDateTime(reader) : default(DateTime?);
|
||||
}
|
||||
}
|
||||
|
@ -127,8 +127,8 @@ public static double TimelineClamp(
|
||||
// we define a boundary of 'bufferTime' around the target time.
|
||||
// this is where catchup / slowdown will happen.
|
||||
// outside of the area, we clamp.
|
||||
double lowerBound = targetTime - bufferTime;
|
||||
double upperBound = targetTime + bufferTime;
|
||||
double lowerBound = targetTime - bufferTime; // how far behind we can get
|
||||
double upperBound = targetTime + bufferTime; // how far ahead we can get
|
||||
return Mathd.Clamp(localTimeline, lowerBound, upperBound);
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,10 @@ public class ClientCube : MonoBehaviour
|
||||
|
||||
void Awake()
|
||||
{
|
||||
// show vsync reminder. too easy to forget.
|
||||
Debug.Log("Reminder: Snapshot interpolation is smoothest & easiest to debug with Vsync off.");
|
||||
|
||||
|
||||
defaultColor = render.sharedMaterial.color;
|
||||
|
||||
// initialize EMA with 'emaDuration' seconds worth of history.
|
||||
@ -173,14 +177,37 @@ void OnGUI()
|
||||
{
|
||||
lowFpsMode = !lowFpsMode;
|
||||
}
|
||||
if (GUILayout.Button("Timeline 100ms behind"))
|
||||
|
||||
GUILayout.Label("|");
|
||||
|
||||
if (GUILayout.Button("Timeline 10s behind"))
|
||||
{
|
||||
localTimeline -= 10.0;
|
||||
}
|
||||
if (GUILayout.Button("Timeline 1s behind"))
|
||||
{
|
||||
localTimeline -= 1.0;
|
||||
}
|
||||
if (GUILayout.Button("Timeline 0.1s behind"))
|
||||
{
|
||||
localTimeline -= 0.1;
|
||||
}
|
||||
if (GUILayout.Button("Timeline 100ms ahead"))
|
||||
|
||||
GUILayout.Label("|");
|
||||
|
||||
if (GUILayout.Button("Timeline 0.1s ahead"))
|
||||
{
|
||||
localTimeline += 0.1;
|
||||
}
|
||||
if (GUILayout.Button("Timeline 1s ahead"))
|
||||
{
|
||||
localTimeline += 1.0;
|
||||
}
|
||||
if (GUILayout.Button("Timeline 10s ahead"))
|
||||
{
|
||||
localTimeline += 10.0;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndArea();
|
||||
|
@ -36,5 +36,19 @@ public void StopHostCallsOnServerDisconnectForHostClient()
|
||||
manager.StopHost();
|
||||
Assert.That(manager.called, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StopClientCallsOnServerDisconnectForHostClient()
|
||||
{
|
||||
// OnServerDisconnect is always called when a client disconnects.
|
||||
// it should also be called for the host client when we stop the host
|
||||
Assert.That(manager.called, Is.EqualTo(0));
|
||||
manager.StartHost();
|
||||
manager.StopClient();
|
||||
Assert.That(manager.called, Is.EqualTo(1));
|
||||
Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));
|
||||
Assert.That(NetworkServer.localConnection, Is.Null);
|
||||
Assert.That(NetworkClient.connection, Is.Null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user