GitHub | Documentation | Discord (chat) | Become a Patron

React-native & Colyseus.js : Issue with room.join



  • Hello guys,

    I'm running an issue with RN 0.59.5 after doing a room.join, when I dismiss the error, the server got my player join, but room.OnJoin is never called :

    0_1556529489234_Screenshot_1556529479.png

    Here's my code:

    export default class GameScreen extends Component {
      room: any;
      client: any;
    
      componentDidMount() {
        this.client = new Colyseus.Client("ws://192.168.1.13:4000", {});
        this.onConnection();
      }
    
      onConnection() {
        this.client.onOpen.add(() => {
          console.log("client connected");
          try {
            this.room = this.client.join("solo");
            this.room.onJoin.add(() => {
              console.log("client joined successfully");
            });
          } catch (err) {
            console.log("test", err);
          }
        });
      } 
    } 
    

    In App.ts:

    import React, {Component} from "react";
    import HomeNavigation from "./src/navigation/home";
    import AsyncStorage from "@react-native-community/async-storage";
    import {Buffer} from "buffer";
    global.Buffer = Buffer;
    window = Object.assign(window, {localStorage: AsyncStorage});
    
    interface Props {}
    
    export default class App extends Component<Props> {
      render() {
        return <HomeNavigation />;
      }
    }
    

    Many thanks!


  • administrator

    Hey @Meabo, please try removing your node_modules + package-json.lock, and re-installing the modules. I'm afraid this is happening because of an update we've made on latest @colyseus/schema version. Let me know if it works for you! Cheers



  • Hello @endel thanks for your answer,
    So I deleted node_modules and package-lock.json, reinstalled colyseus.js at its latest version but the error's still there.

    But I got something interesting:
    It works with @colyseus/schema 0.4.23 instead of 0.4.29. so I downgraded Schema until I find a solution :)