GithubHelp home page GithubHelp logo

How to test multiplayer about js-minecraft HOT 5 OPEN

labystudio avatar labystudio commented on May 18, 2024
How to test multiplayer

from js-minecraft.

Comments (5)

LabyStudio avatar LabyStudio commented on May 18, 2024

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!

from js-minecraft.

codingwatching avatar codingwatching commented on May 18, 2024

Hi @LabyStudio
Thank you so much!

Here is the error log

image

Zoom in

image

from js-minecraft.

CrazyH2 avatar CrazyH2 commented on May 18, 2024

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

from js-minecraft.

LabyStudio avatar LabyStudio commented on May 18, 2024

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

from js-minecraft.

CrazyH2 avatar CrazyH2 commented on May 18, 2024

@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:

  • Fix confirm to exit when in world code
  • Add world selection menu
  • Fix chat scroll back which is infinite
  • Should add own main menu panorama
  • Improve loading splash screen
  • Make join server loading text message actually update states
  • Add change username and skin in settings
  • Add Alex skin
  • Fix kick msg, tabbar colors codes
  • Fix chat colours
  • Add full credits in settings
  • Add button to right click so its easier on touchpad

from js-minecraft.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.