public void NetworkPipeline_CanExtendHeader() { // Create pipeline var clientPipe = m_ClientDriver.CreatePipeline(typeof(TestPipelineStageWithHeader)); var serverPipe = m_ServerDriver.CreatePipeline(typeof(TestPipelineStageWithHeader)); Assert.AreEqual(clientPipe, serverPipe); // Connect to server var clientToServer = m_ClientDriver.Connect(m_ServerDriver.LocalEndPoint()); Assert.AreNotEqual(default(NetworkConnection), clientToServer); m_ClientDriver.ScheduleUpdate().Complete(); // Handle incoming connection from client m_ServerDriver.ScheduleUpdate().Complete(); var serverToClient = m_ServerDriver.Accept(); Assert.AreNotEqual(default(NetworkConnection), serverToClient); // Send message to client var strm = new DataStreamWriter(4, Allocator.Temp); strm.Write((int)42); m_ServerDriver.Send(serverPipe, serverToClient, strm); m_ServerDriver.ScheduleUpdate().Complete(); // Receive incoming message from server m_ClientDriver.ScheduleUpdate().Complete(); DataStreamReader readStrm; Assert.AreEqual(NetworkEvent.Type.Connect, clientToServer.PopEvent(m_ClientDriver, out readStrm)); Assert.AreEqual(NetworkEvent.Type.Data, clientToServer.PopEvent(m_ClientDriver, out readStrm)); Assert.AreEqual(4, readStrm.Length); var readCtx = default(DataStreamReader.Context); Assert.AreEqual(42, readStrm.ReadInt(ref readCtx)); }
public NetworkConnection Accept() { return(m_genericDriver.Accept()); }