Skip to content

Commit

Permalink
stub out RTCDataChannel attributes and methods fixes nickdesaulniers#9
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Weathersby committed Dec 22, 2015
1 parent 526cd2c commit 4343897
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions lib/RTCDataChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ var util = require('util');
// https://w3c.github.io/webrtc-pc/#rtcdatachannel

function RTCDataChannel() {
EventTarget.call(this);
EventTarget.call(this);

// https://w3c.github.io/webrtc-pc/#idl-def-RTCDataChannel
this.label = null;
// https://w3c.github.io/webrtc-pc/#idl-def-RTCDataChannel
this.label = null;
this.negotiated = false;
this.protocol = '';
this.maxPacketLifeTime = null;
Expand Down Expand Up @@ -34,26 +34,26 @@ RTCDataChannel.prototype.send = function(data) {
//TODO:Step 1 implies this?
//Step 2
if (this.readyState === 'connecting') {
throw new Error('InvalidStateError');
throw new Error('InvalidStateError');
}
//TODO:Does this work in all browsers and node?
//Step 3
if (typeof data === "string" || data instanceof String) {
//TODO:increment this.bufferedAmount by length of string in UTF-8
//TODO: send String
//TODO:increment this.bufferedAmount by length of string in UTF-8
//TODO: send String
} else if (data instanceof Blob) {
this.bufferedAmount += data.size;
//TODO: send Blob
this.bufferedAmount += data.size;
//TODO: send Blob
} else if (data instanceof ArrayBuffer) {
this.bufferedAmount += data.byteLength;
//TODO:Does isView work in all browsers and node?
if (ArrayBuffer.isView(data)) {
this.bufferedAmount += data.byteLength;
//TODO:Does isView work in all browsers and node?
if (ArrayBuffer.isView(data)) {
//TODO: send ArrayBufferView
} else {
//TODO: send ArrayBuffer
}
} else {
//TODO: send ArrayBuffer
}
} else {
//TODO: need to handle bad datatype
//TODO: need to handle bad datatype
}
//TODO:Step 4
//TODO:Step 5
Expand All @@ -64,7 +64,7 @@ RTCDataChannel.prototype.close = function() {
//TODO: Is 'this' not the RTCDataChannel Step 1
//Step 2
if (this.readyState === 'closing' || this.readyState === 'closed') {
return;
return;
}
//Step 3
this.readyState = 'closing';
Expand Down

0 comments on commit 4343897

Please sign in to comment.