Members

(constant) cors

Module for cross-origin resource sharing; needed so that the protocol default CORS policy can be overridden.

currentPeer :Object

Reference to the most recently connected peer.

Type:
  • Object

(constant) express

Express module for starting route-based apps.

(constant) ExpressPeerServer

Module for peer.js that allows for express app support for peer-to-peer connections.

(constant) Gesture :Object

Enum for the different types of gestures Spark recognizes.

Type:
  • Object

gesturesEnabled :boolean

Boolean for toggling whether or not gestures are enabled. Default disabled.

Type:
  • boolean

isBreakout :boolean

Boolean for toggling whether or not the user is in a breakout room. Default false.

Type:
  • boolean

(constant) myVideo

Reference to the created (local) video object

myVideoStream :Object

Reference to the local video stream for the client.

Type:
  • Object

participantBreakOutRoomMap :Object

Variable to keep track of breakout rooms for determining where to place participants.

Type:
  • Object

(constant) peers

Container for all connected peers in the room.

(constant) RateLimit

Module for enforcing rate limit on an express app

roomHostsMap :Object

Variable to keep track of room hosts for determining host-only actions

Type:
  • Object

roomParticipantsMap :Object

Variable to keep track of room participants for determining host-only actions

Type:
  • Object

screenSharing :boolean

Boolean for determining if a screen is being shared or not.

Type:
  • boolean

screenStream :Object

Reference object of the screen sharing video stream.

Type:
  • Object

(constant) videoGrid

The grid of local and remote video objects representing the video of all peers.

Methods

addVideoStream(video, stream)

Adds a new video to the client's video grid, and forcing the stream of the video to play.

Parameters:
NameTypeDescription
videoObject
streamObject

breakoutUnbreakout()

Toggles the brekoutRoom and exitBreakoutRoom for the user, along with setting the Breakout Rooms and Exit Breakout button by calling their defined functions.

connectToNewUser(userId, stream)

Uses peer.js to add a new peer, along with setting up the listeners for "this" client.

Parameters:
NameTypeDescription
userIdstring

User (socket) ID of the new user

streamObject

Video stream to add to "this" client's video grid

detect_fingersup(lmlist) → {Array}

Determines how many fingers are pointing "up", using arrays to store the result.

Parameters:
NameTypeDescription
lmlistArray
Returns:

The fingers IDs that are found as "up"

Type: 
Array

findhandpos(landmarks) → {Array}

Helper function to determine the x-y coordinates of the positions of the hand

Parameters:
NameTypeDescription
landmarksObject
Returns:

x-y coordinates of the hand data

Type: 
Array

muteUnmute()

Toggles the mute and unmute of the video stream, along with setting the mute and unmute button by calling their defined functions.

onGestureAction(results)

Callback for the Hands onResults event to see what gestures came out of that and how to map those gestures to certain room controls.

Parameters:
NameTypeDescription
resultsObject

The hand detection results

onResults(results) → {Object}

Determines what gesture is being shown based on the given hand detection data.

Parameters:
NameTypeDescription
resultsObject

Hand detection data

Returns:

The gesture enum that was determined

Type: 
Object

peerServer(peerAppopt)

The HTTP server module used for starting Spark's server to listen for new peers and their activity; uses createServer to set up the peer.js functionality.

Parameters:
NameTypeAttributesDescription
peerAppObject<optional>

Reference to instantiated peer.js express app that server module can interface on

Listens to Events:

playStop()

Toggles the show and hide of the video stream, along with setting the show and hide video buttons by calling their defined functions. It does this by using the myVideo pause() and play() functions from HTMLVideoElement to manipulate video state.

scrollToBottom()

Scrolls to the bottom of the chat container HTML element to show the latest chat message.

setDisableGestures()

Utilizes DOM manipulation to display the disable gesture button on the gesture enable/disable button container.

setEnableGestures()

Utilizes DOM manipulation to display the enable gesture button on the gesture enable/disable button container.

setExitBreakoutRoom()

Utilizes DOM manipulation to display the ExitBreakout button on the breakoutRoom/exitBreakout button container.

setMuteButton()

Utilizes DOM manipulation to display the mute button on the mute/unmute button container.

setPlayVideo()

Utilizes DOM manipulation to display the show video button on the video show/stop button container.

setStopVideo()

Utilizes DOM manipulation to display the stop video button on the video show/stop button container.

setUnmuteButton()

Utilizes DOM manipulation to display the unmute button on the mute/unmute button container.

startScreenShare()

Changes your video to point to point to your screen sharing video that's prompted. If permitted, it will change your video stream to the screen sharing stream you are doing for all peers that are connected to you. If stopping screen share, see stopScreenSharing function.

stopScreenSharing()

Replaces the video stream of the screen sharing to be video stream of the user who stopped the screen sharing.

toggleChat()

Utilizes DOM manipulation to toggle the chat section of the room.

toggleGesture()

Toggles the detection of gestures in the video stream, along with setting the enable and disable buttons by calling their defined functions.

.onchange(event)

Sends the 'filetransfer' signal to the server along with the byte data of the file that was chosen to be submitted by the user.

Parameters:
NameTypeDescription
eventObject

The event object that holds the file data to transfer