Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: components/devtools_bridge/client/js/client_session.js

Issue 746663002: Stub for WebRTCDeviceProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webclient
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * WebRTC session to the DevTools Bridge Server. Handles a peer connection.
7 * Client sends an offer to the server, waits for an answer and then
8 * handles ICE candidates exhange process.
9 *
10 * @Constructor
11 */
12 function ClientSession(deviceId, gcdClient) {
13 this.deviceId_ = deviceId;
14 this.connection_ = new webkitRTCPeerConnection(null, null);
15 this.gcdClient_ = gcdClient;
16 this.id_ = ""; // TODO(serya): generate or pass ID.
17 }
18
19 ClientSession.prototype.start = function() {
20 this.connection_.createOffer(this.onOfferCreated_.bind(this),
21 this.onOfferFailed_.bind(this),
22 {});
23 };
24
25 ClientSession.prototype.stop = function() {
26 this.connection_.close();
27 };
28
29 ClientSession.prototype.onOfferCreated_ = function(offer) {
30 this.gcdClient_.sendCommand({
31 'deviceId': this.deviceId_,
32 'name': 'base._startSession',
33 'parameters': {
34 '_sessionId': this.id_,
35 '_config': '{}',
36 '_offer': offer.sdp
37 }
38 });
39 };
40
41 ClientSession.prototype.onOfferFailed_ = function(error) {
42 console.log('Offer failed: ' + error);
43 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698