From c83a215679374afe6526564ddcfce99f8c6469c6 Mon Sep 17 00:00:00 2001 From: Sascha Englert Date: Tue, 21 Aug 2018 20:02:58 +0200 Subject: [PATCH 1/8] Added d.ts for socket.io-p2p --- types/socket.io-p2p/index.d.ts | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 types/socket.io-p2p/index.d.ts diff --git a/types/socket.io-p2p/index.d.ts b/types/socket.io-p2p/index.d.ts new file mode 100644 index 0000000000..79b91e0c14 --- /dev/null +++ b/types/socket.io-p2p/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for socket.io P2P v2.2 +// Project: https://github.com/socketio/socket.io-p2p +// Definitions by: Sascha Englert +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace Socketiop2p; + +export = SocketioP2PStatic; + +declare function SocketioP2PStatic( + socket: any, + opts: SocketioP2PStatic.P2POptions, + cb?: () => void +): SocketioP2PStatic.Socketiop2p; + +declare namespace SocketioP2PStatic { + export interface PeerOpts { + initiator?: boolean; // false + channelConfig?: object; // {} + channelName?: string; // random string + config?: object; // { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }, { urls: 'stun:global.stun.twilio.com:3478?transport=udp' }] } + constraints?: object; // {} + offerConstraints?: object; // {} + answerConstraints?: object; // {} + sdpTransfrom?: (sdp: any) => any; // (sdp) => sdp + stream?: boolean; // false + streams?: any[]; // [] + trickle?: boolean; // true + wrtc?: RTCPeerConnection | RTCSessionDescription | RTCIceCandidate; // {} + objectMode?: boolean; // false + } + + export interface P2POptions { + numClients?: number; // 5 + autoUpgrade?: boolean; //true + peerOpts?: PeerOpts; + } + + export interface Socketiop2p { + (socket: any, opts: P2POptions, cb?: () => void): Socketiop2p; + on(event: string, callback: (data: any) => void): void; + emit(data: any, cb: () => void): void; + + upgrade(): void; + disconnect(): void; + binarySlice(arr: any[], interval: number, cb: () => void): void; + setupPeerEvents(peer: any): void; + } +} From 0703234afbd5db5e60520c07b7330abf5120bb6c Mon Sep 17 00:00:00 2001 From: Sascha Englert Date: Tue, 21 Aug 2018 20:09:37 +0200 Subject: [PATCH 2/8] Revert "Added d.ts for socket.io-p2p" This reverts commit c83a215679374afe6526564ddcfce99f8c6469c6. --- types/socket.io-p2p/index.d.ts | 49 ---------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 types/socket.io-p2p/index.d.ts diff --git a/types/socket.io-p2p/index.d.ts b/types/socket.io-p2p/index.d.ts deleted file mode 100644 index 79b91e0c14..0000000000 --- a/types/socket.io-p2p/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Type definitions for socket.io P2P v2.2 -// Project: https://github.com/socketio/socket.io-p2p -// Definitions by: Sascha Englert -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export as namespace Socketiop2p; - -export = SocketioP2PStatic; - -declare function SocketioP2PStatic( - socket: any, - opts: SocketioP2PStatic.P2POptions, - cb?: () => void -): SocketioP2PStatic.Socketiop2p; - -declare namespace SocketioP2PStatic { - export interface PeerOpts { - initiator?: boolean; // false - channelConfig?: object; // {} - channelName?: string; // random string - config?: object; // { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }, { urls: 'stun:global.stun.twilio.com:3478?transport=udp' }] } - constraints?: object; // {} - offerConstraints?: object; // {} - answerConstraints?: object; // {} - sdpTransfrom?: (sdp: any) => any; // (sdp) => sdp - stream?: boolean; // false - streams?: any[]; // [] - trickle?: boolean; // true - wrtc?: RTCPeerConnection | RTCSessionDescription | RTCIceCandidate; // {} - objectMode?: boolean; // false - } - - export interface P2POptions { - numClients?: number; // 5 - autoUpgrade?: boolean; //true - peerOpts?: PeerOpts; - } - - export interface Socketiop2p { - (socket: any, opts: P2POptions, cb?: () => void): Socketiop2p; - on(event: string, callback: (data: any) => void): void; - emit(data: any, cb: () => void): void; - - upgrade(): void; - disconnect(): void; - binarySlice(arr: any[], interval: number, cb: () => void): void; - setupPeerEvents(peer: any): void; - } -} From 5677ea318e2bbb610d4bf2c5916f714a4986563c Mon Sep 17 00:00:00 2001 From: Sascha Englert Date: Tue, 21 Aug 2018 20:13:50 +0200 Subject: [PATCH 3/8] Added d.ts for socket.io-p2p --- types/socket.io-p2p/index.d.ts | 49 ++++++++++++++++++++++ types/socket.io-p2p/socket.io-p2p-tests.ts | 0 types/socket.io-p2p/tsconfig.json | 15 +++++++ types/socket.io-p2p/tslint.json | 1 + 4 files changed, 65 insertions(+) create mode 100644 types/socket.io-p2p/index.d.ts create mode 100644 types/socket.io-p2p/socket.io-p2p-tests.ts create mode 100644 types/socket.io-p2p/tsconfig.json create mode 100644 types/socket.io-p2p/tslint.json diff --git a/types/socket.io-p2p/index.d.ts b/types/socket.io-p2p/index.d.ts new file mode 100644 index 0000000000..fbeaa07c94 --- /dev/null +++ b/types/socket.io-p2p/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for socket.io-p2p 2.2 +// Project: https://github.com/socketio/socket.io-p2p +// Definitions by: Sascha Englert +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace Socketiop2p; + +export = SocketioP2PStatic; + +declare function SocketioP2PStatic( + socket: any, + opts: SocketioP2PStatic.P2POptions, + cb?: () => void +): SocketioP2PStatic.Socketiop2p; + +declare namespace SocketioP2PStatic { + export interface PeerOpts { + initiator?: boolean; // false + channelConfig?: object; // {} + channelName?: string; // random string + config?: object; // { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }, { urls: 'stun:global.stun.twilio.com:3478?transport=udp' }] } + constraints?: object; // {} + offerConstraints?: object; // {} + answerConstraints?: object; // {} + sdpTransfrom?: (sdp: any) => any; // (sdp) => sdp + stream?: boolean; // false + streams?: any[]; // [] + trickle?: boolean; // true + wrtc?: RTCPeerConnection | RTCSessionDescription | RTCIceCandidate; // {} + objectMode?: boolean; // false + } + + export interface P2POptions { + numClients?: number; // 5 + autoUpgrade?: boolean; // true + peerOpts?: PeerOpts; + } + + export interface Socketiop2p { + (socket: any, opts: P2POptions, cb?: () => void): Socketiop2p; + on(event: string, callback: (data: any) => void): void; + emit(data: any, cb: () => void): void; + + upgrade(): void; + disconnect(): void; + binarySlice(arr: any[], interval: number, cb: () => void): void; + setupPeerEvents(peer: any): void; + } +} diff --git a/types/socket.io-p2p/socket.io-p2p-tests.ts b/types/socket.io-p2p/socket.io-p2p-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/socket.io-p2p/tsconfig.json b/types/socket.io-p2p/tsconfig.json new file mode 100644 index 0000000000..cbaab55544 --- /dev/null +++ b/types/socket.io-p2p/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "socket.io-p2p-tests.ts"] +} diff --git a/types/socket.io-p2p/tslint.json b/types/socket.io-p2p/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/socket.io-p2p/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 4c0d6331fb2ac2faf8557e579bb72fbb0d5e59f6 Mon Sep 17 00:00:00 2001 From: Sascha Englert Date: Tue, 21 Aug 2018 20:25:19 +0200 Subject: [PATCH 4/8] Fixed tsconfig and removed redundand keywords --- types/socket.io-p2p/index.d.ts | 7 ++++--- types/socket.io-p2p/tsconfig.json | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/types/socket.io-p2p/index.d.ts b/types/socket.io-p2p/index.d.ts index fbeaa07c94..e0f461111c 100644 --- a/types/socket.io-p2p/index.d.ts +++ b/types/socket.io-p2p/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/socketio/socket.io-p2p // Definitions by: Sascha Englert // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 export as namespace Socketiop2p; @@ -14,7 +15,7 @@ declare function SocketioP2PStatic( ): SocketioP2PStatic.Socketiop2p; declare namespace SocketioP2PStatic { - export interface PeerOpts { + interface PeerOpts { initiator?: boolean; // false channelConfig?: object; // {} channelName?: string; // random string @@ -30,13 +31,13 @@ declare namespace SocketioP2PStatic { objectMode?: boolean; // false } - export interface P2POptions { + interface P2POptions { numClients?: number; // 5 autoUpgrade?: boolean; // true peerOpts?: PeerOpts; } - export interface Socketiop2p { + interface Socketiop2p { (socket: any, opts: P2POptions, cb?: () => void): Socketiop2p; on(event: string, callback: (data: any) => void): void; emit(data: any, cb: () => void): void; diff --git a/types/socket.io-p2p/tsconfig.json b/types/socket.io-p2p/tsconfig.json index cbaab55544..75c4112267 100644 --- a/types/socket.io-p2p/tsconfig.json +++ b/types/socket.io-p2p/tsconfig.json @@ -5,6 +5,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": ["../"], "types": [], From a5e411fdadf25bbc0ffba823c45d9c6f30d7e3dd Mon Sep 17 00:00:00 2001 From: Sascha Englert Date: Sat, 25 Aug 2018 07:44:18 +0200 Subject: [PATCH 5/8] Refactored comments, added stub test --- types/socket.io-p2p/index.d.ts | 104 +++++++++++++++++---- types/socket.io-p2p/socket.io-p2p-tests.ts | 3 + 2 files changed, 91 insertions(+), 16 deletions(-) diff --git a/types/socket.io-p2p/index.d.ts b/types/socket.io-p2p/index.d.ts index e0f461111c..e3f50790cf 100644 --- a/types/socket.io-p2p/index.d.ts +++ b/types/socket.io-p2p/index.d.ts @@ -8,6 +8,12 @@ export as namespace Socketiop2p; export = SocketioP2PStatic; +/** + * Creates the P2P object + * @param socket Socket.io socket + * @param opts Object of viable options + * @param cb Optional callback + */ declare function SocketioP2PStatic( socket: any, opts: SocketioP2PStatic.P2POptions, @@ -16,32 +22,98 @@ declare function SocketioP2PStatic( declare namespace SocketioP2PStatic { interface PeerOpts { - initiator?: boolean; // false - channelConfig?: object; // {} - channelName?: string; // random string - config?: object; // { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }, { urls: 'stun:global.stun.twilio.com:3478?transport=udp' }] } - constraints?: object; // {} - offerConstraints?: object; // {} - answerConstraints?: object; // {} - sdpTransfrom?: (sdp: any) => any; // (sdp) => sdp - stream?: boolean; // false - streams?: any[]; // [] - trickle?: boolean; // true - wrtc?: RTCPeerConnection | RTCSessionDescription | RTCIceCandidate; // {} - objectMode?: boolean; // false + /** + * Set to true if this is the initiating peer + * @default false + */ + initiator?: boolean; + /** + * Custom WebRTC channel configuration (used by createDataChannel) + * @default {} + */ + channelConfig?: object; + /** + * Custom WebRTC data channel name + * @default + */ + channelName?: string; + /** + * Custom WebRTC configuration (used by RTCPeerConnection constructor) + * @default {iceServers:[{urls:'stun:stun.l.google.com:19302'},{urls:'stun:global.stun.twilio.com:3478?transport=udp'}]} + */ + config?: object; + /** + * Custom WebRTC video/voice constrainst (used by RTCPeerConnection constructor) + * @default {} + */ + constraints?: object; + /** + * Custom offer contstraints (used by createOffer methode) + * @default {} + */ + offerConstraints?: object; + /** + * Custom answer constraints (used by createAnswer method) + */ + answerConstraints?: object; + /** + * Function to transform generated SDP signaling data (for advanced users) + * @default (sdp)=>sdp + */ + sdpTransfrom?: (sdp: any) => any; + /** + * If video/voice is desired, pass stream from getUserMedia + * @default false + */ + stream?: boolean; + /** + * An array of MediaStreams returned from getUserMedia + * @default [] + */ + streams?: MediaStream[]; + /** + * Set to false to disable trickle ICE and get single 'signal' event (slower) + * @default true + */ + trickle?: boolean; + /** + * Custom WebRTC implementation, mainly useful in node to specify the wrtc package + * @default {} + */ + wrtc?: RTCPeerConnection | RTCSessionDescription | RTCIceCandidate; + /** + * Set to true to create the stream in Object Mode. In this mode, incoming string data is not automatically converted to Buffer objects + * @default false + */ + objectMode?: boolean; } interface P2POptions { - numClients?: number; // 5 - autoUpgrade?: boolean; // true + /** + * Max number of peers each client can connect to + * @default 5 + */ + numClients?: number; + /** + * Upgrade to p2p connection (from s.io one) when peers are ready + * @default true + */ + autoUpgrade?: boolean; + /** + * Object of options passed to underlying peers + * @default {} + */ peerOpts?: PeerOpts; } interface Socketiop2p { (socket: any, opts: P2POptions, cb?: () => void): Socketiop2p; on(event: string, callback: (data: any) => void): void; - emit(data: any, cb: () => void): void; + emit(data: any, cb?: () => void): void; + /** + * Upgrade the connection to p2p + */ upgrade(): void; disconnect(): void; binarySlice(arr: any[], interval: number, cb: () => void): void; diff --git a/types/socket.io-p2p/socket.io-p2p-tests.ts b/types/socket.io-p2p/socket.io-p2p-tests.ts index e69de29bb2..29d9ef537a 100644 --- a/types/socket.io-p2p/socket.io-p2p-tests.ts +++ b/types/socket.io-p2p/socket.io-p2p-tests.ts @@ -0,0 +1,3 @@ +function testStub() { + console.log("this is a stub"); +} From da60d0c6bbf10be7aca3311df518a4ca8a458f40 Mon Sep 17 00:00:00 2001 From: Sascha Englert Date: Sun, 2 Sep 2018 18:26:17 +0200 Subject: [PATCH 6/8] Reworked definition and added tests --- types/socket.io-p2p/index.d.ts | 213 +++++++++++---------- types/socket.io-p2p/socket.io-p2p-tests.ts | 18 +- 2 files changed, 128 insertions(+), 103 deletions(-) diff --git a/types/socket.io-p2p/index.d.ts b/types/socket.io-p2p/index.d.ts index e3f50790cf..3667726700 100644 --- a/types/socket.io-p2p/index.d.ts +++ b/types/socket.io-p2p/index.d.ts @@ -14,109 +14,122 @@ export = SocketioP2PStatic; * @param opts Object of viable options * @param cb Optional callback */ -declare function SocketioP2PStatic( +declare class SocketioP2PStatic { + useSockets: boolean; + usePeerConnection: boolean; + decoder: any; + socket: any; + cb: () => void; + defaultOps: SocketioP2PStatic.DefaultOps; + opts: SocketioP2PStatic.P2POptions; + peerOpts: SocketioP2PStatic.PeerOpts; + numConnectedClients: number; + + constructor( socket: any, - opts: SocketioP2PStatic.P2POptions, + opts?: SocketioP2PStatic.P2POptions, cb?: () => void -): SocketioP2PStatic.Socketiop2p; + ); + + on(event: string, callback: (data: any) => void): void; + emit(eventName: any, data: any): void; + + /** + * Upgrade the connection to p2p + */ + upgrade(): void; + disconnect(): void; + binarySlice(arr: any[], interval: number, cb: () => void): void; + setupPeerEvents(peer: any): void; +} declare namespace SocketioP2PStatic { - interface PeerOpts { - /** - * Set to true if this is the initiating peer - * @default false - */ - initiator?: boolean; - /** - * Custom WebRTC channel configuration (used by createDataChannel) - * @default {} - */ - channelConfig?: object; - /** - * Custom WebRTC data channel name - * @default - */ - channelName?: string; - /** - * Custom WebRTC configuration (used by RTCPeerConnection constructor) - * @default {iceServers:[{urls:'stun:stun.l.google.com:19302'},{urls:'stun:global.stun.twilio.com:3478?transport=udp'}]} - */ - config?: object; - /** - * Custom WebRTC video/voice constrainst (used by RTCPeerConnection constructor) - * @default {} - */ - constraints?: object; - /** - * Custom offer contstraints (used by createOffer methode) - * @default {} - */ - offerConstraints?: object; - /** - * Custom answer constraints (used by createAnswer method) - */ - answerConstraints?: object; - /** - * Function to transform generated SDP signaling data (for advanced users) - * @default (sdp)=>sdp - */ - sdpTransfrom?: (sdp: any) => any; - /** - * If video/voice is desired, pass stream from getUserMedia - * @default false - */ - stream?: boolean; - /** - * An array of MediaStreams returned from getUserMedia - * @default [] - */ - streams?: MediaStream[]; - /** - * Set to false to disable trickle ICE and get single 'signal' event (slower) - * @default true - */ - trickle?: boolean; - /** - * Custom WebRTC implementation, mainly useful in node to specify the wrtc package - * @default {} - */ - wrtc?: RTCPeerConnection | RTCSessionDescription | RTCIceCandidate; - /** - * Set to true to create the stream in Object Mode. In this mode, incoming string data is not automatically converted to Buffer objects - * @default false - */ - objectMode?: boolean; - } + interface DefaultOps { + autoUpgrade: boolean; + numClients: number; + } + interface PeerOpts { + /** + * Set to true if this is the initiating peer + * @default false + */ + initiator?: boolean; + /** + * Custom WebRTC channel configuration (used by createDataChannel) + * @default {} + */ + channelConfig?: object; + /** + * Custom WebRTC data channel name + * @default + */ + channelName?: string; + /** + * Custom WebRTC configuration (used by RTCPeerConnection constructor) + * @default {iceServers:[{urls:'stun:stun.l.google.com:19302'},{urls:'stun:global.stun.twilio.com:3478?transport=udp'}]} + */ + config?: object; + /** + * Custom WebRTC video/voice constrainst (used by RTCPeerConnection constructor) + * @default {} + */ + constraints?: object; + /** + * Custom offer contstraints (used by createOffer methode) + * @default {} + */ + offerConstraints?: object; + /** + * Custom answer constraints (used by createAnswer method) + */ + answerConstraints?: object; + /** + * Function to transform generated SDP signaling data (for advanced users) + * @default (sdp)=>sdp + */ + sdpTransfrom?: (sdp: any) => any; + /** + * If video/voice is desired, pass stream from getUserMedia + * @default false + */ + stream?: boolean; + /** + * An array of MediaStreams returned from getUserMedia + * @default [] + */ + streams?: MediaStream[]; + /** + * Set to false to disable trickle ICE and get single 'signal' event (slower) + * @default true + */ + trickle?: boolean; + /** + * Custom WebRTC implementation, mainly useful in node to specify the wrtc package + * @default {} + */ + wrtc?: RTCPeerConnection | RTCSessionDescription | RTCIceCandidate; + /** + * Set to true to create the stream in Object Mode. In this mode, incoming string data is not automatically converted to Buffer objects + * @default false + */ + objectMode?: boolean; + } - interface P2POptions { - /** - * Max number of peers each client can connect to - * @default 5 - */ - numClients?: number; - /** - * Upgrade to p2p connection (from s.io one) when peers are ready - * @default true - */ - autoUpgrade?: boolean; - /** - * Object of options passed to underlying peers - * @default {} - */ - peerOpts?: PeerOpts; - } - - interface Socketiop2p { - (socket: any, opts: P2POptions, cb?: () => void): Socketiop2p; - on(event: string, callback: (data: any) => void): void; - emit(data: any, cb?: () => void): void; - - /** - * Upgrade the connection to p2p - */ - upgrade(): void; - disconnect(): void; - binarySlice(arr: any[], interval: number, cb: () => void): void; - setupPeerEvents(peer: any): void; - } + interface P2POptions { + /** + * Max number of peers each client can connect to + * @default 5 + */ + numClients?: number; + /** + * Upgrade to p2p connection (from s.io one) when peers are ready + * @default true + */ + autoUpgrade?: boolean; + /** + * Object of options passed to underlying peers + * @default {} + */ + peerOpts?: PeerOpts; + } } diff --git a/types/socket.io-p2p/socket.io-p2p-tests.ts b/types/socket.io-p2p/socket.io-p2p-tests.ts index 29d9ef537a..dd8548d79d 100644 --- a/types/socket.io-p2p/socket.io-p2p-tests.ts +++ b/types/socket.io-p2p/socket.io-p2p-tests.ts @@ -1,3 +1,15 @@ -function testStub() { - console.log("this is a stub"); -} +import * as P2P from "socket.io-p2p"; +import * as io from "socket.io-client"; + +const socket = io(); +const p2p = new P2P(socket); + +p2p.on("ready", (...args) => { + console.log(args); + p2p.usePeerConnection = true; + p2p.emit("peer-obj", { peerId: 1 }); +}); + +p2p.on("peer-msg", data => { + console.log(data); +}); From 98930540ebf42abda5ffd6e5132a5c684c59b673 Mon Sep 17 00:00:00 2001 From: Sascha Englert Date: Sun, 2 Sep 2018 18:31:44 +0200 Subject: [PATCH 7/8] Removed manual tests --- types/socket.io-p2p/socket.io-p2p-tests.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/socket.io-p2p/socket.io-p2p-tests.ts b/types/socket.io-p2p/socket.io-p2p-tests.ts index dd8548d79d..e566c64c13 100644 --- a/types/socket.io-p2p/socket.io-p2p-tests.ts +++ b/types/socket.io-p2p/socket.io-p2p-tests.ts @@ -4,8 +4,7 @@ import * as io from "socket.io-client"; const socket = io(); const p2p = new P2P(socket); -p2p.on("ready", (...args) => { - console.log(args); +p2p.on("ready", () => { p2p.usePeerConnection = true; p2p.emit("peer-obj", { peerId: 1 }); }); From b24d914740a7348e33422848469bc0f06a8913a5 Mon Sep 17 00:00:00 2001 From: Sascha Englert Date: Mon, 3 Sep 2018 10:19:36 +0200 Subject: [PATCH 8/8] Changed import statements --- types/socket.io-p2p/socket.io-p2p-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/socket.io-p2p/socket.io-p2p-tests.ts b/types/socket.io-p2p/socket.io-p2p-tests.ts index e566c64c13..f6e3548685 100644 --- a/types/socket.io-p2p/socket.io-p2p-tests.ts +++ b/types/socket.io-p2p/socket.io-p2p-tests.ts @@ -1,5 +1,5 @@ -import * as P2P from "socket.io-p2p"; -import * as io from "socket.io-client"; +import P2P = require("socket.io-p2p"); +import io = require("socket.io-client"); const socket = io(); const p2p = new P2P(socket);