LAN world API draft

This commit is contained in:
LAX1DUDE 2022-08-06 15:33:14 -07:00
parent 36c75ca4e1
commit e93e53541e
16 changed files with 53516 additions and 53023 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

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

@ -0,0 +1,41 @@
<html>
<head><title>eeeeeeee</title></head>
<style type="text/css">
.consoleTab {
margin-block-start: 0px;
margin-block-end: 0px;
margin: 4px 1px 0px 1px;
border-radius: 6px 6px 0px 0px;
background-color: #E6E6E6;
padding: 4px 8px;
display: inline-block;
font-family: monospace;
font-size: 1.1em;
user-select: none;
cursor: pointer;
border-top: 1px solid #BBBBBB;
border-left: 1px solid #BBBBBB;
border-right: 1px solid #BBBBBB;
color: black;
}
.consoleTab:hover {
background-color: #E5E5F9;
}
.consoleTabDisabled {
background-color: #F7F7F7;
border-top: 1px solid #E6E6E6;
border-left: 1px solid #E6E6E6;
border-right: 1px solid #E6E6E6;
color: #444444;
}
.consoleTabDisabled:hover {
background-color: #E7E7EE;
}
</style>
<body style="margin:20px;">
<div>
<p class="consoleTab">Client</p>
<p class="consoleTab consoleTabDisabled">Server</p>
</div>
</body>
</html>

View File

@ -2,14 +2,17 @@
/*
This is the backend for voice channels in eaglercraft, it links with TeaVM EaglerAdapter at runtime
This is the backend for voice channels and LAN servers in eaglercraft
Copyright 2022 Calder Young & ayunami2000. All rights reserved.
it links with TeaVM EaglerAdapter at runtime
Based on code written by ayunami2000
Copyright 2022 ayunami2000 & lax1dude. All rights reserved.
*/
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%% VOICE CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
window.initializeVoiceClient = (() => {
const READYSTATE_NONE = 0;
@ -304,4 +307,166 @@ window.startVoiceClient = () => {
window.initializeVoiceClient();
}
return window.constructVoiceClient();
};
};
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%% LAN CLIENT CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
window.initializeLANClient = (() => {
const READYSTATE_INIT_FAILED = -2;
const READYSTATE_FAILED = -1;
const READYSTATE_DISCONNECTED = 0;
const READYSTATE_CONNECTING = 1;
const READYSTATE_CONNECTED = 2;
class EaglercraftLANClient {
constructor() {
}
LANClientSupported() {
}
initializeClient() {
}
setICEServers(urls) {
}
setICECandidateHandler(cb) {
}
setDescriptionHandler(cb) {
}
setRemoteDataChannelHandler(cb) {
}
setRemoteDisconnectHandler(cb) {
}
setRemotePacketHandler(cb) {
}
getReadyState() {
}
sendPacketToServer(buffer) {
}
signalRemoteConnect() {
}
signalRemoteDescription(descJSON) {
}
signalRemoteICECandidate(candidate) {
}
};
window.constructLANClient = () => new EaglercraftLANClient();
});
window.startLANClient = () => {
if(typeof window.constructLANClient !== "function") {
window.initializeLANClient();
}
return window.constructLANClient();
};
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%% LAN SERVER CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
window.initializeLANServer = (() => {
class EaglercraftLANServer {
constructor() {
}
LANServerSupported() {
}
initializeServer() {
}
setRecieveCodeHandler(cb) {
}
setICEServers(urls) {
}
setICECandidateHandler(cb) {
}
setDescriptionHandler(cb) {
}
setRemoteClientDataChannelHandler(cb) {
}
setRemoteClientDisconnectHandler(cb) {
}
setRemoteClientPacketHandler(cb) {
}
sendPacketToRemoteClient(peerId, buffer) {
}
signalRemoteConnect(peerId) {
}
signalRemoteDescription(peerId, descJSON) {
}
signalRemoteICECandidate(peerId, candidate) {
}
disconnectRemotePeer(peerId) {
}
};
window.constructLANServer = () => new EaglercraftLANServer();
});
window.startLANServer = () => {
if(typeof window.constructLANServer !== "function") {
window.initializeLANServer();
}
return window.constructLANerver();
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -6,7 +6,7 @@ public class ConfigConstants {
public static boolean profanity = false;
public static final String version = "SP-SNAPSHOT-02";
public static final String version = "SP-SNAPSHOT-03";
public static final String mainMenuString = "eaglercraft " + version;
public static final String forkMe = "https://github.com/LAX1DUDE/eaglercraft";

View File

@ -451,6 +451,7 @@ public class GuiMainMenu extends GuiScreen {
}
private static final TextureLocation mclogo = new TextureLocation("/title/mclogo.png");
private static final TextureLocation eag = new TextureLocation("/title/eag.png");
private static final TextureLocation ackbk = new TextureLocation("/gui/demo_bg.png");
private static final TextureLocation beaconx = new TextureLocation("/gui/beacon.png");
private static final TextureLocation items = new TextureLocation("/gui/items.png");
@ -468,13 +469,15 @@ public class GuiMainMenu extends GuiScreen {
byte var7 = 30;
this.drawGradientRect(0, 0, this.width, this.height, -2130706433, 16777215);
this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE);
mclogo.bindTexture();
this.drawTexturedModalRect(var6 + 0, var7 + 0, 0, 0, 99, 44);
this.drawTexturedModalRect(var6 + 99, var7 + 0, 129, 0, 27, 44);
this.drawTexturedModalRect(var6 + 99 + 26, var7 + 0, 126, 0, 3, 44);
this.drawTexturedModalRect(var6 + 99 + 26 + 3, var7 + 0, 99, 0, 26, 44);
this.drawTexturedModalRect(var6 + 154, var7 + 0, 0, 45, 155, 44);
if(ConfigConstants.eaglercraftTitleLogo) {
eag.bindTexture();
}else {
mclogo.bindTexture();
}
this.drawTexturedModalRect(var6 + 0, var7 + 0, 0, 0, 155, 44);
this.drawTexturedModalRect(var6 + 155, var7 + 0, 0, 45, 155, 44);
this.drawString(this.fontRenderer, "minecraft 1.5.2", 2, this.height - 20, 16777215);
this.drawString(this.fontRenderer, ConfigConstants.mainMenuString + EnumChatFormatting.GRAY + " (cracked)", 2, this.height - 10, 16777215);

View File

@ -93,6 +93,8 @@ import net.lax1dude.eaglercraft.LocalStorageManager;
import net.lax1dude.eaglercraft.PKT;
import net.lax1dude.eaglercraft.ServerQuery;
import net.lax1dude.eaglercraft.Voice;
import net.lax1dude.eaglercraft.adapter.teavm.EaglercraftLANClient;
import net.lax1dude.eaglercraft.adapter.teavm.EaglercraftLANServer;
import net.lax1dude.eaglercraft.adapter.teavm.EaglercraftVoiceClient;
import net.lax1dude.eaglercraft.adapter.teavm.SelfDefence;
import net.lax1dude.eaglercraft.adapter.teavm.WebGL2RenderingContext;
@ -338,43 +340,16 @@ public class EaglerAdapterImpl2 {
});
onBeforeCloseRegister();
/*
this was on the singleplayer branch, it needs to be re-implemented without eval:
execute("window.eagsFileChooser = {\r\n" +
"inputElement: null,\r\n" +
"openFileChooser: function(ext, mime){\r\n" +
"el = window.eagsFileChooser.inputElement = document.createElement(\"input\");\r\n" +
"el.type = \"file\";\r\n" +
"el.multiple = false;\r\n" +
"el.addEventListener(\"change\", function(evt){\r\n" +
"var f = window.eagsFileChooser.inputElement.files;\r\n" +
"if(f.length == 0){\r\n" +
"window.eagsFileChooser.getFileChooserResult = null;\r\n" +
"window.eagsFileChooser.getFileChooserResultName = \"<none>\";\r\n" +
"}else{\r\n" +
"(async function(){\r\n" +
"window.eagsFileChooser.getFileChooserResult = await f[0].arrayBuffer();\r\n" +
"window.eagsFileChooser.getFileChooserResultName = f[0].name;\r\n" +
"})();\r\n" +
"}\r\n" +
"});\r\n" +
"window.eagsFileChooser.getFileChooserResult = null;\r\n" +
"window.eagsFileChooser.getFileChooserResultName = null;\r\n" +
"el.accept = (mime === null ? \".\"+ext : mime);\r\n" +
"el.click();\r\n" +
"},\r\n" +
"getFileChooserResult: null,\r\n" +
"getFileChooserResultName: null\r\n" +
"};");
*/
initFileChooser();
EarlyLoadScreen.paintScreen();
voiceClient = startVoiceClient();
rtcLANClient = startRTCLANClient();
if(integratedServerScript != null) {
rtcLANServer = startRTCLANServer();
}
downloadAssetPack(assetPackageURI);
@ -2100,7 +2075,7 @@ public class EaglerAdapterImpl2 {
voiceAvailableStat = false;
}
public static void setVoiceSignalHandler(Consumer<byte[]> signalHandler) {
public static void setVoiceSignalHandler(Consumer<byte[]> signalHandler) { //TODO
returnSignalHandler = signalHandler;
}
@ -2467,230 +2442,51 @@ public class EaglerAdapterImpl2 {
private static String[] LWJGLKeyNames = new String[] {"NONE", "ESCAPE", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "MINUS", "EQUALS", "BACK", "TAB", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "LBRACKET", "RBRACKET", "RETURN", "LCONTROL", "A", "S", "D", "F", "G", "H", "J", "K", "L", "SEMICOLON", "APOSTROPHE", "GRAVE", "LSHIFT", "BACKSLASH", "Z", "X", "C", "V", "B", "N", "M", "COMMA", "PERIOD", "SLASH", "RSHIFT", "MULTIPLY", "LMENU", "SPACE", "CAPITAL", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "NUMLOCK", "SCROLL", "NUMPAD7", "NUMPAD8", "NUMPAD9", "SUBTRACT", "NUMPAD4", "NUMPAD5", "NUMPAD6", "ADD", "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD0", "DECIMAL", "null", "null", "null", "F11", "F12", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "F13", "F14", "F15", "F16", "F17", "F18", "null", "null", "null", "null", "null", "null", "KANA", "F19", "null", "null", "null", "null", "null", "null", "null", "CONVERT", "null", "NOCONVERT", "null", "YEN", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "NUMPADEQUALS", "null", "null", "CIRCUMFLEX", "AT", "COLON", "UNDERLINE", "KANJI", "STOP", "AX", "UNLABELED", "null", "null", "null", "null", "NUMPADENTER", "RCONTROL", "null", "null", "null", "null", "null", "null", "null", "null", "null", "SECTION", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "NUMPADCOMMA", "null", "DIVIDE", "null", "SYSRQ", "RMENU", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "FUNCTION", "PAUSE", "null", "HOME", "UP", "PRIOR", "null", "LEFT", "null", "RIGHT", "null", "END", "DOWN", "NEXT", "INSERT", "DELETE", "null", "null", "null", "null", "null", "null", "CLEAR", "LMETA", "RMETA", "APPS", "POWER", "SLEEP", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null"};
private static int[] LWJGLKeyCodes = new int[] {
/* 0 */ -1,
/* 1 */ -1,
/* 2 */ -1,
/* 3 */ -1,
/* 4 */ -1,
/* 5 */ -1,
/* 6 */ -1,
/* 7 */ -1,
/* 8 */ 14,
/* 9 */ 15,
/* 10 */ -1,
/* 11 */ -1,
/* 12 */ -1,
/* 13 */ 28,
/* 14 */ -1,
/* 15 */ -1,
/* 16 */ 42,
/* 17 */ 29,
/* 18 */ 56,
/* 19 */ -1,
/* 20 */ -1,
/* 21 */ -1,
/* 22 */ -1,
/* 23 */ -1,
/* 24 */ -1,
/* 25 */ -1,
/* 26 */ -1,
/* 27 */ 1,
/* 28 */ -1,
/* 29 */ -1,
/* 30 */ -1,
/* 31 */ -1,
/* 32 */ 57,
/* 33 */ 210,
/* 34 */ 201,
/* 35 */ 207,
/* 36 */ 199,
/* 37 */ 203,
/* 38 */ 200,
/* 39 */ 205,
/* 40 */ 208,
/* 41 */ 205,
/* 42 */ 208,
/* 43 */ -1,
/* 44 */ -1,
/* 45 */ 210,
/* 46 */ 211,
/* 47 */ 211,
/* 48 */ 11,
/* 49 */ 2,
/* 50 */ 3,
/* 51 */ 4,
/* 52 */ 5,
/* 53 */ 6,
/* 54 */ 7,
/* 55 */ 8,
/* 56 */ 9,
/* 57 */ 10,
/* 58 */ -1,
/* 59 */ -1,
/* 60 */ -1,
/* 61 */ -1,
/* 62 */ -1,
/* 63 */ -1,
/* 64 */ -1,
/* 65 */ 30,
/* 66 */ 48,
/* 67 */ 46,
/* 68 */ 32,
/* 69 */ 18,
/* 70 */ 33,
/* 71 */ 34,
/* 72 */ 35,
/* 73 */ 23,
/* 74 */ 36,
/* 75 */ 37,
/* 76 */ 38,
/* 77 */ 50,
/* 78 */ 49,
/* 79 */ 24,
/* 80 */ 25,
/* 81 */ 16,
/* 82 */ 19,
/* 83 */ 31,
/* 84 */ 20,
/* 85 */ 22,
/* 86 */ 47,
/* 87 */ 17,
/* 88 */ 45,
/* 89 */ 21,
/* 90 */ 44,
/* 91 */ -1,
/* 92 */ -1,
/* 93 */ -1,
/* 94 */ -1,
/* 95 */ -1,
/* 96 */ -1,
/* 97 */ -1,
/* 98 */ -1,
/* 99 */ -1,
/* 100 */ -1,
/* 101 */ -1,
/* 102 */ -1,
/* 103 */ -1,
/* 104 */ -1,
/* 105 */ -1,
/* 106 */ -1,
/* 107 */ -1,
/* 108 */ -1,
/* 109 */ 12,
/* 110 */ 52,
/* 111 */ 53,
/* 112 */ -1,
/* 113 */ -1,
/* 114 */ -1,
/* 115 */ -1,
/* 116 */ -1,
/* 117 */ -1,
/* 118 */ -1,
/* 119 */ -1,
/* 120 */ -1,
/* 121 */ -1,
/* 122 */ -1,
/* 123 */ -1,
/* 124 */ -1,
/* 125 */ -1,
/* 126 */ -1,
/* 127 */ -1,
/* 128 */ -1,
/* 129 */ -1,
/* 130 */ -1,
/* 131 */ -1,
/* 132 */ -1,
/* 133 */ -1,
/* 134 */ -1,
/* 135 */ -1,
/* 136 */ -1,
/* 137 */ -1,
/* 138 */ -1,
/* 139 */ -1,
/* 140 */ -1,
/* 141 */ -1,
/* 142 */ -1,
/* 143 */ -1,
/* 144 */ -1,
/* 145 */ -1,
/* 146 */ -1,
/* 147 */ -1,
/* 148 */ -1,
/* 149 */ -1,
/* 150 */ -1,
/* 151 */ -1,
/* 152 */ -1,
/* 153 */ -1,
/* 154 */ -1,
/* 155 */ -1,
/* 156 */ -1,
/* 157 */ -1,
/* 158 */ -1,
/* 159 */ -1,
/* 160 */ -1,
/* 161 */ -1,
/* 162 */ -1,
/* 163 */ -1,
/* 164 */ -1,
/* 165 */ -1,
/* 166 */ -1,
/* 167 */ -1,
/* 168 */ -1,
/* 169 */ -1,
/* 170 */ -1,
/* 171 */ -1,
/* 172 */ -1,
/* 173 */ -1,
/* 174 */ -1,
/* 175 */ -1,
/* 176 */ -1,
/* 177 */ -1,
/* 178 */ -1,
/* 179 */ -1,
/* 180 */ -1,
/* 181 */ -1,
/* 182 */ -1,
/* 183 */ -1,
/* 184 */ -1,
/* 185 */ -1,
/* 186 */ 39,
/* 187 */ 13,
/* 188 */ 51,
/* 189 */ 12,
/* 190 */ 52,
/* 191 */ 53,
/* 192 */ -1,
/* 193 */ -1,
/* 194 */ -1,
/* 195 */ -1,
/* 196 */ -1,
/* 197 */ -1,
/* 198 */ -1,
/* 199 */ -1,
/* 200 */ -1,
/* 200 */ -1,
/* 201 */ -1,
/* 202 */ -1,
/* 203 */ -1,
/* 204 */ -1,
/* 205 */ -1,
/* 206 */ -1,
/* 207 */ -1,
/* 208 */ -1,
/* 209 */ -1,
/* 210 */ -1,
/* 211 */ -1,
/* 212 */ -1,
/* 213 */ -1,
/* 214 */ -1,
/* 215 */ -1,
/* 216 */ -1,
/* 217 */ -1,
/* 218 */ -1,
/* 219 */ 26,
/* 220 */ 43,
/* 221 */ 27,
/* 222 */ 40
/* 0 */ -1, /* 1 */ -1, /* 2 */ -1, /* 3 */ -1, /* 4 */ -1,
/* 5 */ -1, /* 6 */ -1, /* 7 */ -1, /* 8 */ 14, /* 9 */ 15,
/* 10 */ -1, /* 11 */ -1, /* 12 */ -1, /* 13 */ 28, /* 14 */ -1,
/* 15 */ -1, /* 16 */ 42, /* 17 */ 29, /* 18 */ 56, /* 19 */ -1,
/* 20 */ -1, /* 21 */ -1, /* 22 */ -1, /* 23 */ -1, /* 24 */ -1,
/* 25 */ -1, /* 26 */ -1, /* 27 */ 1, /* 28 */ -1, /* 29 */ -1,
/* 30 */ -1, /* 31 */ -1, /* 32 */ 57, /* 33 */ 210, /* 34 */ 201,
/* 35 */ 207, /* 36 */ 199, /* 37 */ 203, /* 38 */ 200, /* 39 */ 205,
/* 40 */ 208, /* 41 */ 205, /* 42 */ 208, /* 43 */ -1, /* 44 */ -1,
/* 45 */ 210, /* 46 */ 211, /* 47 */ 211, /* 48 */ 11, /* 49 */ 2,
/* 50 */ 3, /* 51 */ 4, /* 52 */ 5, /* 53 */ 6, /* 54 */ 7,
/* 55 */ 8, /* 56 */ 9, /* 57 */ 10, /* 58 */ -1, /* 59 */ -1,
/* 60 */ -1, /* 61 */ -1, /* 62 */ -1, /* 63 */ -1, /* 64 */ -1,
/* 65 */ 30, /* 66 */ 48, /* 67 */ 46, /* 68 */ 32, /* 69 */ 18,
/* 70 */ 33, /* 71 */ 34, /* 72 */ 35, /* 73 */ 23, /* 74 */ 36,
/* 75 */ 37, /* 76 */ 38, /* 77 */ 50, /* 78 */ 49, /* 79 */ 24,
/* 80 */ 25, /* 81 */ 16, /* 82 */ 19, /* 83 */ 31, /* 84 */ 20,
/* 85 */ 22, /* 86 */ 47, /* 87 */ 17, /* 88 */ 45, /* 89 */ 21,
/* 90 */ 44, /* 91 */ -1, /* 92 */ -1, /* 93 */ -1, /* 94 */ -1,
/* 95 */ -1, /* 96 */ -1, /* 97 */ -1, /* 98 */ -1, /* 99 */ -1,
/* 100 */ -1, /* 101 */ -1, /* 102 */ -1, /* 103 */ -1, /* 104 */ -1,
/* 105 */ -1, /* 106 */ -1, /* 107 */ -1, /* 108 */ -1, /* 109 */ 12,
/* 110 */ 52, /* 111 */ 53, /* 112 */ -1, /* 113 */ -1, /* 114 */ -1,
/* 115 */ -1, /* 116 */ -1, /* 117 */ -1, /* 118 */ -1, /* 119 */ -1,
/* 120 */ -1, /* 121 */ -1, /* 122 */ -1, /* 123 */ -1, /* 124 */ -1,
/* 125 */ -1, /* 126 */ -1, /* 127 */ -1, /* 128 */ -1, /* 129 */ -1,
/* 130 */ -1, /* 131 */ -1, /* 132 */ -1, /* 133 */ -1, /* 134 */ -1,
/* 135 */ -1, /* 136 */ -1, /* 137 */ -1, /* 138 */ -1, /* 139 */ -1,
/* 140 */ -1, /* 141 */ -1, /* 142 */ -1, /* 143 */ -1, /* 144 */ -1,
/* 145 */ -1, /* 146 */ -1, /* 147 */ -1, /* 148 */ -1, /* 149 */ -1,
/* 150 */ -1, /* 151 */ -1, /* 152 */ -1, /* 153 */ -1, /* 154 */ -1,
/* 155 */ -1, /* 156 */ -1, /* 157 */ -1, /* 158 */ -1, /* 159 */ -1,
/* 160 */ -1, /* 161 */ -1, /* 162 */ -1, /* 163 */ -1, /* 164 */ -1,
/* 165 */ -1, /* 166 */ -1, /* 167 */ -1, /* 168 */ -1, /* 169 */ -1,
/* 170 */ -1, /* 171 */ -1, /* 172 */ -1, /* 173 */ -1, /* 174 */ -1,
/* 175 */ -1, /* 176 */ -1, /* 177 */ -1, /* 178 */ -1, /* 179 */ -1,
/* 180 */ -1, /* 181 */ -1, /* 182 */ -1, /* 183 */ -1, /* 184 */ -1,
/* 185 */ -1, /* 186 */ 39, /* 187 */ 13, /* 188 */ 51, /* 189 */ 12,
/* 190 */ 52, /* 191 */ 53, /* 192 */ -1, /* 193 */ -1, /* 194 */ -1,
/* 195 */ -1, /* 196 */ -1, /* 197 */ -1, /* 198 */ -1, /* 199 */ -1,
/* 200 */ -1, /* 201 */ -1, /* 202 */ -1, /* 203 */ -1, /* 204 */ -1,
/* 205 */ -1, /* 206 */ -1, /* 207 */ -1, /* 208 */ -1, /* 209 */ -1,
/* 210 */ -1, /* 211 */ -1, /* 212 */ -1, /* 213 */ -1, /* 214 */ -1,
/* 215 */ -1, /* 216 */ -1, /* 217 */ -1, /* 218 */ -1, /* 219 */ 26,
/* 220 */ 43, /* 221 */ 27, /* 222 */ 40
};
public static final int _wArrayByteLength(Object obj) {
@ -3115,5 +2911,104 @@ public class EaglerAdapterImpl2 {
}
return !isLittleEndian;
}
private static EaglercraftLANClient rtcLANClient = null; //TODO
@JSBody(params = { }, script = "return window.startLANClient();")
private static native EaglercraftLANClient startRTCLANClient();
public static final int LAN_CLIENT_INIT_FAILED = -2;
public static final int LAN_CLIENT_FAILED = -1;
public static final int LAN_CLIENT_DISCONNECTED = 0;
public static final int LAN_CLIENT_CONNECTING = 1;
public static final int LAN_CLIENT_CONNECTED = 2;
public static final boolean clientLANSupported() {
return true;
}
public static final void clientLANSetServer(String relay, String peerId) {
}
public static final int clientLANReadyState() {
return 0;
}
public static final void clientLANCloseConnection() {
}
public static final void clientLANSendPacket(byte[] pkt) {
}
public static final byte[] clientLANReadPacket() {
return null;
}
private static EaglercraftLANServer rtcLANServer = null;
@JSBody(params = { }, script = "return window.startLANServer();")
private static native EaglercraftLANServer startRTCLANServer();
public static final boolean serverLANSupported() {
return true;
}
public static final String serverLANInitializeServer(String relay) {
return null;
}
public static final boolean serverLANServerOpen() {
return true;
}
public static final void serverLANCloseServer() {
}
public static interface LANConnectionEvent {
public String getPeerName();
public void accept();
public void reject();
}
public static final LANConnectionEvent serverLANGetConnectionEvent() {
return null;
}
public static final String serverLANGetDisconnectEvent() {
return null;
}
public static class LANPeerPacket {
public final String peer;
public final byte[] packet;
protected LANPeerPacket(String peer, byte[] packet) {
this.peer = peer;
this.packet = packet;
}
}
public static final LANPeerPacket serverLANReadPacket() {
return null;
}
public static final void serverLANWritePacket(String peer, byte[] data) {
}
public static final void serverLANDisconnectPeer(String peer) {
}
}

View File

@ -0,0 +1,61 @@
package net.lax1dude.eaglercraft.adapter.teavm;
import org.teavm.jso.JSFunctor;
import org.teavm.jso.JSObject;
import org.teavm.jso.typedarrays.ArrayBuffer;
public interface EaglercraftLANClient {
final int READYSTATE_INIT_FAILED = -2;
final int READYSTATE_FAILED = -1;
final int READYSTATE_DISCONNECTED = 0;
final int READYSTATE_CONNECTING = 1;
final int READYSTATE_CONNECTED = 2;
boolean LANClientSupported();
void initializeClient();
void setICEServers(String[] urls);
void setICECandidateHandler(ICECandidateHandler callback);
void setDescriptionHandler(DescriptionHandler callback);
void setRemoteDataChannelHandler(ClientSignalHandler cb);
void setRemoteDisconnectHandler(ClientSignalHandler cb);
void setRemotePacketHandler(RemotePacketHandler cb);
int getReadyState();
void sendPacketToServer(ArrayBuffer buffer);
void signalRemoteConnect();
void signalRemoteDescription(String descJSON);
void signalRemoteICECandidate(String candidate);
@JSFunctor
public static interface ICECandidateHandler extends JSObject {
void call(String candidate);
}
@JSFunctor
public static interface DescriptionHandler extends JSObject {
void call(String candidate);
}
@JSFunctor
public static interface ClientSignalHandler extends JSObject {
void call();
}
@JSFunctor
public static interface RemotePacketHandler extends JSObject {
void call(ArrayBuffer buffer);
}
}

View File

@ -0,0 +1,62 @@
package net.lax1dude.eaglercraft.adapter.teavm;
import org.teavm.jso.JSFunctor;
import org.teavm.jso.JSObject;
import org.teavm.jso.typedarrays.ArrayBuffer;
public interface EaglercraftLANServer {
boolean LANServerSupported();
void initializeServer();
void setRecieveCodeHandler(CodeHandler cb);
void setICEServers(String[] urls);
void setICECandidateHandler(ICECandidateHandler cb);
void setDescriptionHandler(DescriptionHandler cb);
void setRemoteClientDataChannelHandler(ClientSignalHandler cb);
void setRemoteClientDisconnectHandler(ClientSignalHandler cb);
void setRemoteClientPacketHandler(PeerPacketHandler cb);
void ssendPacketToRemoteClient(String peerId, ArrayBuffer buffer);
void signalRemoteConnect(String peerId);
void signalRemoteDescription(String peerId, String descJSON);
void signalRemoteICECandidate(String peerId, String candidate);
void disconnectRemotePeer(String peerId);
@JSFunctor
public static interface ICECandidateHandler extends JSObject {
void call(String peerId, String candidate);
}
@JSFunctor
public static interface CodeHandler extends JSObject {
void call(String code);
}
@JSFunctor
public static interface DescriptionHandler extends JSObject {
void call(String peerId, String candidate);
}
@JSFunctor
public static interface ClientSignalHandler extends JSObject {
void call();
}
@JSFunctor
public static interface PeerPacketHandler extends JSObject {
void call(String peerId, ArrayBuffer buffer);
}
}