New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

webrtc-myip

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webrtc-myip - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

4

lib-esm/RTC.d.ts

@@ -21,2 +21,3 @@ import { ICECandidateMessage, MediaType, NegotiationMessage } from "./RTCMessage";

private streamDestination;
private remoteDestination;
private emitters;

@@ -26,2 +27,3 @@ private eventEmitter;

private __debug;
private __isStreamer;
/**

@@ -81,2 +83,3 @@ * Creates WebRTC client instance

private handleSourceTrack;
private handleTrackDisconnected;
/**

@@ -166,2 +169,3 @@ * {@link SignalingDelegate} method to handle socket event 'other' (other user joined)

connectDestinationVideo(type: MediaType, videoElement: HTMLVideoElement): EventEmitter;
disconnectDestinationVideo(type?: MediaType): void;
on(event: string, fn: any, context?: any): EventEmitter<string | symbol>;

@@ -168,0 +172,0 @@ off(event: string, fn: any, context?: any, once?: boolean): EventEmitter<string | symbol>;

52

lib-esm/RTC.js

@@ -72,2 +72,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

this.streamDestination = {};
this.remoteDestination = {};
this.emitters = {};

@@ -80,2 +81,3 @@ this.peerConnections = {

this.signaling.delegate = this;
this.signaling._debug = this.__debug;
this.connectionsCount = 0;

@@ -126,12 +128,12 @@ this.eventEmitter = new EventEmitter();

pc_1.ontrack = function (event) {
_this.log('Track event:', event);
_this.log("Track event for " + mediaType, event);
_this.handleSourceTrack(event.track, mediaType);
};
pc_1.onconnectionstatechange = function (event) {
_this.log(event.type, event);
_this.handleConnectionStateChangeEvent(pc_1, mediaType);
_this.log(event.type, pc_1.connectionState, _this.id, event);
_this.handleConnectionStateChangeEvent(pc_1.connectionState, mediaType);
};
pc_1.onsignalingstatechange = function (event) {
_this.log(event.type, event);
_this.handleConnectionStateChangeEvent(pc_1, mediaType);
_this.log(event.type, pc_1.signalingState, _this.id, event);
_this.handleConnectionStateChangeEvent(pc_1.signalingState, mediaType);
};

@@ -248,2 +250,5 @@ pc_1.ondatachannel = function () {

this.removeTracksFromPC(pc);
if (this.__isStreamer) {
this.addTracksToPC(pc, this.sourceStream[mediaType]);
}
this.destStream[mediaType] = null;

@@ -283,5 +288,5 @@ desc = new RTCSessionDescription(sdp);

};
RTC.prototype.handleConnectionStateChangeEvent = function (pc, mediaType) {
RTC.prototype.handleConnectionStateChangeEvent = function (state, mediaType) {
var stateEvent;
switch (pc.connectionState) {
switch (state) {
case 'connected':

@@ -322,3 +327,4 @@ stateEvent = STATE_EVENTS.CONNECTED;

// know how Callee’s end of the connection is configured
this.peerConnections[mediaType][from].setRemoteDescription(desc).catch(console.error);
var pc = this.peerConnections[mediaType][from];
pc.setRemoteDescription(desc).catch(console.error);
};

@@ -362,3 +368,3 @@ /**

else {
console.log('End of candidates.');
this.log('End of candidates.');
}

@@ -369,3 +375,3 @@ };

this.destStream[mediaType] = stream;
var video = this.streamDestination[mediaType];
var video = this.remoteDestination[mediaType];
if (video) {

@@ -375,6 +381,13 @@ video.srcObject = stream;

else {
console.log("No video element for " + mediaType);
console.warn("No video element for " + mediaType);
}
stream.addTrack(track);
};
RTC.prototype.handleTrackDisconnected = function (mediaType) {
this.destStream[mediaType] = null;
var video = this.remoteDestination[mediaType];
if (video) {
video.srcObject = null;
}
};
/**

@@ -435,3 +448,5 @@ * {@link SignalingDelegate} method to handle socket event 'other' (other user joined)

switch (_a.label) {
case 0: return [4 /*yield*/, this.signaling.setupSocket()];
case 0:
this.__isStreamer = isStreamer;
return [4 /*yield*/, this.signaling.setupSocket()];
case 1:

@@ -553,3 +568,3 @@ _a.sent();

var pcId = _a[_i];
this.log('close');
this.log("close connection with " + pcId);
this.peerConnections[type][pcId].close();

@@ -568,3 +583,3 @@ delete this.peerConnections[type][pcId];

var pcId = _a[_i];
this.createOffer(type, pcId);
this.createOffer(type, pcId).catch(console.error);
}

@@ -591,3 +606,3 @@ };

if (type === void 0) { type = 'userMedia'; }
this.streamDestination[type] = videoElement;
this.remoteDestination[type] = videoElement;
var emitter = new EventEmitter();

@@ -597,2 +612,9 @@ this.emitters[type] = emitter;

};
RTC.prototype.disconnectDestinationVideo = function (type) {
if (type === void 0) { type = 'userMedia'; }
this.remoteDestination[type]['srcObject'] = null;
delete this.remoteDestination[type];
var emitter = this.emitters[type];
emitter.removeAllListeners();
};
RTC.prototype.on = function (event, fn, context) {

@@ -599,0 +621,0 @@ return this.eventEmitter.on(event, fn, context);

@@ -12,2 +12,3 @@ import { ICECandidateMessage, NegotiationMessage, RTCMessage } from "./RTCMessage";

private wsURL;
_debug: boolean;
private id;

@@ -14,0 +15,0 @@ private __debug;

@@ -7,2 +7,9 @@ import * as io from 'socket.io-client';

}
Object.defineProperty(SignalingChannel.prototype, "_debug", {
set: function (value) {
this.__debug = value;
},
enumerable: true,
configurable: true
});
SignalingChannel.prototype.setupSocket = function () {

@@ -9,0 +16,0 @@ var _this = this;

@@ -21,2 +21,3 @@ import { ICECandidateMessage, MediaType, NegotiationMessage } from "./RTCMessage";

private streamDestination;
private remoteDestination;
private emitters;

@@ -26,2 +27,3 @@ private eventEmitter;

private __debug;
private __isStreamer;
/**

@@ -81,2 +83,3 @@ * Creates WebRTC client instance

private handleSourceTrack;
private handleTrackDisconnected;
/**

@@ -166,2 +169,3 @@ * {@link SignalingDelegate} method to handle socket event 'other' (other user joined)

connectDestinationVideo(type: MediaType, videoElement: HTMLVideoElement): EventEmitter;
disconnectDestinationVideo(type?: MediaType): void;
on(event: string, fn: any, context?: any): EventEmitter<string | symbol>;

@@ -168,0 +172,0 @@ off(event: string, fn: any, context?: any, once?: boolean): EventEmitter<string | symbol>;

@@ -74,2 +74,3 @@ "use strict";

this.streamDestination = {};
this.remoteDestination = {};
this.emitters = {};

@@ -82,2 +83,3 @@ this.peerConnections = {

this.signaling.delegate = this;
this.signaling._debug = this.__debug;
this.connectionsCount = 0;

@@ -128,12 +130,12 @@ this.eventEmitter = new EventEmitter();

pc_1.ontrack = function (event) {
_this.log('Track event:', event);
_this.log("Track event for " + mediaType, event);
_this.handleSourceTrack(event.track, mediaType);
};
pc_1.onconnectionstatechange = function (event) {
_this.log(event.type, event);
_this.handleConnectionStateChangeEvent(pc_1, mediaType);
_this.log(event.type, pc_1.connectionState, _this.id, event);
_this.handleConnectionStateChangeEvent(pc_1.connectionState, mediaType);
};
pc_1.onsignalingstatechange = function (event) {
_this.log(event.type, event);
_this.handleConnectionStateChangeEvent(pc_1, mediaType);
_this.log(event.type, pc_1.signalingState, _this.id, event);
_this.handleConnectionStateChangeEvent(pc_1.signalingState, mediaType);
};

@@ -250,2 +252,5 @@ pc_1.ondatachannel = function () {

this.removeTracksFromPC(pc);
if (this.__isStreamer) {
this.addTracksToPC(pc, this.sourceStream[mediaType]);
}
this.destStream[mediaType] = null;

@@ -285,5 +290,5 @@ desc = new RTCSessionDescription(sdp);

};
RTC.prototype.handleConnectionStateChangeEvent = function (pc, mediaType) {
RTC.prototype.handleConnectionStateChangeEvent = function (state, mediaType) {
var stateEvent;
switch (pc.connectionState) {
switch (state) {
case 'connected':

@@ -324,3 +329,4 @@ stateEvent = STATE_EVENTS.CONNECTED;

// know how Callee’s end of the connection is configured
this.peerConnections[mediaType][from].setRemoteDescription(desc).catch(console.error);
var pc = this.peerConnections[mediaType][from];
pc.setRemoteDescription(desc).catch(console.error);
};

@@ -364,3 +370,3 @@ /**

else {
console.log('End of candidates.');
this.log('End of candidates.');
}

@@ -371,3 +377,3 @@ };

this.destStream[mediaType] = stream;
var video = this.streamDestination[mediaType];
var video = this.remoteDestination[mediaType];
if (video) {

@@ -377,6 +383,13 @@ video.srcObject = stream;

else {
console.log("No video element for " + mediaType);
console.warn("No video element for " + mediaType);
}
stream.addTrack(track);
};
RTC.prototype.handleTrackDisconnected = function (mediaType) {
this.destStream[mediaType] = null;
var video = this.remoteDestination[mediaType];
if (video) {
video.srcObject = null;
}
};
/**

@@ -437,3 +450,5 @@ * {@link SignalingDelegate} method to handle socket event 'other' (other user joined)

switch (_a.label) {
case 0: return [4 /*yield*/, this.signaling.setupSocket()];
case 0:
this.__isStreamer = isStreamer;
return [4 /*yield*/, this.signaling.setupSocket()];
case 1:

@@ -555,3 +570,3 @@ _a.sent();

var pcId = _a[_i];
this.log('close');
this.log("close connection with " + pcId);
this.peerConnections[type][pcId].close();

@@ -570,3 +585,3 @@ delete this.peerConnections[type][pcId];

var pcId = _a[_i];
this.createOffer(type, pcId);
this.createOffer(type, pcId).catch(console.error);
}

@@ -593,3 +608,3 @@ };

if (type === void 0) { type = 'userMedia'; }
this.streamDestination[type] = videoElement;
this.remoteDestination[type] = videoElement;
var emitter = new EventEmitter();

@@ -599,2 +614,9 @@ this.emitters[type] = emitter;

};
RTC.prototype.disconnectDestinationVideo = function (type) {
if (type === void 0) { type = 'userMedia'; }
this.remoteDestination[type]['srcObject'] = null;
delete this.remoteDestination[type];
var emitter = this.emitters[type];
emitter.removeAllListeners();
};
RTC.prototype.on = function (event, fn, context) {

@@ -601,0 +623,0 @@ return this.eventEmitter.on(event, fn, context);

@@ -12,2 +12,3 @@ import { ICECandidateMessage, NegotiationMessage, RTCMessage } from "./RTCMessage";

private wsURL;
_debug: boolean;
private id;

@@ -14,0 +15,0 @@ private __debug;

@@ -9,2 +9,9 @@ "use strict";

}
Object.defineProperty(SignalingChannel.prototype, "_debug", {
set: function (value) {
this.__debug = value;
},
enumerable: true,
configurable: true
});
SignalingChannel.prototype.setupSocket = function () {

@@ -11,0 +18,0 @@ var _this = this;

{
"name": "webrtc-myip",
"version": "1.0.1",
"version": "1.0.2",
"description": "WebRTC client",

@@ -15,3 +15,3 @@ "main": "lib/index.js",

"scripts": {
"docs": "typedoc --out ./docs --excludePrivate",
"docs": "typedoc --out ./docs --excludePrivate --mode file",
"lib": "npm run clean && tsc && tsc -m es6 --outDir lib-esm && webpack",

@@ -18,0 +18,0 @@ "clean": "rm -rf lib lib-esm"

@@ -58,3 +58,3 @@ # WebRTC-myip - webRTC client

```
See working example code in the [example folder](example)
See working example code in the [example folder](https://github.com/zhukovka/webrtc-myip/tree/master/example)
## Docs

@@ -74,2 +74,2 @@ Read full documentation [here](https://zhukovka.github.io/webrtc-myip/)

See sample socket code in the [example folder](example/index.ts)
See sample socket code in the [example folder](https://github.com/zhukovka/webrtc-myip/tree/master/example/index.ts)

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 too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc