| Index: components/devtools_bridge/client/js/client_session.js
|
| diff --git a/components/devtools_bridge/client/js/client_session.js b/components/devtools_bridge/client/js/client_session.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1ce99a9edd9aa1ec75ed4aac7eae2c92dc0d0856
|
| --- /dev/null
|
| +++ b/components/devtools_bridge/client/js/client_session.js
|
| @@ -0,0 +1,43 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +/**
|
| + * WebRTC session to the DevTools Bridge Server. Handles a peer connection.
|
| + * Client sends an offer to the server, waits for an answer and then
|
| + * handles ICE candidates exhange process.
|
| + *
|
| + * @Constructor
|
| + */
|
| +function ClientSession(deviceId, gcdClient) {
|
| + this.deviceId_ = deviceId;
|
| + this.connection_ = new webkitRTCPeerConnection(null, null);
|
| + this.gcdClient_ = gcdClient;
|
| + this.id_ = ""; // TODO(serya): generate or pass ID.
|
| +}
|
| +
|
| +ClientSession.prototype.start = function() {
|
| + this.connection_.createOffer(this.onOfferCreated_.bind(this),
|
| + this.onOfferFailed_.bind(this),
|
| + {});
|
| +};
|
| +
|
| +ClientSession.prototype.stop = function() {
|
| + this.connection_.close();
|
| +};
|
| +
|
| +ClientSession.prototype.onOfferCreated_ = function(offer) {
|
| + this.gcdClient_.sendCommand({
|
| + 'deviceId': this.deviceId_,
|
| + 'name': 'base._startSession',
|
| + 'parameters': {
|
| + '_sessionId': this.id_,
|
| + '_config': '{}',
|
| + '_offer': offer.sdp
|
| + }
|
| + });
|
| +};
|
| +
|
| +ClientSession.prototype.onOfferFailed_ = function(error) {
|
| + console.log('Offer failed: ' + error);
|
| +};
|
|
|