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

Issue 22: WebRTC implementation #27

Merged
merged 5 commits into from
Jul 21, 2020
Merged

Conversation

darrenMabbayad
Copy link
Collaborator

#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 render
peersRef - ref variable which is used to filter through socket ids and accept call signals
userMediaRef - ref variable where the stream object is set to .current.srcObject property of userMediaRef

getMediaStream() - generic async function that returns stream object under certain contraints
initCall() - 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 call
useEffect socket event handler - handles get-player-socket-ids (which invokes initCall()), receiving-call (which invokes answerCall()), and accept-call-back (which looks through peersRef to accept returning offers) socket events

Back End

starting-call - send an offer to a specific player
answering-call send an offer back to the caller

@InsafKhamzin InsafKhamzin marked this pull request as ready for review July 17, 2020 14:31
@InsafKhamzin InsafKhamzin self-assigned this Jul 17, 2020
Copy link
Collaborator

@Hyunse Hyunse left a 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");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is "chai" module?

Comment on lines +38 to +42

sockets.on("game-started", () => {
setGame((game) => ({ ...game, isStarted: true }));
});

Copy link
Collaborator

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.

@InsafKhamzin InsafKhamzin merged commit 8b2bd06 into dev Jul 21, 2020
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

Successfully merging this pull request may close these issues.

3 participants