Tested & fixed a few pieces, still WIP.

This commit is contained in:
ayunami2000 2022-08-19 19:39:54 -04:00
parent 3d9df11058
commit c191024041
16 changed files with 31309 additions and 31231 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -347,7 +347,6 @@ window.initializeLANClient = (() => {
}
if(this.peerConnection != null) {
this.peerConnection.close();
this.peerConnection = null;
}
this.peerConnection = new RTCPeerConnection({ iceServers: this.ICEServers, optional: [ { DtlsSrtpKeyAgreement: true } ] });
this.readyState = READYSTATE_CONNECTING;
@ -398,15 +397,14 @@ window.initializeLANClient = (() => {
signalRemoteConnect() {
const self = this;
if(self.readyState === READYSTATE_CONNECTED || self.readyState === READYSTATE_CONNECTING) {
signalRemoteDisconnect();
}
this.peerConnection.addEventListener("icecandidate", (evt) => {
if(evt.candidate) {
self.iceCandidateHandler(JSON.stringify({ sdpMLineIndex: evt.candidate.sdpMLineIndex, candidate: evt.candidate.candidate }));
}
});
/*
this.peerConnection.addEventListener("datachannel", (evt) => {
self.channel = evt.channel;
self.remoteDataChannelHandler(self.channel);
@ -414,6 +412,17 @@ window.initializeLANClient = (() => {
self.remotePacketHandler(evt.data);
});
});
*/
this.channel = this.peerConnection.createDataChannel("lan");
this.channel.addEventListener("open", (evt) => {
self.remoteDataChannelHandler(self.channel);
});
this.channel.addEventListener("message", (evt) => {
self.remotePacketHandler(evt.data);
});
this.peerConnection.createOffer((desc) => {
const selfDesc = desc;
@ -443,11 +452,23 @@ window.initializeLANClient = (() => {
}
signalRemoteDescription(descJSON) {
this.peerConnection.setRemoteDescription(descJSON);
try {
this.peerConnection.setRemoteDescription(JSON.parse(descJSON));
} catch (e) {
console.error(e);
this.readyState = READYSTATE_FAILED;
this.signalRemoteDisconnect();
}
}
signalRemoteICECandidate(candidate) {
this.peerConnection.addICECandidate(candidate);
try {
this.peerConnection.addIceCandidate(JSON.parse(candidate));
} catch (e) {
console.error(e);
this.readyState = READYSTATE_FAILED;
this.signalRemoteDisconnect();
}
}
signalRemoteDisconnect() {
@ -455,7 +476,9 @@ window.initializeLANClient = (() => {
this.dataChannel.close();
this.dataChannel = null;
}
if(this.peerConnection != null) {
this.peerConnection.close();
}
this.remoteDisconnectHandler();
this.readyState = READYSTATE_DISCONNECTED;
}
@ -497,15 +520,25 @@ window.initializeLANServer = (() => {
}
});
/*
this.dataChannel = this.peerConnection.createDataChannel("lan");
this.dataChannel.addEventListener("open", (evt) => {
self.client.remoteClientDataChannelHandler(self.peerId, this.dataChannel);
self.client.remoteClientDataChannelHandler(self.peerId, self.dataChannel);
});
this.dataChannel.addEventListener("message", (evt) => {
self.client.remoteClientPacketHandler(self.peerId, evt.data);
});
*/
this.peerConnection.addEventListener("datachannel", (evt) => {
self.dataChannel = evt.channel;
self.client.remoteClientDataChannelHandler(self.peerId, self.dataChannel);
self.dataChannel.addEventListener("message", (evt) => {
self.client.remoteClientPacketHandler(self.peerId, evt.data);
});
});
this.peerConnection.addEventListener("connectionstatechange", (evt) => {
if(evt.connectionState === 'disconnected') {

View File

@ -47,21 +47,21 @@ public class EaglerSPClient {
public boolean handle(IPacket packet) throws IOException {
if(packet instanceof IPacket03ICECandidate) {
if(LoginState.assertEquals(this, LoginState.INIT)) {
if(LoginState.assertEquals(this, LoginState.RECIEVED_DESCRIPTION)) {
state = LoginState.SENT_ICE_CANDIDATE;
server.handleClientICECandidate(this, (IPacket03ICECandidate)packet);
EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x03: ICECandidate", (String) socket.getAttachment());
}
return true;
}else if(packet instanceof IPacket04Description) {
if(LoginState.assertEquals(this, LoginState.RECIEVED_ICE_CANIDATE)) {
if(LoginState.assertEquals(this, LoginState.INIT)) {
state = LoginState.SENT_DESCRIPTION;
server.handleClientDescription(this, (IPacket04Description)packet);
EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x04: Description", (String) socket.getAttachment());
}
return true;
}else if(packet instanceof IPacket05ClientSuccess) {
if(LoginState.assertEquals(this, LoginState.RECIEVED_DESCRIPTION)) {
if(LoginState.assertEquals(this, LoginState.RECIEVED_ICE_CANIDATE)) {
state = LoginState.FINISHED;
server.handleClientSuccess(this, (IPacket05ClientSuccess)packet);
EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x05: ClientSuccess", (String) socket.getAttachment());
@ -69,7 +69,7 @@ public class EaglerSPClient {
}
return true;
}else if(packet instanceof IPacket06ClientFailure) {
if(LoginState.assertEquals(this, LoginState.RECIEVED_DESCRIPTION)) {
if(LoginState.assertEquals(this, LoginState.RECIEVED_ICE_CANIDATE)) {
state = LoginState.FINISHED;
server.handleClientFailure(this, (IPacket06ClientFailure)packet);
EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x05: ClientFailure", (String) socket.getAttachment());
@ -96,7 +96,7 @@ public class EaglerSPClient {
public void disconnect(int code, String reason) {
IPacket pkt = new IPacketFEDisconnectClient(id, code, reason);
if(!serverNotifiedOfClose) {
server.send(pkt);
if (code != IPacketFEDisconnectClient.TYPE_FINISHED_SUCCESS) server.send(pkt);
serverNotifiedOfClose = true;
}
if(this.socket.isOpen()) {

View File

@ -368,7 +368,7 @@ public class EaglerSPRelay extends WebSocketServer {
cl = clientConnections.get(arg0);
}
if(cl != null) {
if(cl.handle(pkt)) {
if(!cl.handle(pkt)) {
logger.debug("[{}]: Client sent invalid packet: {}", (String) arg0.getAttachment(), pkt.getClass().getSimpleName());
arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_INVALID_PACKET,
"Invalid Packet Recieved")));

View File

@ -84,7 +84,7 @@ public class EaglerSPRelayConfigRelayList {
}else if(isTURNHead) {
addType = RelayType.TURN;
}else if(line.startsWith("url")) {
int spidx = line.indexOf('=');
int spidx = line.indexOf('=') + 1;
if(spidx < 3) {
EaglerSPRelay.logger.error("Error: Invalid line in {}: ", line);
}else {
@ -96,7 +96,7 @@ public class EaglerSPRelayConfigRelayList {
}
}
}else if(line.startsWith("username")) {
int spidx = line.indexOf('=');
int spidx = line.indexOf('=') + 1;
if(spidx < 8) {
EaglerSPRelay.logger.error("Error: Invalid line in {}: ", line);
}else {
@ -108,7 +108,7 @@ public class EaglerSPRelayConfigRelayList {
}
}
}else if(line.startsWith("password")) {
int spidx = line.indexOf('=');
int spidx = line.indexOf('=') + 1;
if(spidx < 8) {
EaglerSPRelay.logger.error("Error: Invalid line in {}: ", line);
}else {

View File

@ -32,18 +32,18 @@ public class GuiScreenAddRelay extends GuiScreen {
StringTranslate var1 = StringTranslate.getInstance();
EaglerAdapter.enableRepeatEvents(true);
this.buttonList.clear();
this.parentGui.addNewName = IntegratedServer.relayManager.makeNewRelayName();
this.parentGui.addNewAddr = "";
this.parentGui.addNewPrimary = IntegratedServer.relayManager.count() == 0;
int sslOff = EaglerAdapter.isSSLPage() ? 36 : 0;
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12 + sslOff, var1.translateKey("addRelay.add")));
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12 + sslOff, var1.translateKey("gui.cancel")));
this.buttonList.add(new GuiButton(2, this.width / 2 - 100, 142, var1.translateKey("addRelay.primary") + ": " + var1.translateKey("gui.no")));
this.buttonList.add(new GuiButton(2, this.width / 2 - 100, 142, var1.translateKey("addRelay.primary") + ": " + (this.parentGui.addNewPrimary ? var1.translateKey("gui.yes") : var1.translateKey("gui.no"))));
this.serverName = new GuiTextField(this.fontRenderer, this.width / 2 - 100, 106, 200, 20);
this.serverAddress = new GuiTextField(this.fontRenderer, this.width / 2 - 100, 66, 200, 20);
this.serverAddress.setMaxStringLength(128);
this.serverAddress.setFocused(true);
((GuiButton) this.buttonList.get(0)).enabled = this.serverAddress.getText().length() > 0 && this.serverAddress.getText().split(":").length > 0 && this.serverName.getText().length() > 0;
this.parentGui.addNewName = IntegratedServer.relayManager.makeNewRelayName();
this.parentGui.addNewAddr = "";
this.parentGui.addNewPrimary = IntegratedServer.relayManager.count() == 0;
this.serverName.setText(this.parentGui.addNewName);
}

View File

@ -20,8 +20,8 @@ public class GuiScreenChangeRelayTimeout extends GuiScreen {
StringTranslate ts = StringTranslate.getInstance();
title = ts.translateKey("networkSettings.relayTimeoutTitle");
buttonList.clear();
buttonList.add(new GuiButton(0, width / 2 - 100, height / 3 + 55, ts.translateKey("gui.cancel")));
buttonList.add(new GuiButton(1, width / 2 - 100, height / 3 + 85, ts.translateKey("gui.done")));
buttonList.add(new GuiButton(0, width / 2 - 100, height / 3 + 55, ts.translateKey("gui.done")));
buttonList.add(new GuiButton(1, width / 2 - 100, height / 3 + 85, ts.translateKey("gui.cancel")));
slider = new GuiSlider2(0, width / 2 - 100, height / 3 + 10, 200, 20, (mc.gameSettings.relayTimeout - 1) / 14.0f, 1.0f) {
public boolean mousePressed(Minecraft par1Minecraft, int par2, int par3) {
if(super.mousePressed(par1Minecraft, par2, par3)) {
@ -41,11 +41,11 @@ public class GuiScreenChangeRelayTimeout extends GuiScreen {
public void actionPerformed(GuiButton btn) {
if(btn.id == 0) {
mc.displayGuiScreen(parent);
}else if(btn.id == 1) {
mc.gameSettings.relayTimeout = (int)((slider.sliderValue * 14.0f) + 1.0f);
mc.gameSettings.saveOptions();
mc.displayGuiScreen(parent);
}else if(btn.id == 1) {
mc.displayGuiScreen(parent);
}
}

View File

@ -59,7 +59,7 @@ public class IntegratedServerLAN {
Thread.sleep(50l);
} catch (InterruptedException e) {
}
}while(System.currentTimeMillis() - millis > 1000l);
}while(System.currentTimeMillis() - millis < 1000l);
System.out.println("Relay [" + sock.getURI() + "] relay provide ICE servers timeout");
closeLAN();
return null;
@ -80,6 +80,7 @@ public class IntegratedServerLAN {
lanRelaySocket = null;
currentCode = null;
}
EaglerAdapter.serverLANCloseServer();
cleanupLAN();
}
@ -100,7 +101,7 @@ public class IntegratedServerLAN {
public static void updateLANServer() {
if(lanRelaySocket != null) {
IPacket pkt;
while((pkt = lanRelaySocket.nextPacket()) != null) {
while((pkt = lanRelaySocket.readPacket()) != null) {
if(pkt instanceof IPacket02NewClient) {
IPacket02NewClient ipkt = (IPacket02NewClient) pkt;
if(clients.containsKey(ipkt.clientId)) {
@ -180,10 +181,11 @@ public class IntegratedServerLAN {
protected LANClient(String clientId) {
this.clientId = clientId;
EaglerAdapter.serverLANCreatePeer(clientId);
}
protected void handleICECandidates(String candidates) {
if(state == PRE) {
if(state == SENT_DESCRIPTION) {
EaglerAdapter.serverLANPeerICECandidates(clientId, candidates);
long millis = System.currentTimeMillis();
do {
@ -205,7 +207,7 @@ public class IntegratedServerLAN {
Thread.sleep(20l);
} catch (InterruptedException e) {
}
}while(System.currentTimeMillis() - millis > 3000l);
}while(System.currentTimeMillis() - millis < 3000l);
System.err.println("Getting server ICE candidates for '" + clientId + "' timed out!");
disconnect();
}else {
@ -214,7 +216,7 @@ public class IntegratedServerLAN {
}
protected void handleDescription(String description) {
if(state == SENT_ICE_CANDIDATE) {
if(state == PRE) {
EaglerAdapter.serverLANPeerDescription(clientId, description);
long millis = System.currentTimeMillis();
do {
@ -236,7 +238,7 @@ public class IntegratedServerLAN {
Thread.sleep(20l);
} catch (InterruptedException e) {
}
}while(System.currentTimeMillis() - millis > 3000l);
}while(System.currentTimeMillis() - millis < 3000l);
System.err.println("Getting server description for '" + clientId + "' timed out!");
disconnect();
}else {
@ -245,7 +247,7 @@ public class IntegratedServerLAN {
}
protected void handleSuccess() {
if(state == SENT_DESCRIPTION) {
if(state == SENT_ICE_CANDIDATE) {
long millis = System.currentTimeMillis();
do {
LANPeerEvent evt;
@ -254,6 +256,9 @@ public class IntegratedServerLAN {
EaglerAdapter.enableChannel("NET|" + clientId);
state = CONNECTED;
return;
}else if(evt instanceof LANPeerEvent.LANPeerICECandidateEvent) {
// ignore
return;
}else if(evt instanceof LANPeerEvent.LANPeerDisconnectEvent) {
System.err.println("LAN client '" + clientId + "' disconnected while waiting for connection");
}else {
@ -266,7 +271,7 @@ public class IntegratedServerLAN {
Thread.sleep(20l);
} catch (InterruptedException e) {
}
}while(System.currentTimeMillis() - millis > 3000l);
}while(System.currentTimeMillis() - millis < 3000l);
System.err.println("Getting server description for '" + clientId + "' timed out!");
disconnect();
}else {
@ -275,7 +280,7 @@ public class IntegratedServerLAN {
}
protected void handleFailure() {
if(state == SENT_DESCRIPTION) {
if(state == SENT_ICE_CANDIDATE) {
System.err.println("Client '" + clientId + "' failed to connect");
disconnect();
}else {
@ -312,7 +317,10 @@ public class IntegratedServerLAN {
EaglerAdapter.disableChannel("NET|" + clientId);
}
state = CLOSED;
if (lanRelaySocket != null) {
lanRelaySocket.writePacket(new IPacketFEDisconnectClient(clientId, IPacketFEDisconnectClient.TYPE_SERVER_DISCONNECT, "Connection Closed"));
}
EaglerAdapter.serverLANDisconnectPeer(clientId);
dead = true;
}
}

View File

@ -80,25 +80,25 @@ public class LANClientNetworkManager implements INetworkManager {
// await result
long lm = System.currentTimeMillis();
do {
String c = EaglerAdapter.clientLANAwaitICECandidate();
String c = EaglerAdapter.clientLANAwaitDescription();
if(c != null) {
System.out.println("Relay [" + displayRelay + "|" + displayCode + "] client sent ICE candidate");
System.out.println("Relay [" + displayRelay + "|" + displayCode + "] client sent description");
// 'this.iceCandidateHandler' was called, send result:
sock.writePacket(new IPacket03ICECandidate("", c));
// 'this.descriptionHandler' was called, send result:
sock.writePacket(new IPacket04Description("", c));
connectState = SENT_ICE_CANDIDATE;
connectState = SENT_DESCRIPTION;
continue mainLoop;
}
try {
Thread.sleep(20l);
} catch (InterruptedException e) {
}
}while(System.currentTimeMillis() - lm > 3000l);
}while(System.currentTimeMillis() - lm < 3000l);
// no ice candidates were sent
// no description was sent
sock.close();
System.err.println("Relay [" + displayRelay + "|" + displayCode + "] client provide ICE candidate timeout");
System.err.println("Relay [" + displayRelay + "|" + displayCode + "] client provide description timeout");
return null;
}else {
@ -121,25 +121,25 @@ public class LANClientNetworkManager implements INetworkManager {
// await result
long lm = System.currentTimeMillis();
do {
String c = EaglerAdapter.clientLANAwaitDescription();
if(c != null) {
System.out.println("Relay [" + displayRelay + "|" + displayCode + "] client sent description");
if(EaglerAdapter.clientLANAwaitChannel()) {
System.out.println("Relay [" + displayRelay + "|" + displayCode + "] client opened data channel");
// 'this.descriptionHandler' was called, send result:
sock.writePacket(new IPacket04Description("", c));
// 'this.remoteDataChannelHandler' was called, success
sock.writePacket(new IPacket05ClientSuccess(ipkt.peerId));
sock.close();
return new LANClientNetworkManager(displayCode, displayRelay);
connectState = SENT_DESCRIPTION;
continue mainLoop;
}
try {
Thread.sleep(20l);
} catch (InterruptedException e) {
}
}while(System.currentTimeMillis() - lm > 3000l);
}while(System.currentTimeMillis() - lm < 3000l);
// no description was sent
// no channel was opened
sock.writePacket(new IPacket06ClientFailure());
sock.close();
System.err.println("Relay [" + displayRelay + "|" + displayCode + "] client provide description timeout");
System.err.println("Relay [" + displayRelay + "|" + displayCode + "] client open data channel timeout");
return null;
}else {
@ -153,35 +153,34 @@ public class LANClientNetworkManager implements INetworkManager {
// %%%%%% Process IPacket04Description %%%%%%
IPacket03ICECandidate ipkt = (IPacket03ICECandidate) pkt;
IPacket04Description ipkt = (IPacket04Description) pkt;
// process
System.out.println("Relay [" + displayRelay + "|" + displayCode + "] recieved server description");
EaglerAdapter.clientLANSetDescription(ipkt.candidate);
EaglerAdapter.clientLANSetDescription(ipkt.description);
// await result
long lm = System.currentTimeMillis();
do {
if(EaglerAdapter.clientLANAwaitChannel()) {
System.out.println("Relay [" + displayRelay + "|" + displayCode + "] client opened data channel");
String c = EaglerAdapter.clientLANAwaitICECandidate();
if(c != null) {
System.out.println("Relay [" + displayRelay + "|" + displayCode + "] client sent ICE candidate");
// 'this.remoteDataChannelHandler' was called, success
sock.writePacket(new IPacket05ClientSuccess());
sock.close();
return new LANClientNetworkManager(displayCode, displayRelay);
// 'this.iceCandidateHandler' was called, send result:
sock.writePacket(new IPacket03ICECandidate("", c));
connectState = SENT_ICE_CANDIDATE;
continue mainLoop;
}
try {
Thread.sleep(20l);
} catch (InterruptedException e) {
}
}while(System.currentTimeMillis() - lm > 3000l);
}while(System.currentTimeMillis() - lm < 3000l);
// no channel was opened
sock.writePacket(new IPacket06ClientFailure());
// no ice candidates were sent
sock.close();
System.err.println("Relay [" + displayRelay + "|" + displayCode + "] client open data channel timeout");
System.err.println("Relay [" + displayRelay + "|" + displayCode + "] client provide ICE candidate timeout");
return null;
}else {

View File

@ -14,6 +14,8 @@ public class GuiIngameMenu extends GuiScreen {
private GuiVoiceMenu voiceMenu;
private GuiButton lanButton;
public GuiIngameMenu() {
voiceMenu = new GuiVoiceMenu(this);
}
@ -32,9 +34,8 @@ public class GuiIngameMenu extends GuiScreen {
this.buttonList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 24 + var1, StatCollector.translateToLocal("menu.returnToGame")));
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + var1, 98, 20, StatCollector.translateToLocal("menu.options")));
GuiButton var3;
this.buttonList.add(var3 = new GuiButton(7, this.width / 2 + 2, this.height / 4 + 96 + var1, 98, 20, StatCollector.translateToLocal(IntegratedServerLAN.isHostingLAN() ? "menu.closeLan" : "menu.shareToLan")));
var3.enabled = mc.isSingleplayer();
this.buttonList.add(lanButton = new GuiButton(7, this.width / 2 + 2, this.height / 4 + 96 + var1, 98, 20, StatCollector.translateToLocal(IntegratedServerLAN.isHostingLAN() ? "menu.closeLan" : "menu.shareToLan")));
lanButton.enabled = mc.isSingleplayer();
this.buttonList.add(new GuiButton(8, 3, 3, 120, 20, StatCollector.translateToLocal("menu.skinCapeSettings")));
}
@ -71,9 +72,7 @@ public class GuiIngameMenu extends GuiScreen {
IntegratedServerLAN.closeLAN();
IntegratedServer.configureLAN(this.mc.theWorld.getWorldInfo().getGameType(), false);
this.mc.thePlayer.sendChatToPlayer(StatCollector.translateToLocal("lanServer.closed"));
this.mc.displayGuiScreen((GuiScreen) null);
this.mc.setIngameFocus();
this.mc.sndManager.resumeAllSounds();
this.lanButton.displayString = StatCollector.translateToLocal("menu.shareToLan");
} else {
if(IntegratedServer.relayManager.count() == 0) {
this.mc.displayGuiScreen(new GuiScreenNoRelays(this, "noRelay.title"));

View File

@ -22,11 +22,11 @@ public class GuiShareToLan extends GuiScreen {
private String gameMode = "survival";
/** True if 'Allow Cheats' is currently enabled */
private boolean allowCommands;
private boolean allowCommands = false;
private final GuiNetworkSettingsButton relaysButton;
private boolean hiddenToggle;
private boolean hiddenToggle = false;
private GuiTextField codeTextField;
@ -102,7 +102,7 @@ public class GuiShareToLan extends GuiScreen {
} else if (par1GuiButton.id == 103) {
this.allowCommands = !this.allowCommands;
this.func_74088_g();
} else if (par1GuiButton.id == 104) {
} else if (par1GuiButton.id == 105) {
this.hiddenToggle = !this.hiddenToggle;
this.func_74088_g();
} else if (par1GuiButton.id == 101) {

View File

@ -3719,7 +3719,23 @@ public class EaglerAdapterImpl2 {
return rtcLANClient.LANClientSupported();
}
public static final void clientLANSetServer(String relay, String peerId) {
public static final int clientLANReadyState() {
return rtcLANClient.getReadyState();
}
public static final void clientLANCloseConnection() {
rtcLANClient.signalRemoteDisconnect();
}
public static final void clientLANSendPacket(byte[] pkt) {
rtcLANClient.sendPacketToServer(convertToArrayBuffer(pkt));
}
public static final byte[] clientLANReadPacket() {
return clientLANPacketBuffer.size() > 0 ? clientLANPacketBuffer.remove(0) : null;
}
public static final void clientLANSetICEServersAndConnect(String[] servers) {
if(!clientLANinit) {
clientLANinit = true;
rtcLANClient.setDescriptionHandler(new EaglercraftLANClient.DescriptionHandler() {
@ -3758,27 +3774,11 @@ public class EaglerAdapterImpl2 {
}
});
}
// todo: java-side: register with relay and set server
}
public static final int clientLANReadyState() {
return rtcLANClient.getReadyState();
}
public static final void clientLANCloseConnection() {
rtcLANClient.setICEServers(servers);
if(clientLANReadyState() == rtcLANClient.READYSTATE_CONNECTED || clientLANReadyState() == rtcLANClient.READYSTATE_CONNECTING) {
rtcLANClient.signalRemoteDisconnect();
}
public static final void clientLANSendPacket(byte[] pkt) {
rtcLANClient.sendPacketToServer(convertToArrayBuffer(pkt));
}
public static final byte[] clientLANReadPacket() {
return clientLANPacketBuffer.size() > 0 ? clientLANPacketBuffer.remove(0) : null;
}
public static final void clientLANSetICEServersAndConnect(String[] servers) {
rtcLANClient.setICEServers(servers);
rtcLANClient.initializeClient();
rtcLANClient.signalRemoteConnect();
}
@ -3850,14 +3850,14 @@ public class EaglerAdapterImpl2 {
serverLANinit = true;
rtcLANServer.setDescriptionHandler(new EaglercraftLANServer.DescriptionHandler() {
@Override
public void call(String peerId, String candidate) {
serverLANEventBuffer.add(new LANPeerEvent.LANPeerDisconnectEvent(peerId));
public void call(String peerId, String description) {
serverLANEventBuffer.add(new LANPeerEvent.LANPeerDescriptionEvent(peerId, description));
}
});
rtcLANServer.setICECandidateHandler(new EaglercraftLANServer.ICECandidateHandler() {
@Override
public void call(String peerId, String candidate) {
serverLANEventBuffer.add(new LANPeerEvent.LANPeerDisconnectEvent(peerId));
serverLANEventBuffer.add(new LANPeerEvent.LANPeerICECandidateEvent(peerId, candidate));
}
});
rtcLANServer.setRemoteClientDataChannelHandler(new EaglercraftLANServer.ClientSignalHandler() {
@ -3892,7 +3892,6 @@ public class EaglerAdapterImpl2 {
public static final void serverLANCloseServer() {
rtcLANServer.signalRemoteDisconnect("");
// todo: java-side: disconnect from relay server
}
public static final LANPeerEvent serverLANGetEvent() {