diff options
-rw-r--r-- | src/client/northstar/utils/Utils.ts | 6 | ||||
-rw-r--r-- | src/client/views/webcam/DashWebRTC.ts | 26 | ||||
-rw-r--r-- | src/client/views/webcam/DashWebRTCVideo.tsx | 24 | ||||
-rw-r--r-- | src/server/Message.ts | 2 |
4 files changed, 42 insertions, 16 deletions
diff --git a/src/client/northstar/utils/Utils.ts b/src/client/northstar/utils/Utils.ts index d071dec62..09f83ce80 100644 --- a/src/client/northstar/utils/Utils.ts +++ b/src/client/northstar/utils/Utils.ts @@ -4,6 +4,12 @@ import { IBaseFilterProvider } from '../core/filter/IBaseFilterProvider'; import { AggregateFunction } from '../model/idea/idea'; export class Utils { + static Emit() { + throw new Error("Method not implemented."); + } + static EmitCallback() { + throw new Error("Method not implemented."); + } public static EqualityHelper(a: Object, b: Object): boolean { if (a === b) return true; diff --git a/src/client/views/webcam/DashWebRTC.ts b/src/client/views/webcam/DashWebRTC.ts index bd0bd7f9a..846de4115 100644 --- a/src/client/views/webcam/DashWebRTC.ts +++ b/src/client/views/webcam/DashWebRTC.ts @@ -1,4 +1,7 @@ import { DocServer } from '../../DocServer'; +import { Utils } from '../../../Utils'; +import { MessageStore } from '../../../server/Message'; + /** @@ -30,8 +33,7 @@ export namespace DashWebRTC { offerToReceiveVideo: true }; - export function init() { - let room = 'test'; + export function init(room: string) { if (room !== '') { DocServer._socket.emit('create or join', room); @@ -68,20 +70,21 @@ export namespace DashWebRTC { // This client receives a message DocServer._socket.on('message', function (message: any) { console.log('Client received message:', message); - if (message === 'got user media') { + if (message.message === 'got user media') { maybeStart(); - } else if (message.type === 'offer') { + } else if (message.message.type === 'offer') { + console.log("I have entered here bro!!!"); if (!isInitiator && !isStarted) { maybeStart(); } - pc.setRemoteDescription(new RTCSessionDescription(message)); + pc.setRemoteDescription(new RTCSessionDescription(message.message)); doAnswer(); - } else if (message.type === 'answer' && isStarted) { - pc.setRemoteDescription(new RTCSessionDescription(message)); - } else if (message.type === 'candidate' && isStarted) { + } else if (message.message.type === 'answer' && isStarted) { + pc.setRemoteDescription(new RTCSessionDescription(message.message)); + } else if (message.message.type === 'candidate' && isStarted) { var candidate = new RTCIceCandidate({ - sdpMLineIndex: message.label, - candidate: message.candidate + sdpMLineIndex: message.message.label, + candidate: message.message.candidate }); pc.addIceCandidate(candidate); } else if (message === 'bye' && isStarted) { @@ -120,7 +123,8 @@ export namespace DashWebRTC { function sendMessage(message: any) { console.log('Client sending message: ', message); - DocServer._socket.emit('message', message); + Utils.Emit(DocServer._socket, MessageStore.NotifyRoommates, { message: message, room: "" }); + //DocServer._socket.emit('message', message); } diff --git a/src/client/views/webcam/DashWebRTCVideo.tsx b/src/client/views/webcam/DashWebRTCVideo.tsx index 503b71569..0c4e594e4 100644 --- a/src/client/views/webcam/DashWebRTCVideo.tsx +++ b/src/client/views/webcam/DashWebRTCVideo.tsx @@ -9,6 +9,7 @@ import "../../views/nodes/WebBox.scss"; import "./DashWebRTC.scss"; import adapter from 'webrtc-adapter'; import { DashWebRTC } from "./DashWebRTC"; +import { DocServer } from "../../DocServer"; @@ -37,11 +38,12 @@ export class DashWebRTCVideo extends React.Component<CollectionFreeFormDocumentV private callButton: HTMLButtonElement | undefined; private startButton: HTMLButtonElement | undefined; private hangupButton: HTMLButtonElement | undefined; + private roomText: HTMLInputElement | undefined; - componentDidMount() { - // DashWebRTC.setVideoObjects(this.localVideoEl!, this.peerVideoEl!); - DashWebRTC.init(); - } + // componentDidMount() { + // // DashWebRTC.setVideoObjects(this.localVideoEl!, this.peerVideoEl!); + // //DashWebRTC.init(); + // } // componentDidMount() { @@ -279,6 +281,19 @@ export class DashWebRTCVideo extends React.Component<CollectionFreeFormDocumentV // } + /** + * Function that submits the title entered by user on enter press. + */ + onEnterKeyDown = (e: React.KeyboardEvent) => { + if (e.keyCode === 13) { + let submittedTitle = this.roomText!.value; + this.roomText!.value = ""; + this.roomText!.blur(); + DashWebRTC.init(submittedTitle); + } + } + + @@ -319,6 +334,7 @@ export class DashWebRTCVideo extends React.Component<CollectionFreeFormDocumentV render() { let content = <div className="webcam-cont" style={{ width: "100%", height: "100%" }} onWheel={this.onPostWheel} onPointerDown={this.onPostPointer} onPointerMove={this.onPostPointer} onPointerUp={this.onPostPointer}> + <input type="text" placeholder="Enter room name" ref={(e) => this.roomText = e!} onKeyDown={this.onEnterKeyDown} /> <video id="localVideo" autoPlay playsInline ref={(e) => { this.localVideoEl = e!; DashWebRTC.setLocalVideoObject(e!); diff --git a/src/server/Message.ts b/src/server/Message.ts index 60ffa215f..ed778e889 100644 --- a/src/server/Message.ts +++ b/src/server/Message.ts @@ -63,7 +63,7 @@ export namespace MessageStore { export const YoutubeApiQuery = new Message<YoutubeQueryInput>("Youtube Api Query"); export const DeleteField = new Message<string>("Delete field"); export const DeleteFields = new Message<string[]>("Delete fields"); - export const NotifyRoommates = new Message<RoomMessage>("Notify Roommates"); + export const NotifyRoommates = new Message<RoomMessage>("message"); export const HangUpCall = new Message<string>("bye"); |