public void DisconnectTimeoutOnServer() { using (var host = new LocalDriverHelper(default(NetworkEndPoint), new NetworkConfigParameter { disconnectTimeoutMS = 40 })) using (var client = new LocalNetworkDriver(new NetworkConfigParameter { disconnectTimeoutMS = 40 })) { NetworkConnection id; NetworkEvent.Type popEvent = NetworkEvent.Type.Empty; DataStreamReader reader; host.Host(); client.Connect(host.Address); client.ScheduleUpdate().Complete(); host.Assert_GotConnectionRequest(client.LocalEndPoint(), true); var stream = new DataStreamWriter(100, Allocator.Persistent); for (int i = 0; i < 100; i++) { stream.Write((byte)i); } // Host sends stuff but gets nothing back, until disconnect timeout happens var timeout = m_timer.ElapsedMilliseconds + 100; while (m_timer.ElapsedMilliseconds < timeout) { host.m_LocalDriver.Send(host.ClientConnections[0], stream); popEvent = host.m_LocalDriver.PopEvent(out id, out reader); if (popEvent != NetworkEvent.Type.Empty) { break; } host.Update(); } stream.Dispose(); Assert.AreEqual(NetworkEvent.Type.Disconnect, popEvent); } }
public void ConnectToARemoteEndPoint() { using (var host = new LocalDriverHelper(default(NetworkEndPoint))) { host.Host(); var driver = new LocalNetworkDriver(new NetworkDataStreamParameter { size = 64 }); NetworkConnection connectionId = driver.Connect(host.Address); Assert.True(connectionId != default(NetworkConnection)); driver.ScheduleUpdate().Complete(); var local = driver.LocalEndPoint(); host.Assert_GotConnectionRequest(local); driver.Dispose(); } }
public void DisconnectTimeoutOnServer() { using (var host = new LocalDriverHelper(default(NetworkEndPoint), new NetworkConfigParameter { disconnectTimeoutMS = 40, fixedFrameTimeMS = 10 })) using (var client = new NetworkDriver(new IPCNetworkInterface(), new NetworkConfigParameter { disconnectTimeoutMS = 40, fixedFrameTimeMS = 10 })) { NetworkConnection id; NetworkEvent.Type popEvent = NetworkEvent.Type.Empty; DataStreamReader reader; host.Host(); client.Connect(host.EndPoint); client.ScheduleUpdate().Complete(); host.Assert_GotConnectionRequest(client.LocalEndPoint(), true); // Host sends stuff but gets nothing back, until disconnect timeout happens for (int frm = 0; frm < 10; ++frm) { var stream = host.m_LocalDriver.BeginSend(NetworkPipeline.Null, host.ClientConnections[0]); for (int i = 0; i < 100; i++) { stream.WriteByte((byte)i); } host.m_LocalDriver.EndSend(stream); popEvent = host.m_LocalDriver.PopEvent(out id, out reader); if (popEvent != NetworkEvent.Type.Empty) { break; } host.Update(); } Assert.AreEqual(NetworkEvent.Type.Disconnect, popEvent); } }