Im following the few samples there are about Transport, but so far I havent found a way to confirm if the connection was actually established, even if the server is down this function returns true:
public bool Connect(string server)
{
driver = new UdpNetworkDriver(new ReliableUtility.Parameters { WindowSize = 32 });
pipeline = driver.CreatePipeline(typeof(ReliableSequencedPipelineStage));
connection = new NativeArray<NetworkConnection>(1, Allocator.Persistent);
done = new NativeArray<byte>(1, Allocator.Persistent);
var endpoint = new NetworkEndPoint();
endpoint = NetworkEndPoint.Parse(server, 9000);
connection[0] = driver.Connect(endpoint);
if (!connection[0].IsCreated)
return false;
else if (connection[0].GetState<UdpNetworkDriver>(driver) == NetworkConnection.State.Disconnected) {
return false;
} else
return true;
}
Can somebody see a problem in this code or maybe suggest improvements?