Skip to content
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

it would be nice to mention socket.dispatchEvent in docs #309

Open
keremciu opened this issue Oct 25, 2020 · 1 comment
Open

it would be nice to mention socket.dispatchEvent in docs #309

keremciu opened this issue Oct 25, 2020 · 1 comment

Comments

@keremciu
Copy link

I'm using mock-socket in new version of my game. I wanted to add some test coverage.

I have a test case that one user is already created a game then second user can join. Somehow I found some ugly solutions but I I couldn't find any example when I need to broadcast to players who joined the game.

I assumed mockServer.emit could be the solution but I couldn't say specifally, just send message for players who joined the game.

I implemented a solution this way:
https://github.com/keremciu/house-of-decks/blob/ws-implement/client/src/utils/server-mock.js#L32-L42

I asummed people who wants to play with mockServer.clients() would like to see an example, it would be nice to mention there's dispatchEvent to send something to client because my original server code uses client.send to reach same functionality. It can cause conflict for many people.

https://github.com/keremciu/house-of-decks/blob/ws-implement/server/index.js#L62

@dfree
Copy link

dfree commented Apr 18, 2021

@keremciu Thank you so much for these links! Your implementation helped me to understand the whole thing better! And huge shout out to @thoov as well making it even possible! All the best for you fellas! ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants