Dispatch events when calls are made/received.

This commit is contained in:
Kegan Dougal 2015-07-15 14:06:44 +01:00
parent f94a061fda
commit 78bea916e1
5 changed files with 59 additions and 10 deletions

View file

@ -20,11 +20,12 @@ var React = require('react');
var MatrixClientPeg = require("../../../../src/MatrixClientPeg"); var MatrixClientPeg = require("../../../../src/MatrixClientPeg");
var ComponentBroker = require('../../../../src/ComponentBroker'); var ComponentBroker = require('../../../../src/ComponentBroker');
var VideoViewController = require("../../../../src/controllers/molecules/VideoView");
var VideoFeed = ComponentBroker.get('atoms/VideoFeed'); var VideoFeed = ComponentBroker.get('atoms/VideoFeed');
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'VideoView', displayName: 'VideoView',
mixins: [VideoViewController],
getRemoteVideoElement: function() { getRemoteVideoElement: function() {
return this.refs.remote.getDOMNode(); return this.refs.remote.getDOMNode();
@ -45,5 +46,5 @@ module.exports = React.createClass({
</div> </div>
</div> </div>
); );
}, }
}); });

View file

@ -37,10 +37,6 @@ module.exports = React.createClass({
displayName: 'RoomView', displayName: 'RoomView',
mixins: [RoomViewController], mixins: [RoomViewController],
getVideoView: function() {
return this.refs.video;
},
render: function() { render: function() {
var myUserId = MatrixClientPeg.get().credentials.userId; var myUserId = MatrixClientPeg.get().credentials.userId;
if (this.state.room.currentState.members[myUserId].membership == 'invite') { if (this.state.room.currentState.members[myUserId].membership == 'invite') {
@ -73,7 +69,7 @@ module.exports = React.createClass({
<div className="mx_RoomView"> <div className="mx_RoomView">
<RoomHeader room={this.state.room} /> <RoomHeader room={this.state.room} />
<div className="mx_RoomView_auxPanel"> <div className="mx_RoomView_auxPanel">
<VideoView ref="video" /> <VideoView/>
</div> </div>
<div ref="messageWrapper" className="mx_RoomView_messagePanel" onScroll={this.onMessageListScroll}> <div ref="messageWrapper" className="mx_RoomView_messagePanel" onScroll={this.onMessageListScroll}>
<div className="mx_RoomView_messageListWrapper"> <div className="mx_RoomView_messageListWrapper">

View file

@ -16,14 +16,22 @@ limitations under the License.
'use strict'; 'use strict';
var MatrixClientPeg = require("../../MatrixClientPeg"); var dis = require("../../dispatcher");
module.exports = { module.exports = {
onVideoClick: function() { onVideoClick: function() {
console.log("video clicked"); dis.dispatch({
action: 'place_call',
type: "video",
room_id: this.props.room.roomId
});
}, },
onVoiceClick: function() { onVoiceClick: function() {
console.log("voice clicked"); dis.dispatch({
action: 'place_call',
type: "voice",
room_id: this.props.room.roomId
});
} }
}; };

View file

@ -0,0 +1,38 @@
/*
Copyright 2015 OpenMarket Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
'use strict';
var dis = require("../../dispatcher");
module.exports = {
componentDidMount: function() {
this.dispatcherRef = dis.register(this.onAction);
},
onAction: function(payload) {
switch(payload.action) {
case 'place_call':
console.log("Place %s call in %s", payload.type, payload.room_id);
break;
case 'incoming_call':
console.log("Incoming call: %s", payload.call);
break;
}
}
};

View file

@ -116,6 +116,12 @@ module.exports = {
that.setState({ready: true, currentRoom: firstRoom}); that.setState({ready: true, currentRoom: firstRoom});
dis.dispatch({action: 'focus_composer'}); dis.dispatch({action: 'focus_composer'});
}); });
cli.on('Call.incoming', function(call) {
dis.dispatch({
action: 'incoming_call',
call: call
});
});
Notifier.start(); Notifier.start();
cli.startClient(); cli.startClient();
}, },