Open codingwatching opened 2 years ago
Hey, the multiplayer feature is currently an experimental implementation and works over a websocket proxy that only allows my local demo server for testing purposes.
You should be still able to join this demo server, doesn't matter which ip address you enter. Maybe open the devtools network tab and check for any error messages when connecting to the the websocket server.
I'm not at home right now and I tested it on my phone and it works just fine!
Hi @LabyStudio Thank you so much!
Here is the error log
Zoom in
the code that forwards the websocket looks like this (run with: "npm init -y","npm i ws net" and "node proxy.js")
proxy.js:
//Simple local Websocket server for forwarding to //minecraft server import { WebSocketServer } from 'ws'; import * as net from "net"; const wss = new WebSocketServer({ port: 30023 }); wss.on('connection', function connection(ws) { ws.on('message', function message(data) { let a; try { if(ws.client) { ws.client.write(data); return; } a = JSON.parse(data); if(a?.payload?.host && a?.payload?.port ){ ws.client=new net.Socket(); ws.client.connect(a?.payload?.port, a?.payload?.host, function() { }); ws.client.on('data', function(data) { ws.send(data); }); ws.client.on('close', function() { ws.client.destroy(); // kill client after server's response }); } } catch (e) { return console.error(e); // error in the above string (in this case, yes)! } }); });
@kiliansinger How did you get this to work? the client sends json which its not meant to.
@LabyStudio could you please help? i really want to improve this repo a lot I've already improved speeds. Would i be able to get a working Minecraft proxy
the code that forwards the websocket looks like this (run with: "npm init -y","npm i ws net" and "node proxy.js") proxy.js:
//Simple local Websocket server for forwarding to //minecraft server import { WebSocketServer } from 'ws'; import * as net from "net"; const wss = new WebSocketServer({ port: 30023 }); wss.on('connection', function connection(ws) { ws.on('message', function message(data) { let a; try { if(ws.client) { ws.client.write(data); return; } a = JSON.parse(data); if(a?.payload?.host && a?.payload?.port ){ ws.client=new net.Socket(); ws.client.connect(a?.payload?.port, a?.payload?.host, function() { }); ws.client.on('data', function(data) { ws.send(data); }); ws.client.on('close', function() { ws.client.destroy(); // kill client after server's response }); } } catch (e) { return console.error(e); // error in the above string (in this case, yes)! } }); });
@kiliansinger How did you get this to work? the client sends json which its not meant to.
@LabyStudio could you please help? i really want to improve this repo a lot I've already improved speeds. Would i be able to get a working Minecraft proxy
I just published my proxy https://github.com/LabyStudio/mc-websocket-proxy
@LabyStudio
Thanks so much for the websocket proxy! I have done a lot of improvements so I'll probably push then soon but i just have to replace all the textures
Here my change list:
Hi @LabyStudio Thank you so much for this awesome project When I press the demo and enter multiplayer, nothing happens https://labystudio.de/page/minecraft/ Could you please help me how set up and test that function? Thank you!