3 * @author Jordan Lavatai and Ken Grimes
9 const dlog
= (msg
) => console
.log(msg
)
11 /***********************/
12 /** Helper functions **/
13 /***********************/
15 /* SDP Interop helper functions to be used by beginRTCOffer and beginRTCAnswer */
17 /** @func Determines the multimedia signaling protocol for the given session description
18 * @desc Does some basic duck typing to determine the type of Session Description
19 * @arg {Object} Session Description Object
20 * @return {String} Returns 'planB' if Session Description is planB, 'Unified' if
21 * Session Description is Unified
23 function determineSessionDescription(sessionDescription
) {
26 /** @func Converts a planB session description to Unified session description
27 * @arg {Object} Session Description Object
28 * @return {Object} PlanB Session Description
30 function toUnified(sessionDescription
) {
33 /** @func Converts a Unified session description to planB session description
34 * @arg {Object} Session Description Object
35 * @return {Object} PlanB Session Description
37 function toPlanB(sessionDescription
) {
40 /* WebSocket wielder helper functions */
42 /* Function for setting up webSocket wielders message handler */
46 /* SDP Negotiation helper functions */
48 /* addRemoteIceCandidate() */
49 /* addIceCandidateCreationHandler(callback for sending?) */
50 /* handleIceRequest() - WebSpocketless entity specific */
53 /***********************/
54 /** Exposed functions **/
55 /***********************/
57 /** @func Attempts to create a websocket
58 * @desc If user agent supports web sockets, attempt to create a websocket
60 * @arg {String} domain - ip address or domain name of other end of websocket
61 * @return {Boolean} returns true if successful, false if unsucessful
63 export function createWebSocket(domain
) {
67 /** @func Returns public key for the user
68 * @desc Attempts to find a stored key. If unsucessful, ask user for key. If user
69 * doesn't have a key, generates a key
70 * @dependencies keyManager, fileSystem
72 * @return {Object} cryptoKey object
74 export function resolveKey() {
78 /** @func Begins the SDP handshake process as the offerer
83 export function beginRTCOffer() {
86 /** @func Begins the SDP handshake process as the answerer
91 export function beginRTCAnswer() {
95 /** @func Generic way to message host from client
97 * @arg {Object} data object to be sent
99 export function sendHostData(data
) {
102 /** @func Generic way to message client from host
104 * @arg {Object} data object to be sent
106 export function sendClientData(data
){