Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-datachannel

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-datachannel - npm Package Compare versions

Comparing version 0.1.13 to 0.1.14-dev

src/thread-safe-callback.cpp

13

CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW)
project(node_datachannel VERSION 0.1.13)
project(node_datachannel VERSION 0.1.14)

@@ -30,3 +30,3 @@ include_directories(${CMAKE_JS_INC})

GIT_REPOSITORY https://github.com/paullouisageneau/libdatachannel.git
GIT_TAG "v0.15.6"
GIT_TAG "v0.16.0"
)

@@ -48,2 +48,3 @@

src/peer-connection-wrapper.cpp
src/thread-safe-callback.cpp
src/main.cpp

@@ -58,6 +59,12 @@ ${CMAKE_JS_SRC}

${CMAKE_SOURCE_DIR}/node_modules/node-addon-api
${CMAKE_SOURCE_DIR}/node_modules/napi-thread-safe-callback
${CMAKE_BINARY_DIR}/_deps/libdatachannel-src/include
)
# For compatibility with Node.js 12
# This should be removed along with the napi-thread-safe-callback-cancellable dependency when dropping support at end-of-life
target_compile_definitions(${PROJECT_NAME} PRIVATE -DLEGACY_NAPI_THREAD_SAFE_CALLBACK)
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_SOURCE_DIR}/node_modules/napi-thread-safe-callback-cancellable
)
set(LINK_LIBRARIES

@@ -64,0 +71,0 @@ ${CMAKE_JS_LIB}

{
"name": "node-datachannel",
"version": "0.1.13",
"version": "0.1.14-dev",
"description": "libdatachannel node bindings",

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

"clean": "cmake-js clean",
"test": "jest --forceExit"
"test": "jest"
},

@@ -28,3 +28,12 @@ "repository": {

],
"author": "Murat Doğan",
"contributors": [
{
"name": "Murat Doğan",
"url": "https://github.com/murat-dogan"
},
{
"name": "Paul-Louis Ageneau",
"url": "https://github.com/paullouisageneau"
}
],
"license": "GPL-2.0-or-later",

@@ -40,4 +49,4 @@ "gypfile": true,

"nan": "^2.15.0",
"napi-thread-safe-callback": "0.0.6",
"node-addon-api": "^3.2.1",
"napi-thread-safe-callback-cancellable": "^0.0.7",
"node-addon-api": "^4.2.0",
"prebuild": "^11.0.0"

@@ -44,0 +53,0 @@ },

@@ -99,3 +99,4 @@ const nodeDataChannel = require('../lib/index');

nodeDataChannel.cleanup();
process.exit();
// No need for this (>= V0.1.14)
// process.exit();
}, 5 * 1000);

@@ -38,113 +38,112 @@ const nodeDataChannel = require('../lib/index');

// describe('P2P', () => {
// let peer1 = new nodeDataChannel.PeerConnection("Peer1", { iceServers: ["stun:stun.l.google.com:19302"] });
// let peer2 = new nodeDataChannel.PeerConnection("Peer2", { iceServers: ["stun:stun.l.google.com:19302"] });
// let dc1 = null;
// let dc2 = null;
describe('P2P', () => {
// Default is 5000 ms but we need more
jest.setTimeout(30000);
// // Mocks
// const p1StateMock = jest.fn();
// const p1GatheringStateMock = jest.fn();
// const p2StateMock = jest.fn();
// const p2GatheringStateMock = jest.fn();
// const p1SDPMock = jest.fn();
// const p1CandidateMock = jest.fn();
// const p2SDPMock = jest.fn();
// const p2CandidateMock = jest.fn();
let peer1 = new nodeDataChannel.PeerConnection("Peer1", { iceServers: ["stun:stun.l.google.com:19302"] });
let peer2 = new nodeDataChannel.PeerConnection("Peer2", { iceServers: ["stun:stun.l.google.com:19302"] });
let dc1 = null;
let dc2 = null;
// const p1DCMock = jest.fn();
// const p1DCMessageMock = jest.fn();
// const p2DCMock = jest.fn();
// const p2DCMessageMock = jest.fn();
// Mocks
const p1StateMock = jest.fn();
const p1GatheringStateMock = jest.fn();
const p2StateMock = jest.fn();
const p2GatheringStateMock = jest.fn();
const p1SDPMock = jest.fn();
const p1CandidateMock = jest.fn();
const p2SDPMock = jest.fn();
const p2CandidateMock = jest.fn();
// // Set Callbacks
// peer1.onStateChange(p1StateMock);
// peer1.onGatheringStateChange(p1GatheringStateMock);
// peer1.onLocalDescription((sdp, type) => {
// p1SDPMock();
// peer2.setRemoteDescription(sdp, type);
// });
// peer1.onLocalCandidate((candidate, mid) => {
// p1CandidateMock();
// peer2.addRemoteCandidate(candidate, mid);
// });
const p1DCMock = jest.fn();
const p1DCMessageMock = jest.fn();
const p2DCMock = jest.fn();
const p2DCMessageMock = jest.fn();
// // Set Callbacks
// peer2.onStateChange(p2StateMock);
// peer2.onGatheringStateChange(p2GatheringStateMock);
// peer2.onLocalDescription((sdp, type) => {
// p2SDPMock();
// peer1.setRemoteDescription(sdp, type);
// });
// peer2.onLocalCandidate((candidate, mid) => {
// p2CandidateMock();
// peer1.addRemoteCandidate(candidate, mid);
// });
// peer2.onDataChannel((dc) => {
// p2DCMock();
// dc2 = dc;
// dc2.onMessage((msg) => {
// p2DCMessageMock(msg);
// });
// dc2.sendMessage("Hello From Peer2");
// });
// Set Callbacks
peer1.onStateChange(p1StateMock);
peer1.onGatheringStateChange(p1GatheringStateMock);
peer1.onLocalDescription((sdp, type) => {
p1SDPMock();
peer2.setRemoteDescription(sdp, type);
});
peer1.onLocalCandidate((candidate, mid) => {
p1CandidateMock();
peer2.addRemoteCandidate(candidate, mid);
});
// dc1 = peer1.createDataChannel("test-p2p");
// dc1.onOpen(() => {
// p1DCMock();
// dc1.sendMessage("Hello From Peer1");
// });
// dc1.onMessage((msg) => {
// p1DCMessageMock(msg);
// });
// Set Callbacks
peer2.onStateChange(p2StateMock);
peer2.onGatheringStateChange(p2GatheringStateMock);
peer2.onLocalDescription((sdp, type) => {
p2SDPMock();
peer1.setRemoteDescription(sdp, type);
});
peer2.onLocalCandidate((candidate, mid) => {
p2CandidateMock();
peer1.addRemoteCandidate(candidate, mid);
});
peer2.onDataChannel((dc) => {
p2DCMock();
dc2 = dc;
dc2.onMessage((msg) => {
p2DCMessageMock(msg);
});
dc2.sendMessage("Hello From Peer2");
});
// test('P2P', (done) => {
// // Default is 5000 ms but we need more
// jest.setTimeout(30000);
dc1 = peer1.createDataChannel("test-p2p");
dc1.onOpen(() => {
p1DCMock();
dc1.sendMessage("Hello From Peer1");
});
dc1.onMessage((msg) => {
p1DCMessageMock(msg);
});
// setTimeout(() => {
// dc1.close();
// dc2.close();
// peer1.close();
// peer2.close();
test('P2P', (done) => {
setTimeout(() => {
dc1.close();
dc2.close();
peer1.close();
peer2.close();
// // Fee memory
// dc1 = null;
// dc2 = null;
// peer1 = null;
// peer2 = null;
// Fee memory
dc1 = null;
dc2 = null;
peer1 = null;
peer2 = null;
// // Cleanup Threads
// nodeDataChannel.cleanup();
// }, 8 * 1000);
// Cleanup Threads
nodeDataChannel.cleanup();
}, 10 * 1000);
// setTimeout(() => {
// // State Callbacks
// expect(p1StateMock.mock.calls.length).toBeGreaterThanOrEqual(1);
// expect(p1GatheringStateMock.mock.calls.length).toBeGreaterThanOrEqual(1);
// expect(p2StateMock.mock.calls.length).toBeGreaterThanOrEqual(1);
// expect(p2GatheringStateMock.mock.calls.length).toBeGreaterThanOrEqual(1);
setTimeout(() => {
// State Callbacks
expect(p1StateMock.mock.calls.length).toBeGreaterThanOrEqual(1);
expect(p1GatheringStateMock.mock.calls.length).toBeGreaterThanOrEqual(1);
expect(p2StateMock.mock.calls.length).toBeGreaterThanOrEqual(1);
expect(p2GatheringStateMock.mock.calls.length).toBeGreaterThanOrEqual(1);
// // SDP
// expect(p1SDPMock.mock.calls.length).toBe(1);
// expect(p2SDPMock.mock.calls.length).toBe(1);
// SDP
expect(p1SDPMock.mock.calls.length).toBe(1);
expect(p2SDPMock.mock.calls.length).toBe(1);
// // Candidates
// expect(p1CandidateMock.mock.calls.length).toBeGreaterThanOrEqual(1);
// expect(p2CandidateMock.mock.calls.length).toBeGreaterThanOrEqual(1);
// Candidates
expect(p1CandidateMock.mock.calls.length).toBeGreaterThanOrEqual(1);
expect(p2CandidateMock.mock.calls.length).toBeGreaterThanOrEqual(1);
// // DataChannel
// expect(p1DCMock.mock.calls.length).toBe(1);
// expect(p1DCMessageMock.mock.calls.length).toBe(1);
// expect(p1DCMessageMock.mock.calls[0][0]).toEqual("Hello From Peer2");
// expect(p2DCMock.mock.calls.length).toBe(1);
// // These 2 tests fails randomly
// // Needs investigation ?
// // expect(p2DCMessageMock.mock.calls.length).toBe(1);
// // expect(p2DCMessageMock.mock.calls[0][0]).toEqual("Hello From Peer1");
// DataChannel
expect(p1DCMock.mock.calls.length).toBe(1);
expect(p1DCMessageMock.mock.calls.length).toBe(1);
expect(p1DCMessageMock.mock.calls[0][0]).toEqual("Hello From Peer2");
expect(p2DCMock.mock.calls.length).toBe(1);
// done();
// }, 20 * 1000);
expect(p2DCMessageMock.mock.calls.length).toBe(1);
expect(p2DCMessageMock.mock.calls[0][0]).toEqual("Hello From Peer1");
// });
// });
done();
}, 12 * 1000);
});
});

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

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