question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: Public Room API

See original GitHub issue

I’d like to discuss the API for listing and exposing rooms for the client-side.

Scenario

The user would like to manually select a room he’d like to join, based on the currently available list of rooms.

Current state of the framework:

  • The server will select a room automatically for the user (via requestJoin()). The user can’t manually select between 3 available rooms, for example.
  • The user can join a room by its id. But the framework doesn’t provide a built-in way to list room ids.

Proposal

Allowing to set metadata in the rooms (server-side), and querying available rooms on the client-side.

Public Room Stats

The room stats is a limited information about the spawned room. At first, I think these are the most important information to be public.

  • id (the id of the room)
  • clients (number of clients connected)
  • maxClients (maximum number of clients allowed in that room instance)
  • metadata (custom data, manually set for each room instance)

Setting the Room’s metadata:

// BattleRoom.ts
//...
  onInit (options) {
    this.setMetadata({
      image: "something.png"
    });
  }
//...

Requesting Room’s Stats

In the client-side, the developer could make a request to receive all available (unlocked) room’s stats via:

const client = new Colyseus.Client("ws://...");

client.getAvailableRooms("battle", (rooms, err) => {
  if (err) throw new Error(err);
  rooms.forEach((room) => {
    room.id // => "rye7lcbyFf"
    room.clients // => 1
    room.maxClients // => 10
    room.meta // => { "image": "something.png" }
  });
});

Considerations:

  • The number of available rooms may be too long. It may be necessary to consider a search API for rooms based on some criteria (number of clients, metadata values, etc)
  • The room id requested may not exist anymore when the user finally tries to connect to it.
  • Real-time updates regarding room’s stats aren’t available this way.

Feedback

Sorry for the long post, if you’ve made it until here, your feedback is very welcome! 🚀 🚀 /cc @msholty-fd @JoaoMosmann @gregmax17 @takaaptech @AnubisCode

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
endelcommented, Mar 30, 2018
1reaction
oyedcommented, Mar 9, 2018

@talothman This is definitely something you should do yourself, Colyseus is per-server and as such per-region, you should build your own API (Or hardcode server options in your client, though API is a better option) that will return all of the available servers (A.K.A. Regions/Colyseus Instances) that the client can connect to. After that, it is simply just connecting and using the Rooms API.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Client-Server API - Matrix.org
Another example: a public room list has rooms R1 -> R17. The client is showing 5 rooms at a time on screen, and...
Read more >
Matrix / Synapse: send image via client server API
I would like to send messages using the client-server API to a specific matrix room. I use an access token and a room...
Read more >
What is an API: Definition, Types, Specifications, Documentation
The software that needs to access information (i.e., X hotel room rates for ... Open public APIs, as the Open API Definition suggests, ......
Read more >
OGC Members propose update to work of Features API ...
The Open Geospatial Consortium (OGC) seeks public comment on the proposed updated charter for the Features API Standards Working Group (SWG) ...
Read more >
Matrix Widget API v2 (RFC) - Google Docs
State: PROPOSED. Matrix.org Widgets (RFC). Document Status. An Introduction To Widgets. What is a widget? How do I make one? Room-based widgets.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found