Repository navigation
Add sort and limit support to listing lobbies #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,14 +48,17 @@ export default class Network extends EventEmitter<NetworkListeners> { | |
| } | ||
| } | ||
|
|
||
| async list (filter?: object): Promise<LobbyListEntry[]> { | ||
| async list (filter?: object, sort?: object, limit?: number): Promise<LobbyListEntry[]> { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be nice to have better typings here? Enums or something
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not possible, you can filter and sort on any of the fields in the random JSON object that you can store with a lobby.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. e.g. sort |
||
| if (this._closing || this.signaling.receivedID === undefined) { | ||
| return [] | ||
| } | ||
| const filterString = (filter != null) ? JSON.stringify(filter) : undefined | ||
| const sortString = (sort != null) ? JSON.stringify(sort) : undefined | ||
| const reply = await this.signaling.request({ | ||
| type: 'list', | ||
| filter: filterString | ||
| filter: filterString, | ||
| sort: sortString, | ||
| limit | ||
| }) | ||
| if (reply.type === 'lobbies') { | ||
| return reply.lobbies | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.