peer-data
Advanced tools
Comparing version 1.1.9 to 1.1.10
@@ -31,3 +31,3 @@ // Generated by dts-bundle v0.7.2 | ||
caller: Caller; | ||
event: MessageEvent | Event | DOMException; | ||
data: any; | ||
} | ||
@@ -34,0 +34,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("socket.io-client")):"function"==typeof define&&define.amd?define(["exports","socket.io-client"],n):n(e["peer-data"]=e["peer-data"]||{},e.io)}(this,function(e,n){"use strict";var t={},r=function(){function e(){}return e.register=function(e,n){t[e]||(t[e]=[]),t[e].push(n)},e.dispatch=function(e,n){t[e].forEach(function(e){return e(n)})},e}(),o=function(){function e(){}return e}();o.CONNECT="CONNECT",o.DISCONNECT="DISCONNECT",o.CANDIDATE="CANDIDATE",o.OFFER="OFFER",o.ANSWER="ANSWER",o.ERROR="ERROR";var i=function(){function e(e,n){void 0===e&&(e={}),void 0===n&&(n=null),this._servers={},this._dataConstraints=null,this._peers={},this._channels={},this._servers=e,this._dataConstraints=n}return Object.defineProperty(e.prototype,"peers",{get:function(){return this._peers},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"channels",{get:function(){return this._channels},enumerable:!0,configurable:!0}),e.prototype.addPeer=function(e,n){return this._peers.hasOwnProperty(e)||(this._peers[e]=n),this},e.prototype.removePeer=function(e){return this._peers.hasOwnProperty(e)&&(this._peers[e].close(),delete this._peers[e],delete this._peers[e]),this},e.prototype.addChannel=function(e,n){return this._channels.hasOwnProperty(e)||(this._channels[e]=n),this},e.prototype.removeChannel=function(e){return this._channels.hasOwnProperty(e)&&(this._channels[e].close(),delete this._channels[e]),this},Object.defineProperty(e.prototype,"servers",{get:function(){return this._servers},set:function(e){this._servers=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataConstraints",{get:function(){return this._dataConstraints},set:function(e){this._dataConstraints=e},enumerable:!0,configurable:!0}),e}(),s=function(){function e(){}return e}();s.LOG="LOG",s.OPEN="OPEN",s.CLOSE="CLOSE",s.ERROR="ERROR",s.DATA="DATA";var c=function(){function e(){}return e.get=function(e,n){var t=new RTCPeerConnection(e);return t.onicecandidate=function(e){if(e.candidate){var t={type:o.CANDIDATE,caller:null,callee:n.caller,room:n.room,data:e.candidate};r.dispatch("send",t)}},t},e}(),a=function(){function e(){}return e.get=function(e,n){var t=Math.floor(1e16*(1+Math.random())).toString(16).substring(1);return e.createDataChannel(t,n)},e.subscribeToEvents=function(e,n,t){return e.onmessage=function(e){var n={caller:t.caller,room:t.room,event:e};r.dispatch(s.DATA,n)},e.onopen=function(e){var n={caller:t.caller,room:t.room,event:e};r.dispatch(s.OPEN,n)},e.onclose=function(e){var o={caller:t.caller,room:t.room,event:e};r.dispatch(s.CLOSE,o),delete n[t.caller.id]},e.onerror=function(e){var n={caller:t.caller,room:t.room,event:e};r.dispatch(s.ERROR,n)},e},e}(),l=function(){function e(e){this._peers={},this._channels={},this._connection=e,this._peers=this._connection.peers,this._channels=this._connection.channels,r.register(o.CONNECT,this.onConnect.bind(this)),r.register(o.DISCONNECT,this.onDisconnect.bind(this)),r.register(o.OFFER,this.onOffer.bind(this)),r.register(o.ANSWER,this.onAnswer.bind(this)),r.register(o.CANDIDATE,this.onCandidate.bind(this))}return Object.defineProperty(e.prototype,"connection",{get:function(){return this._connection},set:function(e){this._connection=e},enumerable:!0,configurable:!0}),e.prototype.onConnect=function(e){var n=this,t=this._peers[e.caller.id]=c.get(this._connection.servers,e),r=a.get(t,this._connection.dataConstraints);this._channels[e.caller.id]=a.subscribeToEvents(r,this._channels,e),this._peers[e.caller.id]=t,t.createOffer(function(r){var i={type:o.OFFER,caller:null,callee:e.caller,room:e.room,data:r};t.setLocalDescription(r,function(){return n.dispatchEvent(i)},function(t){return n.dispatchError(e,t)})},function(t){return n.dispatchError(e,t)})},e.prototype.onDisconnect=function(e){var n=this._channels[e.caller.id],t=this._peers[e.caller.id];n.close(),t.close(),delete this._channels[e.caller.id],delete this._peers[e.caller.id]},e.prototype.onOffer=function(e){var n=this,t=c.get(this._connection.servers,e);this._peers[e.caller.id]=t,t.ondatachannel=function(t){var r=a.subscribeToEvents(t.channel,n._channels,e);n._connection.addChannel(e.caller.id,r)},t.setRemoteDescription(new RTCSessionDescription(e.data),function(){},function(t){return n.dispatchError(e,t)}),t.createAnswer(function(r){var i={type:o.ANSWER,caller:null,callee:e.caller,room:e.room,data:r};t.setLocalDescription(r,function(){return n.dispatchEvent(i)},function(t){return n.dispatchError(e,t)})},function(t){return n.dispatchError(e,t)})},e.prototype.onAnswer=function(e){var n=this;this._peers[e.caller.id].setRemoteDescription(new RTCSessionDescription(e.data),function(){},function(t){return n.dispatchError(e,t)})},e.prototype.onCandidate=function(e){var n=this,t=this._peers[e.caller.id],r=new RTCIceCandidate(e.data);t.addIceCandidate(r).then(function(){},function(t){return n.dispatchError(e,t)})},e.prototype.dispatchEvent=function(e){r.dispatch("send",e)},e.prototype.dispatchError=function(e,n){var t={caller:e.caller,room:e.room,event:n};r.dispatch(s.ERROR,t)},e}(),h=function(){function e(e,n){void 0===e&&(e={}),void 0===n&&(n=null);var t=new i(e,n);this.bridge=new l(t)}return e.prototype.on=function(e,n){r.register(e,n)},e.prototype.send=function(e,n){if(n){var t=this.bridge.connection.channels[n];t&&"open"===t.readyState&&t.send(e)}else Object.entries(this.bridge.connection.channels).forEach(function(n){var t=(n[0],n[1]);"open"===t.readyState&&t.send(e)})},e.prototype.connect=function(e){var n={type:o.CONNECT,caller:null,callee:null,room:{id:e},data:null};r.dispatch("send",n)},e.prototype.disconnect=function(e){Object.entries(this.bridge.connection.channels).forEach(function(e){e[0];return e[1].close()}),Object.entries(this.bridge.connection.peers).forEach(function(e){e[0];return e[1].close()});var n={type:o.DISCONNECT,caller:null,callee:null,room:{id:e},data:null};r.dispatch("send",n)},e.prototype.peers=function(e){return e?this.bridge.connection.peers[e]:this.bridge.connection.peers},e.prototype.channels=function(e){return e?this.bridge.connection.channels[e]:this.bridge.connection.channels},e}(),u=function(){function e(e){this.socket=n.connect(e),this.subscribeEvents()}return e.prototype.onSend=function(e){this.socket.emit("message",e)},e.prototype.subscribeEvents=function(){this.socket.on("message",this.onMessage.bind(this)),this.socket.on("ipaddr",this.onIp.bind(this)),this.socket.on("log",this.onLog.bind(this)),r.register("send",this.onSend.bind(this))},e.prototype.onIp=function(e){r.dispatch(s.LOG,"Server IP address is: "+e)},e.prototype.onLog=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];r.dispatch(s.LOG,e)},e.prototype.onMessage=function(e){r.dispatch(e.type,e)},e}();e.default=h,e.EventDispatcher=r,e.ConnectionEventType=o,e.DataEventType=s,e.SocketChannel=u,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("socket.io-client")):"function"==typeof define&&define.amd?define(["exports","socket.io-client"],n):n(e["peer-data"]=e["peer-data"]||{},e.io)}(this,function(e,n){"use strict";var t={},r=function(){function e(){}return e.register=function(e,n){t[e]||(t[e]=[]),t[e].push(n)},e.dispatch=function(e,n){t[e].forEach(function(e){return e(n)})},e}(),o=function(){function e(){}return e}();o.CONNECT="CONNECT",o.DISCONNECT="DISCONNECT",o.CANDIDATE="CANDIDATE",o.OFFER="OFFER",o.ANSWER="ANSWER",o.ERROR="ERROR";var i=function(){function e(e,n){void 0===e&&(e={}),void 0===n&&(n=null),this._servers={},this._dataConstraints=null,this._peers={},this._channels={},this._servers=e,this._dataConstraints=n}return Object.defineProperty(e.prototype,"peers",{get:function(){return this._peers},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"channels",{get:function(){return this._channels},enumerable:!0,configurable:!0}),e.prototype.addPeer=function(e,n){return this._peers.hasOwnProperty(e)||(this._peers[e]=n),this},e.prototype.removePeer=function(e){return this._peers.hasOwnProperty(e)&&(this._peers[e].close(),delete this._peers[e],delete this._peers[e]),this},e.prototype.addChannel=function(e,n){return this._channels.hasOwnProperty(e)||(this._channels[e]=n),this},e.prototype.removeChannel=function(e){return this._channels.hasOwnProperty(e)&&(this._channels[e].close(),delete this._channels[e]),this},Object.defineProperty(e.prototype,"servers",{get:function(){return this._servers},set:function(e){this._servers=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataConstraints",{get:function(){return this._dataConstraints},set:function(e){this._dataConstraints=e},enumerable:!0,configurable:!0}),e}(),s=function(){function e(){}return e}();s.LOG="LOG",s.OPEN="OPEN",s.CLOSE="CLOSE",s.ERROR="ERROR",s.DATA="DATA";var c=function(){function e(){}return e.get=function(e,n){var t=new RTCPeerConnection(e);return t.onicecandidate=function(e){if(e.candidate){var t={type:o.CANDIDATE,caller:null,callee:n.caller,room:n.room,data:e.candidate};r.dispatch("send",t)}},t},e}(),a=function(){function e(){}return e.get=function(e,n){var t=Math.floor(1e16*(1+Math.random())).toString(16).substring(1);return e.createDataChannel(t,n)},e.subscribeToEvents=function(e,n,t){return e.onmessage=function(e){var n={caller:t.caller,room:t.room,data:e.data};r.dispatch(s.DATA,n)},e.onopen=function(e){var n={caller:t.caller,room:t.room,data:e.type};r.dispatch(s.OPEN,n)},e.onclose=function(e){var o={caller:t.caller,room:t.room,data:e.type};r.dispatch(s.CLOSE,o),delete n[t.caller.id]},e.onerror=function(e){var n={caller:t.caller,room:t.room,data:e.type};r.dispatch(s.ERROR,n)},e},e}(),l=function(){function e(e){this._peers={},this._channels={},this._connection=e,this._peers=this._connection.peers,this._channels=this._connection.channels,r.register(o.CONNECT,this.onConnect.bind(this)),r.register(o.DISCONNECT,this.onDisconnect.bind(this)),r.register(o.OFFER,this.onOffer.bind(this)),r.register(o.ANSWER,this.onAnswer.bind(this)),r.register(o.CANDIDATE,this.onCandidate.bind(this))}return Object.defineProperty(e.prototype,"connection",{get:function(){return this._connection},set:function(e){this._connection=e},enumerable:!0,configurable:!0}),e.prototype.onConnect=function(e){var n=this,t=this._peers[e.caller.id]=c.get(this._connection.servers,e),r=a.get(t,this._connection.dataConstraints);this._channels[e.caller.id]=a.subscribeToEvents(r,this._channels,e),this._peers[e.caller.id]=t,t.createOffer(function(r){var i={type:o.OFFER,caller:null,callee:e.caller,room:e.room,data:r};t.setLocalDescription(r,function(){return n.dispatchEvent(i)},function(t){return n.dispatchError(e,t)})},function(t){return n.dispatchError(e,t)})},e.prototype.onDisconnect=function(e){var n=this._channels[e.caller.id],t=this._peers[e.caller.id];n.close(),t.close(),delete this._channels[e.caller.id],delete this._peers[e.caller.id]},e.prototype.onOffer=function(e){var n=this,t=c.get(this._connection.servers,e);this._peers[e.caller.id]=t,t.ondatachannel=function(t){var r=a.subscribeToEvents(t.channel,n._channels,e);n._connection.addChannel(e.caller.id,r)},t.setRemoteDescription(new RTCSessionDescription(e.data),function(){},function(t){return n.dispatchError(e,t)}),t.createAnswer(function(r){var i={type:o.ANSWER,caller:null,callee:e.caller,room:e.room,data:r};t.setLocalDescription(r,function(){return n.dispatchEvent(i)},function(t){return n.dispatchError(e,t)})},function(t){return n.dispatchError(e,t)})},e.prototype.onAnswer=function(e){var n=this;this._peers[e.caller.id].setRemoteDescription(new RTCSessionDescription(e.data),function(){},function(t){return n.dispatchError(e,t)})},e.prototype.onCandidate=function(e){var n=this,t=this._peers[e.caller.id],r=new RTCIceCandidate(e.data);t.addIceCandidate(r).then(function(){},function(t){return n.dispatchError(e,t)})},e.prototype.dispatchEvent=function(e){r.dispatch("send",e)},e.prototype.dispatchError=function(e,n){var t={caller:e.caller,room:e.room,data:n.message};r.dispatch(s.ERROR,t)},e}(),h=function(){function e(e,n){void 0===e&&(e={}),void 0===n&&(n=null);var t=new i(e,n);this.bridge=new l(t)}return e.prototype.on=function(e,n){r.register(e,n)},e.prototype.send=function(e,n){if(n){var t=this.bridge.connection.channels[n];t&&"open"===t.readyState&&t.send(e)}else Object.entries(this.bridge.connection.channels).forEach(function(n){var t=(n[0],n[1]);"open"===t.readyState&&t.send(e)})},e.prototype.connect=function(e){var n={type:o.CONNECT,caller:null,callee:null,room:{id:e},data:null};r.dispatch("send",n)},e.prototype.disconnect=function(e){Object.entries(this.bridge.connection.channels).forEach(function(e){e[0];return e[1].close()}),Object.entries(this.bridge.connection.peers).forEach(function(e){e[0];return e[1].close()});var n={type:o.DISCONNECT,caller:null,callee:null,room:{id:e},data:null};r.dispatch("send",n)},e.prototype.peers=function(e){return e?this.bridge.connection.peers[e]:this.bridge.connection.peers},e.prototype.channels=function(e){return e?this.bridge.connection.channels[e]:this.bridge.connection.channels},e}(),u=function(){function e(e){this.socket=n.connect(e),this.subscribeEvents()}return e.prototype.onSend=function(e){this.socket.emit("message",e)},e.prototype.subscribeEvents=function(){this.socket.on("message",this.onMessage.bind(this)),this.socket.on("ipaddr",this.onIp.bind(this)),this.socket.on("log",this.onLog.bind(this)),r.register("send",this.onSend.bind(this))},e.prototype.onIp=function(e){r.dispatch(s.LOG,"Server IP address is: "+e)},e.prototype.onLog=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];r.dispatch(s.LOG,e)},e.prototype.onMessage=function(e){r.dispatch(e.type,e)},e}();e.default=h,e.EventDispatcher=r,e.ConnectionEventType=o,e.DataEventType=s,e.SocketChannel=u,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=peer-data.js.map |
@@ -92,3 +92,3 @@ import { EventDispatcher } from './dispatcher/dispatcher'; | ||
room: cEvent.room, | ||
event: event, | ||
data: event.message, | ||
}; | ||
@@ -95,0 +95,0 @@ EventDispatcher.dispatch(DataEventType.ERROR, message); |
@@ -6,3 +6,3 @@ import { Caller } from './../connection/caller'; | ||
caller: Caller; | ||
event: MessageEvent | Event | DOMException; | ||
data: any; | ||
} |
@@ -15,3 +15,3 @@ import { DataEventType } from './event-type'; | ||
room: event.room, | ||
event: channelEvent, | ||
data: channelEvent.data, | ||
}; | ||
@@ -24,3 +24,3 @@ EventDispatcher.dispatch(DataEventType.DATA, message); | ||
room: event.room, | ||
event: channelEvent, | ||
data: channelEvent.type, | ||
}; | ||
@@ -33,3 +33,3 @@ EventDispatcher.dispatch(DataEventType.OPEN, message); | ||
room: event.room, | ||
event: channelEvent, | ||
data: channelEvent.type, | ||
}; | ||
@@ -43,3 +43,3 @@ EventDispatcher.dispatch(DataEventType.CLOSE, message); | ||
room: event.room, | ||
event: channelEvent, | ||
data: channelEvent.type, | ||
}; | ||
@@ -46,0 +46,0 @@ EventDispatcher.dispatch(DataEventType.ERROR, message); |
@@ -94,3 +94,3 @@ "use strict"; | ||
room: cEvent.room, | ||
event: event, | ||
data: event.message, | ||
}; | ||
@@ -97,0 +97,0 @@ dispatcher_1.EventDispatcher.dispatch(event_type_2.DataEventType.ERROR, message); |
@@ -6,3 +6,3 @@ import { Caller } from './../connection/caller'; | ||
caller: Caller; | ||
event: MessageEvent | Event | DOMException; | ||
data: any; | ||
} |
@@ -17,3 +17,3 @@ "use strict"; | ||
room: event.room, | ||
event: channelEvent, | ||
data: channelEvent.data, | ||
}; | ||
@@ -26,3 +26,3 @@ dispatcher_1.EventDispatcher.dispatch(event_type_1.DataEventType.DATA, message); | ||
room: event.room, | ||
event: channelEvent, | ||
data: channelEvent.type, | ||
}; | ||
@@ -35,3 +35,3 @@ dispatcher_1.EventDispatcher.dispatch(event_type_1.DataEventType.OPEN, message); | ||
room: event.room, | ||
event: channelEvent, | ||
data: channelEvent.type, | ||
}; | ||
@@ -45,3 +45,3 @@ dispatcher_1.EventDispatcher.dispatch(event_type_1.DataEventType.CLOSE, message); | ||
room: event.room, | ||
event: channelEvent, | ||
data: channelEvent.type, | ||
}; | ||
@@ -48,0 +48,0 @@ dispatcher_1.EventDispatcher.dispatch(event_type_1.DataEventType.ERROR, message); |
{ | ||
"name": "peer-data", | ||
"version": "1.1.9", | ||
"version": "1.1.10", | ||
"description": "PeerData - library for files, media streaming/sharing using WebRTC", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
245072