Closed uweeby closed 3 years ago
Took a stab at it
public override void ServerStart()
{
ServerStart(string.Empty, port, int.MaxValue);
}
public override void ServerStart(ushort port)
{
ServerStart(string.Empty, port, int.MaxValue);
}
public override void ServerStart(string networkAddress, ushort port)
{
ServerStart(networkAddress, port, int.MaxValue);
}
/// <summary>
/// Start the server with the specified parameters.
/// </summary>
/// <param name="address">The address to bind to.</param>
/// <param name="port">The port to use. Do not run more than one server on the same port.</param>
/// <param name="maxConnections">How many connections can we have?</param>
public override void ServerStart(string networkAddress, ushort port, int maxConnections)
{
// Do not attempt to start more than one server.
// Check if the server is active before attempting to create. If it returns true,
// then we should not continue, and we'll emit a refusal error message.
// This should be classified as a dirty hack and if it doesn't work then well, shit.
if (ServerActive())
{
LogError("Ignorance Transport: Refusing to start another server instance! There's already one running.");
return;
}
server = new Host();
serverAddress = new Address();
knownConnIDToPeers = new Dictionary<int, Peer>();
knownPeersToConnIDs = new Dictionary<Peer, int>();
#if UNITY_EDITOR_OSX
if(verboseLoggingEnabled) Log(string.Format("Ignorance Transport: Server startup in MacOS Editor workaround mode on port {0} with capacity of {1} concurrent connections", Port, maxConnections));
LogWarning("Ignorance Transport: Binding to a specific address is disabled on MacOS Editor due to some bugs. Please refer to https://github.com/nxrighthere/ENet-CSharp/issues/46 " +
"for technicial details. While you can disable this check, it will most likely bug out and mess connectivity up. You've been warned.");
Log("Ignorance Transport: Binding to ::0 as a workaround for Mac OS LAN Host");
serverAddress.SetHost("::0");
#else
if (m_TransportVerbosity > TransportVerbosity.SilenceIsGolden) Log(string.Format("Ignorance Transport: Server startup on port {0} with capacity of {1} concurrent connections", Port, maxConnections));
if (m_BindToAllInterfaces)
{
Log("Ignorance Transport: Binding to all available interfaces.");
#if UNITY_EDITOR_OSX
serverAddress.SetHost("::0");
#else
serverAddress.SetHost("0.0.0.0");
#endif
}
else
{
if (!string.IsNullOrEmpty(networkAddress))
{
Log(string.Format("Ignorance Transport: Using {0} as our specific bind address", networkAddress));
serverAddress.SetHost(networkAddress);
}
else
{
// WTF happened to reach here?
#if UNITY_EDITOR_OSX
serverAddress.SetHost("::0");
#else
serverAddress.SetHost("0.0.0.0");
#endif
}
}
#endif
// Setup the port.
serverAddress.Port = port;
// Finally create the server.
server.Create(serverAddress, m_MaximumTotalConnections, packetSendMethods.Length, 0, 0);
if (m_UseLZ4Compression) server.EnableCompression();
if (m_UseNewPacketEngine)
{
Log("Ignorance Transport: New experimental packet engine will be used.");
}
// Log our best effort attempts
Log(string.Format("Ignorance Transport: Attempted to create server with capacity of {0} connections on UDP port {1}", maxConnections, Port));
Log("Ignorance Transport: If you see this, the server most likely was successfully created and started! (This is good.)");
}
Implemented this partially in RC5... but i think I'll make a Insight compatible version as a child class. It would be for the best, then you can use that for Insight.
Closing since it's from 2019... if needed, re-open if desired.
Would it be possible to remove the references into NetworkManager? That would allow seamless integration with Insight.