more stun servers and make server list a bit better

This commit is contained in:
RandomityGuy 2024-05-09 23:55:34 +05:30
parent 62ab1ba8a8
commit 1cd5c53156
2 changed files with 10 additions and 3 deletions

View file

@ -92,7 +92,8 @@ class MPServerListGui extends GuiImage {
var platformToString = ["unknown", "pc", "mac", "web", "android"];
function updateServerListDisplay() {
serverDisplays = ourServerList.map(x -> return '<img src="${platformToString[x.platform]}"></img><font color="#FFFFFF">${x.name}</font>');
serverDisplays = ourServerList.map(x -> return
'<img src="${platformToString[x.platform]}"></img><font color="#FFFFFF">${x.players}/${x.maxPlayers} ${x.name}</font>');
serverList.setTexts(serverDisplays);
}

View file

@ -79,6 +79,12 @@ class Net {
public static var serverInfo:ServerInfo;
public static var remoteServerInfo:RemoteServerInfo;
static var stunServers = [
"stun.l.google.com:19302", "stun1.l.google.com:19302", "stun2.l.google.com:19302", "stun3.l.google.com:19302", "stun4.l.google.com:19302",
"stun:relay.metered.ca:80", "stun.ekiga.net", "stun.ideasip.com", "stun.rixtelecom.se", "stun.schlund.de", "stun.stunprotocol.org:3478",
"stun.voiparound.com", "stun.voipbuster.com", "stun.voipstunt.com", "stun.voxgratia.org"
];
public static function hostServer(name:String, maxPlayers:Int, privateSlots:Int, privateServer:Bool, onHosted:() -> Void) {
serverInfo = new ServerInfo(name, 1, maxPlayers, privateSlots, privateServer, Std.int(999999 * Math.random()), "LOBBY", getPlatform());
MasterServerClient.connectToMasterServer(() -> {
@ -92,7 +98,7 @@ class Net {
}
public static function addClientFromSdp(sdpString:String, privateJoin:Bool, onFinishSdp:String->Void) {
var peer = new RTCPeerConnection(["stun:stun.l.google.com:19302"], "0.0.0.0");
var peer = new RTCPeerConnection(stunServers, "0.0.0.0");
var sdpObj = Json.parse(sdpString);
peer.setRemoteDescription(sdpObj.sdp, sdpObj.type);
addClient(peer, privateJoin, onFinishSdp);
@ -140,7 +146,7 @@ class Net {
public static function joinServer(serverName:String, isInvite:Bool, connectedCb:() -> Void) {
MasterServerClient.connectToMasterServer(() -> {
client = new RTCPeerConnection(["stun:stun.l.google.com:19302"], "0.0.0.0");
client = new RTCPeerConnection(stunServers, "0.0.0.0");
var candidates = [];
client.onLocalCandidate = (c) -> {