more formatting (#1630)

This commit is contained in:
James Frowen 2020-03-31 21:55:58 +01:00 committed by GitHub
parent c6501aab06
commit f19e2d3aac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 114 additions and 109 deletions

View File

@ -226,7 +226,7 @@ public void Stop()
TcpClient client = kvp.Value.client;
// close the stream if not closed yet. it may have been closed
// by a disconnect already, so use try/catch
try { client.GetStream().Close(); } catch {}
try { client.GetStream().Close(); } catch { }
client.Close();
}

View File

@ -30,7 +30,7 @@ public Message(int connectionId, EventType eventType, byte[] data)
public override bool Available() => true;
public override int GetMaxPacketSize(int channelId) => int.MaxValue;
public override void Shutdown() {}
public override void Shutdown() { }
public override bool ClientConnected() => clientConnected;
public override void ClientConnect(string address)
{

View File

@ -112,8 +112,8 @@ public void CallSendEventInternal()
// we need to inherit from networkbehaviour to test protected functions
public class NetworkBehaviourDelegateComponent : NetworkBehaviour
{
public static void Delegate(NetworkBehaviour comp, NetworkReader reader) {}
public static void Delegate2(NetworkBehaviour comp, NetworkReader reader) {}
public static void Delegate(NetworkBehaviour comp, NetworkReader reader) { }
public static void Delegate2(NetworkBehaviour comp, NetworkReader reader) { }
}
// we need to inherit from networkbehaviour to test protected functions
@ -324,10 +324,10 @@ public void SendCommandInternal()
// we need to start a server and connect a client in order to be
// able to send commands
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<SpawnMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<SpawnMessage>((conn, msg) => { }, false);
NetworkServer.Listen(1);
Assert.That(NetworkServer.active, Is.True);
@ -336,12 +336,14 @@ public void SendCommandInternal()
Assert.That(comp.called, Is.EqualTo(0));
// create a connection from client to server and from server to client
ULocalConnectionToClient connection = new ULocalConnectionToClient {
ULocalConnectionToClient connection = new ULocalConnectionToClient
{
isReady = true,
// commands require authentication
isAuthenticated = true
};
connection.connectionToServer = new ULocalConnectionToServer {
connection.connectionToServer = new ULocalConnectionToServer
{
isReady = true,
// commands require authentication
isAuthenticated = true
@ -456,10 +458,10 @@ public void SendRPCInternal()
// we need to start a server and connect a client in order to be
// able to send commands
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<SpawnMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<SpawnMessage>((conn, msg) => { }, false);
NetworkServer.Listen(1);
Assert.That(NetworkServer.active, Is.True);
@ -541,10 +543,10 @@ public void SendTargetRPCInternal()
// we need to start a server and connect a client in order to be
// able to send commands
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<SpawnMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<SpawnMessage>((conn, msg) => { }, false);
NetworkServer.Listen(1);
Assert.That(NetworkServer.active, Is.True);
@ -655,10 +657,10 @@ public void SendEventInternal()
// we need to start a server and connect a client in order to be
// able to send events
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<SpawnMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<SpawnMessage>((conn, msg) => { }, false);
NetworkServer.Listen(1);
Assert.That(NetworkServer.active, Is.True);
@ -1464,7 +1466,7 @@ public void GetSyncVarNetworkIdentityOnClientNull()
[Test]
public void ClearAllDirtyBitsClearsSyncVarDirtyBits()
{
// set syncinterval so dirtybit works fine
// set syncinterval so dirtybit works fine
emptyBehaviour.syncInterval = 0;
Assert.That(emptyBehaviour.IsDirty(), Is.False);

View File

@ -6,7 +6,7 @@
using NUnit.Framework;
using UnityEngine;
namespace Mirror.Tests
namespace Mirror.Tests
{
public class NetworkClientTests
{
@ -21,13 +21,13 @@ public void SetUp()
Transport.activeTransport = transportGO.AddComponent<MemoryTransport>();
// we need a server to connect to
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
NetworkServer.Listen(10);
// setup client handlers too
NetworkClient.RegisterHandler<ConnectMessage>(msg => {}, false);
NetworkClient.RegisterHandler<ConnectMessage>(msg => { }, false);
}
[TearDown]

View File

@ -46,13 +46,13 @@ public void VariableTest()
[Test]
public void StartServerTest()
{
Assert.That(NetworkServer.active , Is.False);
Assert.That(NetworkServer.active, Is.False);
manager.StartServer();
Assert.That(manager.isNetworkActive , Is.True);
Assert.That(manager.isNetworkActive, Is.True);
Assert.That(manager.mode == NetworkManagerMode.ServerOnly);
Assert.That(NetworkServer.active , Is.True);
Assert.That(NetworkServer.active, Is.True);
}
[Test]
@ -61,7 +61,7 @@ public void StopServerTest()
manager.StartServer();
manager.StopServer();
Assert.That(manager.isNetworkActive , Is.False);
Assert.That(manager.isNetworkActive, Is.False);
Assert.That(manager.mode == NetworkManagerMode.Offline);
}
@ -70,7 +70,7 @@ public void StartClientTest()
{
manager.StartClient();
Assert.That(manager.isNetworkActive , Is.True);
Assert.That(manager.isNetworkActive, Is.True);
Assert.That(manager.mode == NetworkManagerMode.ClientOnly);
manager.StopClient();
@ -82,7 +82,7 @@ public void StopClientTest()
manager.StartClient();
manager.StopClient();
Assert.That(manager.isNetworkActive , Is.False);
Assert.That(manager.isNetworkActive, Is.False);
Assert.That(manager.mode == NetworkManagerMode.Offline);
}
@ -92,19 +92,19 @@ public void ShutdownTest()
manager.StartClient();
NetworkManager.Shutdown();
Assert.That(NetworkManager.startPositions.Count , Is.Zero);
Assert.That(NetworkManager.startPositionIndex , Is.Zero);
Assert.That(NetworkManager.startPositionIndex , Is.Zero);
Assert.That(NetworkManager.singleton , Is.Null);
Assert.That(NetworkManager.startPositions.Count, Is.Zero);
Assert.That(NetworkManager.startPositionIndex, Is.Zero);
Assert.That(NetworkManager.startPositionIndex, Is.Zero);
Assert.That(NetworkManager.singleton, Is.Null);
}
[Test]
public void RegisterStartPositionTest()
{
Assert.That(NetworkManager.startPositions.Count , Is.Zero);
Assert.That(NetworkManager.startPositions.Count, Is.Zero);
NetworkManager.RegisterStartPosition(gameObject.transform);
Assert.That(NetworkManager.startPositions.Count , Is.EqualTo(1));
Assert.That(NetworkManager.startPositions.Count, Is.EqualTo(1));
Assert.That(NetworkManager.startPositions, Has.Member(gameObject.transform));
NetworkManager.UnRegisterStartPosition(gameObject.transform);
@ -113,23 +113,23 @@ public void RegisterStartPositionTest()
[Test]
public void UnRegisterStartPositionTest()
{
Assert.That(NetworkManager.startPositions.Count , Is.Zero);
Assert.That(NetworkManager.startPositions.Count, Is.Zero);
NetworkManager.RegisterStartPosition(gameObject.transform);
Assert.That(NetworkManager.startPositions.Count , Is.EqualTo(1));
Assert.That(NetworkManager.startPositions.Count, Is.EqualTo(1));
Assert.That(NetworkManager.startPositions, Has.Member(gameObject.transform));
NetworkManager.UnRegisterStartPosition(gameObject.transform);
Assert.That(NetworkManager.startPositions.Count , Is.Zero);
Assert.That(NetworkManager.startPositions.Count, Is.Zero);
}
[Test]
public void GetStartPositionTest()
{
Assert.That(NetworkManager.startPositions.Count , Is.Zero);
Assert.That(NetworkManager.startPositions.Count, Is.Zero);
NetworkManager.RegisterStartPosition(gameObject.transform);
Assert.That(NetworkManager.startPositions.Count , Is.EqualTo(1));
Assert.That(NetworkManager.startPositions.Count, Is.EqualTo(1));
Assert.That(NetworkManager.startPositions, Has.Member(gameObject.transform));
Assert.That(manager.GetStartPosition(), Is.SameAs(gameObject.transform));

View File

@ -89,9 +89,9 @@ public void IsActiveTest()
public void MaxConnectionsTest()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen with maxconnections=1
NetworkServer.Listen(1);
@ -115,8 +115,8 @@ public void ConnectMessageHandlerTest()
// message handlers
bool connectCalled = false;
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { connectCalled = true; }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen
NetworkServer.Listen(1);
@ -135,9 +135,9 @@ public void DisconnectMessageHandlerTest()
{
// message handlers
bool disconnectCalled = false;
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { disconnectCalled = true; }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen
NetworkServer.Listen(1);
@ -159,9 +159,9 @@ public void DisconnectMessageHandlerTest()
public void ConnectionsDictTest()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen
NetworkServer.Listen(2);
@ -198,9 +198,9 @@ public void OnConnectedOnlyAllowsGreaterZeroConnectionIdsTest()
// <0 is never used
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen
NetworkServer.Listen(2);
@ -225,9 +225,9 @@ public void OnConnectedOnlyAllowsGreaterZeroConnectionIdsTest()
public void ConnectDuplicateConnectionIdsTest()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen
NetworkServer.Listen(2);
@ -312,9 +312,9 @@ public void LocalClientActiveTest()
public void AddConnectionTest()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen
NetworkServer.Listen(1);
@ -356,9 +356,9 @@ public void AddConnectionTest()
public void RemoveConnectionTest()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen
NetworkServer.Listen(1);
@ -385,9 +385,9 @@ public void RemoveConnectionTest()
public void DisconnectAllConnectionsTest()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen
NetworkServer.Listen(1);
@ -410,9 +410,9 @@ public void DisconnectAllConnectionsTest()
public void DisconnectAllTest()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen
NetworkServer.Listen(1);
@ -441,15 +441,16 @@ public void DisconnectAllTest()
public void OnDataReceivedTest()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// add one custom message handler
bool wasReceived = false;
NetworkConnection connectionReceived = null;
TestMessage messageReceived = new TestMessage();
NetworkServer.RegisterHandler<TestMessage>((conn, msg) => {
NetworkServer.RegisterHandler<TestMessage>((conn, msg) =>
{
wasReceived = true;
connectionReceived = conn;
messageReceived = msg;
@ -465,7 +466,7 @@ public void OnDataReceivedTest()
Assert.That(NetworkServer.connections.Count, Is.EqualTo(1));
// serialize a test message into an arraysegment
TestMessage testMessage = new TestMessage{IntValue = 13, DoubleValue = 14, StringValue = "15"};
TestMessage testMessage = new TestMessage { IntValue = 13, DoubleValue = 14, StringValue = "15" };
NetworkWriter writer = new NetworkWriter();
MessagePacker.Pack(testMessage, writer);
ArraySegment<byte> segment = writer.ToArraySegment();
@ -489,15 +490,16 @@ public void OnDataReceivedTest()
public void OnDataReceivedInvalidConnectionIdTest()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// add one custom message handler
bool wasReceived = false;
NetworkConnection connectionReceived = null;
TestMessage messageReceived = new TestMessage();
NetworkServer.RegisterHandler<TestMessage>((conn, msg) => {
NetworkServer.RegisterHandler<TestMessage>((conn, msg) =>
{
wasReceived = true;
connectionReceived = conn;
messageReceived = msg;
@ -508,7 +510,7 @@ public void OnDataReceivedInvalidConnectionIdTest()
Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));
// serialize a test message into an arraysegment
TestMessage testMessage = new TestMessage{IntValue = 13, DoubleValue = 14, StringValue = "15"};
TestMessage testMessage = new TestMessage { IntValue = 13, DoubleValue = 14, StringValue = "15" };
NetworkWriter writer = new NetworkWriter();
MessagePacker.Pack(testMessage, writer);
ArraySegment<byte> segment = writer.ToArraySegment();
@ -632,7 +634,8 @@ public void CommandMessageCallsCommandTest()
NetworkIdentity.spawned[identity.netId] = identity;
// serialize a removeplayer message into an arraysegment
CommandMessage message = new CommandMessage {
CommandMessage message = new CommandMessage
{
componentIndex = 0,
functionHash = NetworkBehaviour.GetMethodHash(typeof(CommandTestNetworkBehaviour), nameof(CommandTestNetworkBehaviour.CommandGenerated)),
netId = identity.netId,
@ -734,9 +737,9 @@ public void ActivateHostSceneCallsOnStartClient()
public void SendToAllTest()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen
NetworkServer.Listen(1);
@ -747,14 +750,14 @@ public void SendToAllTest()
connection.connectionToServer = new ULocalConnectionToServer();
// set a client handler
int called = 0;
connection.connectionToServer.SetHandlers(new Dictionary<int,NetworkMessageDelegate>()
connection.connectionToServer.SetHandlers(new Dictionary<int, NetworkMessageDelegate>()
{
{ MessagePacker.GetId<TestMessage>(), ((conn, reader, channelId) => ++called) }
});
NetworkServer.AddConnection(connection);
// create a message
TestMessage message = new TestMessage{ IntValue = 1, DoubleValue = 2, StringValue = "3" };
TestMessage message = new TestMessage { IntValue = 1, DoubleValue = 2, StringValue = "3" };
// send it to all
bool result = NetworkServer.SendToAll(message);
@ -774,9 +777,9 @@ public void SendToAllTest()
public void RegisterUnregisterClearHandlerTest()
{
// message handlers that are needed for the test
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// RegisterHandler(conn, msg) variant
@ -822,7 +825,7 @@ public void RegisterUnregisterClearHandlerTest()
// unregister second handler via ClearHandlers to test that one too. send, should fail
NetworkServer.ClearHandlers();
// (only add this one to avoid disconnect error)
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
writer = new NetworkWriter();
MessagePacker.Pack(new TestMessage(), writer);
// log error messages are expected
@ -840,9 +843,9 @@ public void RegisterUnregisterClearHandlerTest()
public void SendToClientOfPlayer()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen
NetworkServer.Listen(1);
@ -853,14 +856,14 @@ public void SendToClientOfPlayer()
connection.connectionToServer = new ULocalConnectionToServer();
// set a client handler
int called = 0;
connection.connectionToServer.SetHandlers(new Dictionary<int,NetworkMessageDelegate>()
connection.connectionToServer.SetHandlers(new Dictionary<int, NetworkMessageDelegate>()
{
{ MessagePacker.GetId<TestMessage>(), ((conn, reader, channelId) => ++called) }
});
NetworkServer.AddConnection(connection);
// create a message
TestMessage message = new TestMessage{ IntValue = 1, DoubleValue = 2, StringValue = "3" };
TestMessage message = new TestMessage { IntValue = 1, DoubleValue = 2, StringValue = "3" };
// create a gameobject and networkidentity
NetworkIdentity identity = new GameObject().AddComponent<NetworkIdentity>();
@ -914,9 +917,9 @@ public void GetNetworkIdentity()
public void ShowForConnection()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen
NetworkServer.Listen(1);
@ -929,7 +932,7 @@ public void ShowForConnection()
connection.connectionToServer = new ULocalConnectionToServer();
// set a client handler
int called = 0;
connection.connectionToServer.SetHandlers(new Dictionary<int,NetworkMessageDelegate>()
connection.connectionToServer.SetHandlers(new Dictionary<int, NetworkMessageDelegate>()
{
{ MessagePacker.GetId<SpawnMessage>(), ((conn, reader, channelId) => ++called) }
});
@ -966,9 +969,9 @@ public void ShowForConnection()
public void HideForConnection()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen
NetworkServer.Listen(1);
@ -981,7 +984,7 @@ public void HideForConnection()
connection.connectionToServer = new ULocalConnectionToServer();
// set a client handler
int called = 0;
connection.connectionToServer.SetHandlers(new Dictionary<int,NetworkMessageDelegate>()
connection.connectionToServer.SetHandlers(new Dictionary<int, NetworkMessageDelegate>()
{
{ MessagePacker.GetId<ObjectHideMessage>(), ((conn, reader, channelId) => ++called) }
});
@ -1102,9 +1105,9 @@ public void UnSpawn()
public void ShutdownCleanupTest()
{
// message handlers
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => {}, false);
NetworkServer.RegisterHandler<ConnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<DisconnectMessage>((conn, msg) => { }, false);
NetworkServer.RegisterHandler<ErrorMessage>((conn, msg) => { }, false);
// listen
NetworkServer.Listen(1);