I just had an idea.
My server is setup to use C# Code via nwnx plugins.
I happen to have this function, that can query servers, for their status and descriptions.
Im thinking I can setup the Hub server, so players who want to add their server to the available server list, could literally just speak the server IP Address and port, and then this code would go and get all the relevant info from the remote server, and then use it to generate the necessary info to create lobbys etc for each server.
I will give it a test tonight.
I am imagining a system where the player speaks something like
Server:90.22.121.122:5121
The system queries it (should get the data back within 2 seconds, or timeout - it is blocking, so it would freeze the Hub Server for that duration).
The info returned would be a long string containing the
Server Name,
Module Name,
Level Restrictions,
Item Level Restriction Enabled etc,
Password Required,
Player Population etc
as well as the Short Description that comes from the Desc.txt file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace NwnxAssembly
{
public class ServerStatusServices
{
public static string CheckStatus(string sIP, string sPort)
{
var timeToWait = TimeSpan.FromSeconds(2);
var udpClient = new UdpClient(sIP, Convert.ToInt32(sPort));
byte[] sendBytes = new byte[] { 0xFE, 0xFD, 0x00, 0xE0, 0xEB, 0x2D, 0x0E, 0x14, 0x01, 0x0B, 0x01, 0x05, 0x08, 0x0A, 0x33, 0x34, 0x35, 0x13, 0x04, 0x36, 0x37, 0x38, 0x39, 0x14, 0x3A, 0x3B, 0x3C, 0x3D, 0x00, 0x00 };
udpClient.Send(sendBytes, sendBytes.Length);
var asyncResult = udpClient.BeginReceive(null, null);
asyncResult.AsyncWaitHandle.WaitOne(timeToWait);
try
{
IPEndPoint remoteEP = null;
byte[] receivedData = udpClient.EndReceive(asyncResult, ref remoteEP);
return Encoding.ASCII.GetString(receivedData);
// EndReceive worked and we have received data and remote endpoint
}
catch (Exception ex)
{
// EndReceive failed and we ended up here
return "BAD_RESPONSE";
}
return "BAD_RESPONSE";
}
}
}