peer-data
Advanced tools
Comparing version 1.0.25 to 1.0.26
import { EventType } from './data-channel/event-type'; | ||
import { Logger } from './logger/logger'; | ||
import { Signaling } from './signaling/signaling'; | ||
@@ -9,9 +8,8 @@ export declare class App { | ||
on(event: EventType, callback: EventHandler): void; | ||
send(data: any, ids?: string[]): void; | ||
send(data: any): void; | ||
connect(): void; | ||
disconnect(ids?: string[]): void; | ||
disconnect(): void; | ||
servers: RTCConfiguration; | ||
dataConstraints: RTCDataChannelInit; | ||
logger: Logger; | ||
signaling: Signaling; | ||
} |
@@ -5,4 +5,2 @@ "use strict"; | ||
const connection_1 = require('./connection/connection'); | ||
const console_logger_1 = require('./console-logger'); | ||
const log_level_1 = require('./logger/log-level'); | ||
const bridge_1 = require('./bridge'); | ||
@@ -13,4 +11,3 @@ class App { | ||
const connection = new connection_1.Connection(servers, dataConstraints); | ||
const logger = new console_logger_1.ConsoleLogger(log_level_1.LogLevel.ERROR); | ||
this.bridge = new bridge_1.Bridge(connection, logger); | ||
this.bridge = new bridge_1.Bridge(connection); | ||
} | ||
@@ -20,9 +17,5 @@ on(event, callback) { | ||
} | ||
send(data, ids) { | ||
send(data) { | ||
Object.entries(this.bridge.connection.channels) | ||
.forEach(([key, value]) => { | ||
if (!ids || (ids.length > 1 && ids.indexOf(key) !== -1)) { | ||
value.send(data); | ||
} | ||
}); | ||
.forEach(([key, value]) => value.send(data)); | ||
} | ||
@@ -38,24 +31,12 @@ connect() { | ||
} | ||
disconnect(ids) { | ||
Object.entries(this.bridge.connection.channels) | ||
.forEach(([key, value]) => { | ||
if (!ids || (ids.length > 1 && ids.indexOf(key) !== -1)) { | ||
value.close(); | ||
delete this.bridge.connection.channels[key]; | ||
} | ||
}); | ||
Object.entries(this.bridge.connection.peers) | ||
.forEach(([key, value]) => { | ||
if (!ids || (ids.length > 1 && ids.indexOf(key) !== -1)) { | ||
value.close(); | ||
delete this.bridge.connection.peers[key]; | ||
let event = { | ||
type: event_type_1.SignalingEventType.DISCONNECT, | ||
caller: null, | ||
callee: null, | ||
data: null | ||
}; | ||
this._signaling.send(event); | ||
} | ||
}); | ||
disconnect() { | ||
Object.entries(this.bridge.connection.channels).forEach(([key, value]) => value.close()); | ||
Object.entries(this.bridge.connection.peers).forEach(([key, value]) => value.close()); | ||
const event = { | ||
type: event_type_1.SignalingEventType.DISCONNECT, | ||
caller: null, | ||
callee: null, | ||
data: null | ||
}; | ||
this._signaling.send(event); | ||
} | ||
@@ -74,8 +55,2 @@ get servers() { | ||
} | ||
get logger() { | ||
return this.bridge.logger; | ||
} | ||
set logger(value) { | ||
this.bridge.logger = value; | ||
} | ||
get signaling() { | ||
@@ -82,0 +57,0 @@ return this._signaling; |
import { SignalingEvent } from './signaling/event'; | ||
import { Logger } from './logger/logger'; | ||
import { Signaling } from './signaling/signaling'; | ||
@@ -7,4 +6,3 @@ import { Connection } from './connection/connection'; | ||
private _connection; | ||
private _logger; | ||
constructor(connection: Connection, logger: Logger); | ||
constructor(connection: Connection); | ||
onConnect(event: SignalingEvent, signaling: Signaling): void; | ||
@@ -16,3 +14,3 @@ onCandidate(event: SignalingEvent): void; | ||
connection: Connection; | ||
logger: Logger; | ||
private dispatchError(event); | ||
} |
@@ -5,7 +5,8 @@ "use strict"; | ||
const factory_2 = require('./data-channel/factory'); | ||
const dispatcher_1 = require('./data-channel/dispatcher'); | ||
const event_type_2 = require('./data-channel/event-type'); | ||
const LABEL = 'chunks'; | ||
class Bridge { | ||
constructor(connection, logger) { | ||
constructor(connection) { | ||
this._connection = connection; | ||
this._logger = logger; | ||
} | ||
@@ -23,4 +24,4 @@ onConnect(event, signaling) { | ||
}; | ||
peer.setLocalDescription(desc, () => signaling.send(message), this._logger.error.bind(this._logger)); | ||
}, this._logger.error.bind(this._logger)); | ||
peer.setLocalDescription(desc, () => signaling.send(message), this.dispatchError); | ||
}, this.dispatchError); | ||
} | ||
@@ -39,3 +40,3 @@ onCandidate(event) { | ||
peer.setRemoteDescription(new RTCSessionDescription(event.data), () => { | ||
}, this._logger.error.bind(this._logger)); | ||
}, this.dispatchError); | ||
peer.createAnswer((desc) => { | ||
@@ -48,4 +49,4 @@ let message = { | ||
}; | ||
peer.setLocalDescription(desc, () => signaling.send(message), this._logger.error.bind(this._logger)); | ||
}, this._logger.error.bind(this._logger)); | ||
peer.setLocalDescription(desc, () => signaling.send(message), this.dispatchError); | ||
}, this.dispatchError); | ||
} | ||
@@ -55,3 +56,3 @@ onAnswer(event) { | ||
peer.setRemoteDescription(new RTCSessionDescription(event.data), () => { | ||
}, this._logger.error.bind(this._logger)); | ||
}, this.dispatchError); | ||
} | ||
@@ -70,10 +71,7 @@ onDisconnect(event) { | ||
} | ||
get logger() { | ||
return this._logger; | ||
dispatchError(event) { | ||
dispatcher_1.EventDispatcher.dispatch(event_type_2.EventType.ERROR, event); | ||
} | ||
set logger(value) { | ||
this._logger = value; | ||
} | ||
} | ||
exports.Bridge = Bridge; | ||
//# sourceMappingURL=bridge.js.map |
export declare enum EventType { | ||
OPEN = 0, | ||
CLOSE = 1, | ||
ERROR = 2, | ||
DATA = 3, | ||
LOG = 0, | ||
OPEN = 1, | ||
CLOSE = 2, | ||
ERROR = 3, | ||
DATA = 4, | ||
} |
"use strict"; | ||
(function (EventType) { | ||
EventType[EventType["OPEN"] = 0] = "OPEN"; | ||
EventType[EventType["CLOSE"] = 1] = "CLOSE"; | ||
EventType[EventType["ERROR"] = 2] = "ERROR"; | ||
EventType[EventType["DATA"] = 3] = "DATA"; | ||
EventType[EventType["LOG"] = 0] = "LOG"; | ||
EventType[EventType["OPEN"] = 1] = "OPEN"; | ||
EventType[EventType["CLOSE"] = 2] = "CLOSE"; | ||
EventType[EventType["ERROR"] = 3] = "ERROR"; | ||
EventType[EventType["DATA"] = 4] = "DATA"; | ||
})(exports.EventType || (exports.EventType = {})); | ||
var EventType = exports.EventType; | ||
//# sourceMappingURL=event-type.js.map |
@@ -5,8 +5,6 @@ /// <reference types="socket.io-client" /> | ||
import { SignalingEvent } from './signaling/event'; | ||
import { Logger } from './logger/logger'; | ||
export declare class SocketChannel implements Signaling { | ||
private socket; | ||
private bridge; | ||
private _logger; | ||
constructor(bridge: Bridge, logger: Logger, opts?: SocketIOClient.ConnectOpts); | ||
constructor(bridge: Bridge, opts?: SocketIOClient.ConnectOpts); | ||
send(event: SignalingEvent): void; | ||
@@ -17,3 +15,2 @@ private subscribeEvents(); | ||
private onMessage(event); | ||
logger: Logger; | ||
} |
"use strict"; | ||
const io = require('socket.io-client'); | ||
const event_type_1 = require('./signaling/event-type'); | ||
const dispatcher_1 = require('./data-channel/dispatcher'); | ||
const event_type_2 = require('./data-channel/event-type'); | ||
class SocketChannel { | ||
constructor(bridge, logger, opts) { | ||
constructor(bridge, opts) { | ||
this.socket = io.connect(opts); | ||
this.bridge = bridge; | ||
this._logger = logger; | ||
this.subscribeEvents(); | ||
@@ -20,6 +21,6 @@ } | ||
onIp(ipaddr) { | ||
this._logger.log.apply(this._logger, ['Server IP address is: ' + ipaddr]); | ||
dispatcher_1.EventDispatcher.dispatch(event_type_2.EventType.LOG, 'Server IP address is: ' + ipaddr); | ||
} | ||
onLog(data) { | ||
this._logger.log.apply(this._logger, [data]); | ||
dispatcher_1.EventDispatcher.dispatch(event_type_2.EventType.LOG, data); | ||
} | ||
@@ -45,10 +46,4 @@ onMessage(event) { | ||
} | ||
get logger() { | ||
return this._logger; | ||
} | ||
set logger(value) { | ||
this._logger = value; | ||
} | ||
} | ||
exports.SocketChannel = SocketChannel; | ||
//# sourceMappingURL=socket-channel.js.map |
import { App as PeerData } from './app/app'; | ||
export default PeerData; | ||
export { Signaling } from './app/signaling/signaling'; | ||
export { Logger } from './app/logger/logger'; | ||
export { LogLevel } from './app/logger/log-level'; | ||
export { SignalingEvent } from './app/signaling/event'; | ||
@@ -7,0 +5,0 @@ export { SignalingEventType } from './app/signaling/event-type'; |
@@ -5,4 +5,2 @@ "use strict"; | ||
exports.default = app_1.App; | ||
var log_level_1 = require('./app/logger/log-level'); | ||
exports.LogLevel = log_level_1.LogLevel; | ||
var event_type_1 = require('./app/signaling/event-type'); | ||
@@ -9,0 +7,0 @@ exports.SignalingEventType = event_type_1.SignalingEventType; |
{ | ||
"name": "peer-data", | ||
"version": "1.0.25", | ||
"version": "1.0.26", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71529
70
600