Members
# configuration
stun and turn servers used for the peer to peer connection credentials for turn server are provided by xirsys. stun servers used are provided by google.
# constant io
imported socket.io for real time communication it creates a bidirectional channel between Socket.io client and server
# constant socket
imported socket.io for real time communication
Methods
# addVideoStream(video, stream)
function addVideoStream adds the video element to the video-grid videoGrid is the div container used to hold the video stream
Parameters:
Name | Type | Description |
---|---|---|
video |
media | video of the user accessed from the device |
stream |
object | MediaStream object |
# chatWindow()
hides and show the main chat Window as user toggles the hide and display button
# connectToNewUser(stream, userId)
called when 'user-connected' event is emitted this function is used to call the new user that connected by sending the stream of the user who is calling. This function also strores the call object in peers array
Parameters:
Name | Type | Description |
---|---|---|
stream |
object | we send our own audio and video stream to connect |
userId |
string | id of the user we want to connect to |
# copy()
copies the ROOM_ID to share with different users to join a room
# getUserName()
function takes the username input through prompt and sets the user variable to obtained username function uses bootbox library to generate prompt
# muteUnmute()
toggles the mute and unmute button if audio is true the mutes it else unmutes it
# playStop()
to stop and play Video as user clicks to stop Video or play Video
# scrollToBottom()
scrolls to bottom as chat window gets filled
Type Definitions
# Peer
created a Peer type object for peer to peer communication I hosted my own peerjs server on heroku for the purpose
Properties:
Name | Type | Description |
---|---|---|
host |
string | "dbpeerjsserver.herokuapp.com", my own peerjs server |
port |
number | 443 for https requests |
secure |
boolean | it's a secure port |
config |
object | iceServers (stun and turns servers) |