Navigation

    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Users
    1. Home
    2. premdasvm
    • Continue chat with premdasvm
    • Start new chat with premdasvm
    • Flag Profile
    • block_user
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    premdasvm

    @premdasvm

    0
    Reputation
    1
    Posts
    32
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    premdasvm Follow

    Posts made by premdasvm

    • RE: How to access the current room in Redux?

      what i did was create a new Helper class file (Javascript Class), then added all the Colyseus functionalities and listeners and everything there. so I can store the room in a variable there like this.room which can be accessed from any other component on my whole application.

      class ActivityRoom {
          constructor() {
              this.client = new Colyseus.Client(clientUrl);
          }
      
          connect = async (username, rating, photoUrl) => {
              this.name = username;
              this.rating = rating;
              this.photoUrl = photoUrl;
              try {
                  const room = await this.client.joinById('AR1', {
                      username,
                      rating,
                      photoUrl
                  });
                  this.room = room;
                  this.sessionId = room.sessionId;
                  this.Room_Listeners();
              } catch (error) {}
              console.error(error);
          }
      };
      
      leaveRoom() {
          this.room.leave();
      }
      }
      

      then call the leaveRoom like ActivityRoom.leaveRoom from any other Component i want.

      posted in Questions & Help
      premdasvm