-
Notifications
You must be signed in to change notification settings - Fork 715
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
allow multiplayer client creation to be overridden #246
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 |
---|---|---|
|
@@ -91,8 +91,14 @@ class _ClientImpl { | |
this.credentials = credentials; | ||
|
||
let server = undefined; | ||
if (multiplayer instanceof Object && 'server' in multiplayer) { | ||
server = multiplayer.server; | ||
let MultiplayerClientImpl = Multiplayer; | ||
if (multiplayer instanceof Object) { | ||
if ('server' in multiplayer) { | ||
server = multiplayer.server; | ||
} | ||
if ('clientImpl' in multiplayer) { | ||
MultiplayerClientImpl = multiplayer.clientImpl; | ||
} | ||
multiplayer = true; | ||
} | ||
|
||
|
@@ -134,7 +140,7 @@ class _ClientImpl { | |
this.store = null; | ||
|
||
if (multiplayer) { | ||
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. Let's just add a new option in the
That way it's a tiny surgical change and the rest of the interface remains unchanged. 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. update as requested Note that this interface does not reflect that serverUrl and socketOpt are parameters for a specific Multiplayer client type |
||
this.multiplayerClient = new Multiplayer({ | ||
this.multiplayerClient = new MultiplayerClientImpl({ | ||
gameID: gameID, | ||
playerID: playerID, | ||
gameName: game.name, | ||
|
@@ -264,7 +270,7 @@ class _ClientImpl { | |
* | ||
* @param {...object} game - The return value of `Game`. | ||
* @param {...object} numPlayers - The number of players. | ||
* @param {...object} multiplayer - Set to true or { server: '<host>:<port>' } | ||
* @param {...object} multiplayer - Set to true or { server: '<host>:<port>', clientImpl?: Multiplayer client class } | ||
* to make a multiplayer client. The second | ||
* syntax specifies a non-default socket server. | ||
* @param {...object} socketOpts - Options to pass to socket.io. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we're missing a unit test that covers this line.