-
Notifications
You must be signed in to change notification settings - Fork 2
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
Issue 22: WebRTC implementation #27
Conversation
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 good. As you know, we have to change some parts when we integrate codes.
@@ -1,7 +1,10 @@ | |||
const Game = require("./models/Game"); | |||
const { use } = require("chai"); |
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.
what is "chai" module?
|
||
sockets.on("game-started", () => { | ||
setGame((game) => ({ ...game, isStarted: true })); | ||
}); | ||
|
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.
These game-start parts will be modified when integrating with game-integration branch. After integrating between RTC and game, you need to check it.
#22
Note: NOT fully implemented yet, just added all socket and signalling handlers
If anyone could look through this PR and see what can be changed, I'd like some help with that.
Additions
RTCContext.js - provider wrapped around GameSession protected route
/server/sockets.js - added socket events for p2p signalling
Implementation is similar to https://github.com/darrenMabbayad/webrtc-simple-video-call
Utilizes simple-peer package to abstract parts of signalling process/ICE
Front End
peers
- state variable which is a list of created peers to renderpeersRef
- ref variable which is used to filter through socket ids and accept call signalsuserMediaRef
- ref variable where the stream object is set to.current.srcObject
property of userMediaRefgetMediaStream()
- generic async function that returns stream object under certain contraintsinitCall()
- creates peer objects for the player initiating a call, signals to back end 'starting-call'answerCall()
- creates peer objects for players receiving a call, signals to back end 'answering-call', accepts the initiated calluseEffect
socket event handler - handles get-player-socket-ids (which invokesinitCall()
), receiving-call (which invokesanswerCall()
), and accept-call-back (which looks through peersRef to accept returning offers) socket eventsBack End
starting-call - send an offer to a specific player
answering-call send an offer back to the caller