Explorar el Código

Enable WebSocket to accept sub-protocols

CHEN Xian-an hace 8 años
padre
commit
bbbaf8400f
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      src/websocket.js

+ 2 - 1
src/websocket.js Ver fichero

@@ -2,6 +2,7 @@ JSMpeg.Source.WebSocket = (function(){ "use strict";
2 2
 
3 3
 var WSSource = function(url, options) {
4 4
 	this.url = url;
5
+	this.options = options;
5 6
 	this.socket = null;	
6 7
 
7 8
 	this.callbacks = {connect: [], data: []};
@@ -34,7 +35,7 @@ WSSource.prototype.start = function() {
34 35
 	this.progress = 0;
35 36
 	this.established = false;
36 37
 
37
-	this.socket = new WebSocket(this.url);
38
+	this.socket = new WebSocket(this.url, this.options.protocols || '');
38 39
 	this.socket.binaryType = 'arraybuffer';
39 40
 	this.socket.onmessage = this.onMessage.bind(this);
40 41
 	this.socket.onopen = this.onOpen.bind(this);