void Start() { ReliableUtility.Parameters reliabilityParams = new ReliableUtility.Parameters { WindowSize = 32 }; SimulatorUtility.Parameters simulatorParams = new SimulatorUtility.Parameters { MaxPacketSize = k_PacketSize, MaxPacketCount = 30, PacketDelayMs = 100 }; m_Driver = new UdpNetworkDriver(simulatorParams, reliabilityParams); m_Connections = new NativeList <NetworkConnection>(connectionCapacity, Allocator.Persistent); // first parameter is number of connections to accept m_Unreliable_Pipeline = m_Driver.CreatePipeline(typeof(UnreliableSequencedPipelineStage), typeof(SimulatorPipelineStage)); m_Reliable_Pipeline = m_Driver.CreatePipeline(typeof(UnreliableSequencedPipelineStage), typeof(SimulatorPipelineStage)); NetworkEndPoint endpoint = NetworkEndPoint.AnyIpv4; endpoint.Port = 9000; if (m_Driver.Bind(endpoint) != 0) { Debug.Log("Failed to bind to port 9000"); } else { m_Driver.Listen(); } }
/// <summary> /// Configures client to connect to a server. /// </summary> private void configure() { //Creates a network driver that can track up to the specified number of packets at a time networkDriver = new UdpNetworkDriver(new ReliableUtility.Parameters { WindowSize = MaxInflightReliablePackets }); //This must use the same pipeline(s) as the server unreliablePipeline = networkDriver.CreatePipeline( typeof(UnreliableSequencedPipelineStage) ); //This must use the same pipeline(s) as the server reliablePipeline = networkDriver.CreatePipeline( typeof(ReliableSequencedPipelineStage) ); connectionToServer = default; //Setup up default network connection //Network endpoint is configured and ready to be connected to if (configureNetworkEndpoint()) { connectToServer(); } }
//Configures client to connect to a server void configure() { //Creates a network driver that can track up to 32 packets at a time (32 is the limit) //https://github.com/Unity-Technologies/multiplayer/blob/master/com.unity.transport/Documentation/pipelines-usage.md networkDriver = new UdpNetworkDriver(new ReliableUtility.Parameters { WindowSize = 32 }); //This must use the same pipeline(s) as the server networkPipeline = networkDriver.CreatePipeline( typeof(ReliableSequencedPipelineStage) ); connectionToServer = default(NetworkConnection); //Setup up default network connection //Set up server address if (networkSettings.serverIP != "") //Server IP is set { networkEndPoint = NetworkEndPoint.Parse(networkSettings.serverIP, networkSettings.port); Debug.Log("Connecting to server: " + networkSettings.serverIP + " on port: " + networkSettings.port); } else { Debug.Log("Connecting to server on LoopbackIpv4"); networkEndPoint = NetworkEndPoint.LoopbackIpv4; networkEndPoint.Port = networkSettings.port; } connectToServer(); }
//Configures server to connect to clients void configure() { //Creates a network driver that can track up to 32 packets at a time (32 is the limit) //https://github.com/Unity-Technologies/multiplayer/blob/master/com.unity.transport/Documentation/pipelines-usage.md networkDriver = new UdpNetworkDriver(new ReliableUtility.Parameters { WindowSize = 32 }); //This must use the same pipeline(s) as the client(s) networkPipeline = networkDriver.CreatePipeline( typeof(ReliableSequencedPipelineStage) ); //Set up network endpoint to accept any Ipv4 connections on port 9000 NetworkEndPoint networkEndpoint = NetworkEndPoint.AnyIpv4; networkEndpoint.Port = 9000; //Binds the network driver to a specific network address and port if (networkDriver.Bind(networkEndpoint) != 0) { Debug.Log("Failed to bind to port 9000"); } else //Successfully bound to port 9000 { networkDriver.Listen(); //Start listening for incoming connections } //Create list that can hold up to 16 connections networkConnections = new NativeList <NetworkConnection>(16, Allocator.Persistent); }
private void Start() { driver = new UdpNetworkDriver(new SimulatorUtility.Parameters { MaxPacketSize = 256, MaxPacketCount = 30, PacketDelayMs = 100 }); pipeline = driver.CreatePipeline(typeof(UnreliableSequencedPipelineStage), typeof(SimulatorPipelineStage)); connection = default; gm = GetComponent <GameManager>(); endpoint = new NetworkEndPoint(); }
void Start() { m_Driver = new UdpNetworkDriver(new ReliableUtility.Parameters { WindowSize = 32 }); reliableUdpPipe = m_Driver.CreatePipeline(typeof(ReliableSequencedPipelineStage));//, typeof(SimulatorPipelineStage)); //unrealiableSimulatorPipe = m_Driver.CreatePipeline(typeof(SimulatorPipelineStage)); m_Connection = default(NetworkConnection); }
public bool Listen(NetworkEndPoint endpoint) { LastDriverWriter.Complete(); if (m_UnreliablePipeline == NetworkPipeline.Null) { m_UnreliablePipeline = m_Driver.CreatePipeline(typeof(NullPipelineStage)); } if (m_ReliablePipeline == NetworkPipeline.Null) { m_ReliablePipeline = m_Driver.CreatePipeline(typeof(ReliableSequencedPipelineStage)); } // Switching to server mode if (m_Driver.Bind(endpoint) != 0) { return(false); } if (m_Driver.Listen() != 0) { return(false); } m_DriverListening = true; // FIXME: Bind breaks all copies of the driver nad makes them send to the wrong socket m_ConcurrentDriver = m_Driver.ToConcurrent(); return(true); }
private void Start() { driver = new UdpNetworkDriver(new SimulatorUtility.Parameters { MaxPacketSize = 256, MaxPacketCount = 30, PacketDelayMs = 100 }); pipeline = driver.CreatePipeline(typeof(UnreliableSequencedPipelineStage), typeof(SimulatorPipelineStage)); endpoint = new NetworkEndPoint(); ipv4 = GetLocalIpAdress(); gameStartBT = GameObject.FindGameObjectWithTag("GameStartBT"); gameStartBT.SetActive(false); }
// Start is called before the first frame update private void Start() { m_Driver = new UdpNetworkDriver(new SimulatorUtility.Parameters { MaxPacketSize = 256, MaxPacketCount = 30, PacketDelayMs = 100 }); m_Pipeline = m_Driver.CreatePipeline(typeof(UnreliableSequencedPipelineStage), typeof(SimulatorPipelineStage)); m_Connection = default; m_Endpoint = new NetworkEndPoint(); m_Endpoint = NetworkEndPoint.Parse("127.0.0.1", 9000); m_Connection = m_Driver.Connect(m_Endpoint); }
public void Connect(NetworkEndPoint endpoint) { if (connectEntity != Entity.Null) { Debug.LogError("connectEntity != Entity.Null"); return; } if (_unreliablePipeline == NetworkPipeline.Null) { #if UNITY_EDITOR if (clientPacketDelay > 0 || clientPacketDrop > 0) { _unreliablePipeline = _driver.CreatePipeline(typeof(SimulatorPipelineStage), typeof(SimulatorPipelineStageInSend)); } else #endif { _unreliablePipeline = _driver.CreatePipeline(typeof(NullPipelineStage)); } } if (_reliablePipeline == NetworkPipeline.Null) { #if UNITY_EDITOR if (clientPacketDelay > 0 || clientPacketDrop > 0) { _reliablePipeline = _driver.CreatePipeline(typeof(SimulatorPipelineStageInSend), typeof(ReliableSequencedPipelineStage), typeof(SimulatorPipelineStage)); } else #endif { _reliablePipeline = _driver.CreatePipeline(typeof(ReliableSequencedPipelineStage)); } } if (closeQuery == null) { closeQuery = GetEntityQuery(new EntityQueryDesc { All = new ComponentType[] { ComponentType.ReadOnly <NetworkDisconnectedMessage>(), /*ComponentType.ReadOnly<NetworkConnection>()*/ }, }); } // var connection = _driver.Connect(endpoint); connectEntity = EntityManager.CreateEntity(); EntityManager.AddComponentData(connectEntity, new NetworkConnection { value = connection }); EntityManager.AddComponent <NetworkInBuffer>(connectEntity); EntityManager.AddComponent <NetworkReliableOutBuffer>(connectEntity); EntityManager.AddComponent <NetworkUnreliableOutBuffer>(connectEntity); //EntityManager.AddComponent<NetworkConnectedMessage>(connectEntity); EntityManager.AddComponent <NetworkConnectMessage>(connectEntity); #if UNITY_EDITOR EntityManager.SetName(connectEntity, "cNetworkConnection"); #endif }
/// <summary> /// Configures server to allow client connections. /// </summary> private void configure() { //Creates a network driver that can track up to 32 packets at a time (32 is the limit) //https://github.com/Unity-Technologies/multiplayer/blob/master/com.unity.transport/Documentation/pipelines-usage.md networkDriver = new UdpNetworkDriver(new ReliableUtility.Parameters { WindowSize = 32 }); //This must use the same pipeline(s) as the client(s) unreliablePipeline = networkDriver.CreatePipeline( typeof(UnreliableSequencedPipelineStage) ); //This must use the same pipeline(s) as the client(s) reliablePipeline = networkDriver.CreatePipeline( typeof(ReliableSequencedPipelineStage) ); //Set up network endpoint to accept any Ipv4 connections on port networkSettings.port NetworkEndPoint networkEndpoint = NetworkEndPoint.AnyIpv4; networkEndpoint.Port = NetworkSettings.serverPort; //Binds the network driver to a specific network address and port if (networkDriver.Bind(networkEndpoint) != 0) { Debug.LogError("<color=magenta><b>[Server]</b></color> Failed to bind to port " + NetworkSettings.serverPort); } else //Successfully bound to port 9000 { networkDriver.Listen(); //Start listening for incoming connections } //Create list that can hold up to the specified number of client connections networkConnections = new NativeList <NetworkConnection>(maxClients, Allocator.Persistent); //Creates a dictionary that tracks client connections with unique IDs connectedClients = new Dictionary <short, NetworkConnection>(); }
// Start is called before the first frame update private void Start() { m_Driver = new UdpNetworkDriver(new SimulatorUtility.Parameters { MaxPacketSize = 256, MaxPacketCount = 30, PacketDelayMs = 100 }); m_Pipeline = m_Driver.CreatePipeline(typeof(UnreliableSequencedPipelineStage), typeof(SimulatorPipelineStage)); m_Connection = new NativeArray <NetworkConnection>(1, Allocator.Persistent); m_Done = new NativeArray <byte>(1, Allocator.Persistent); m_Endpoint = new NetworkEndPoint(); m_Endpoint = NetworkEndPoint.Parse("127.0.0.1", 9000); m_Connection[0] = m_Driver.Connect(m_Endpoint); }
void Start() { // Driver can be used as normal m_Driver = new UdpNetworkDriver(new SimulatorUtility.Parameters { MaxPacketSize = k_PacketSize, MaxPacketCount = 30, PacketDelayMs = 100 }); // Driver now knows about this pipeline and can explicitly be asked to send packets through it (by default it sends directly) m_Pipeline = m_Driver.CreatePipeline(typeof(UnreliableSequencedPipelineStage), typeof(SimulatorPipelineStage)); m_Connection = new NativeArray <NetworkConnection>(1, Allocator.Persistent); m_Done = new NativeArray <byte>(1, Allocator.Persistent); var endpoint = NetworkEndPoint.LoopbackIpv4; endpoint.Port = 9000; m_Connection[0] = m_Driver.Connect(endpoint); }
public SoakClient(double sendInterval, int packetSize, int duration) { DriverHandle = new UdpNetworkDriver(new SimulatorUtility.Parameters { MaxPacketSize = packetSize, MaxPacketCount = 30, PacketDelayMs = 25, PacketDropPercentage = 10 /*PacketDropInterval = 100*/ }, new ReliableUtility.Parameters { WindowSize = 32 }); //Pipeline = DriverHandle.CreatePipeline(typeof(UnreliableSequencedPipelineStage), typeof(SimulatorPipelineStage)); Pipeline = DriverHandle.CreatePipeline(typeof(ReliableSequencedPipelineStage), typeof(SimulatorPipelineStage)); if (packetSize > NetworkParameterConstants.MTU) { Debug.LogWarning("Truncating packet size to MTU"); packetSize = NetworkParameterConstants.MTU; } else if (packetSize < SoakMessage.HeaderLength) { Debug.LogWarning("Packet size was to small resizing to at least SoakMessage HeaderSize"); packetSize = SoakMessage.HeaderLength; } var payloadSize = packetSize - SoakMessage.HeaderLength; SoakClientStreamWriter = new DataStreamWriter(packetSize, Allocator.Persistent); PendingSoakMessages = new NativeArray <SoakMessage>(64, Allocator.Persistent); ConnectionHandle = new NativeArray <NetworkConnection>(1, Allocator.Persistent); SoakJobDataPacket = new NativeArray <byte>(payloadSize, Allocator.Persistent); var random = new byte[payloadSize]; Random r = new Random(); r.NextBytes(random); SoakJobDataPacket.CopyFrom(random); SoakJobContextsHandle = new NativeArray <SoakJobContext>(1, Allocator.Persistent); var context = new SoakJobContext { Duration = duration, PacketSize = packetSize, SendInterval = sendInterval }; SoakJobContextsHandle[0] = context; SoakStatisticsHandle = new NativeArray <SoakStatisticsPoint>(2, Allocator.Persistent); SoakStatisticsHandle[0] = new SoakStatisticsPoint(); SoakStatisticsHandle[1] = new SoakStatisticsPoint(); }
void Start() { m_Driver = new UdpNetworkDriver(new ReliableUtility.Parameters { WindowSize = 32 }); m_Connection = default(NetworkConnection); m_Pipeline = m_Driver.CreatePipeline( typeof(ReliableSequencedPipelineStage) ); NetworkEndPoint m_Endpoint = NetworkEndPoint.LoopbackIpv4; m_Endpoint.Port = 9000; m_Connection = m_Driver.Connect(m_Endpoint); }
// Start is called before the first frame update void Start() { m_Driver = new UdpNetworkDriver(new ReliableUtility.Parameters { WindowSize = 32 }); reliableUdpPipe = m_Driver.CreatePipeline(typeof(ReliableSequencedPipelineStage)); if (m_Driver.Bind(NetworkEndPoint.Parse("0.0.0.0", 9000)) != 0) { Debug.Log("Failed to bind to port ..."); } else { m_Driver.Listen(); } m_Connections = new NativeList <NetworkConnection>(16, Allocator.Persistent); }
public void Start() { m_Connections = new NativeList <SoakClientCtx>(1, Allocator.Persistent); m_ServerDriver = new UdpNetworkDriver(new ReliableUtility.Parameters { WindowSize = 32 }); //m_Pipeline = m_ServerDriver.CreatePipeline(typeof(UnreliableSequencedPipelineStage)); m_Pipeline = m_ServerDriver.CreatePipeline(typeof(ReliableSequencedPipelineStage)); var addr = NetworkEndPoint.AnyIpv4; addr.Port = 9000; if (m_ServerDriver.Bind(addr) != 0) { Debug.Log("Failed to bind to port 9000"); } else { m_ServerDriver.Listen(); } }
// Start is called before the first frame update private void Start() { m_Driver = new UdpNetworkDriver(new SimulatorUtility.Parameters { MaxPacketSize = 256, MaxPacketCount = 30, PacketDelayMs = 100 }); m_Pipeline = m_Driver.CreatePipeline(typeof(UnreliableSequencedPipelineStage), typeof(SimulatorPipelineStage)); m_Endpoint = new NetworkEndPoint(); m_Endpoint = NetworkEndPoint.Parse("0.0.0.0", 9000); if (m_Driver.Bind(m_Endpoint) != 0) { Debug.Log("Failed to bind to port 9000"); } else { m_Driver.Listen(); } m_Connections = new NativeList <NetworkConnection>(16, Allocator.Persistent); }
private void ConfigureClient() { // Creates a network driver that can track up to 32 packets at a time (32 is the limit) networkDriver = new UdpNetworkDriver(new ReliableUtility.Parameters { WindowSize = 32 }); // This must use the same pipeline(s) as the server networkPipeline = networkDriver.CreatePipeline( typeof(ReliableSequencedPipelineStage) ); connectionToServer = default(NetworkConnection); // Setup up default network connection // Set up server address NetworkEndPoint networkEndpoint = NetworkEndPoint.LoopbackIpv4; networkEndpoint.Port = PORT; // Connect to server connectionToServer = networkDriver.Connect(networkEndpoint); }
void Start() { m_Driver = new UdpNetworkDriver(new ReliableUtility.Parameters { WindowSize = 32 }); m_Pipeline = m_Driver.CreatePipeline(typeof(ReliableSequencedPipelineStage)); NetworkEndPoint m_Endpoint = NetworkEndPoint.AnyIpv4; m_Endpoint.Port = 9000; if (m_Driver.Bind(m_Endpoint) != 0) { Debug.Log("Failed to bind to port 9000"); } else { m_Driver.Listen(); } m_Connections = new NativeList <NetworkConnection> (16, Allocator.Persistent); }
void Start() { m_Connections = new NativeList <NetworkConnection>(16, Allocator.Persistent); // Driver can be used as normal m_Driver = new UdpNetworkDriver(new SimulatorUtility.Parameters { MaxPacketSize = k_PacketSize, MaxPacketCount = 30, PacketDelayMs = 100 }); // Driver now knows about this pipeline and can explicitly be asked to send packets through it (by default it sends directly) m_Pipeline = m_Driver.CreatePipeline(typeof(UnreliableSequencedPipelineStage), typeof(SimulatorPipelineStage)); var endpoint = NetworkEndPoint.LoopbackIpv4; endpoint.Port = 9000; if (m_Driver.Bind(endpoint) != 0) { Debug.Log("Failed to bind to port 9000"); } else { m_Driver.Listen(); } }
//Configures client to connect to a server void configure() { //Creates a network driver that can track up to 32 packets at a time (32 is the limit) //https://github.com/Unity-Technologies/multiplayer/blob/master/com.unity.transport/Documentation/pipelines-usage.md networkDriver = new UdpNetworkDriver(new ReliableUtility.Parameters { WindowSize = 32 }); //This must use the same pipeline(s) as the server networkPipeline = networkDriver.CreatePipeline( typeof(ReliableSequencedPipelineStage) ); connectionToServer = default(NetworkConnection); //Setup up default network connection //Set up server address NetworkEndPoint networkEndpoint = NetworkEndPoint.LoopbackIpv4; networkEndpoint.Port = 9000; //Connect to server connectionToServer = networkDriver.Connect(networkEndpoint); }