Merge pull request #4829 from legokichi/peer

Add PeerJs.Peer.off method
This commit is contained in:
Horiuchi_H
2015-07-06 18:07:42 +09:00
2 changed files with 12 additions and 1 deletions
+3 -1
View File
@@ -42,11 +42,13 @@ var connection = peerById.connect("id", {
var call = peerById.call('callto-id', (<any>window).localStream);
peerById.on("open", ()=> console.log("open"));
var openHandler=()=> console.log("open");
peerById.on("open", openHandler);
peerById.on("connection", (c)=> console.log("connection"));
peerById.on("call", (media)=> console.log("call"));
peerById.on("close", ()=> console.log("close"));
peerById.on("disconnected", ()=> console.log("disconnected"));
peerById.on("error", (err)=> console.log(err));
peerById.off("open", openHandler);
var connection2 = peerById.getConnection(peerByOption, "callto-id");
+9
View File
@@ -33,6 +33,7 @@ declare module PeerJs{
on(event: 'open', cb: ()=>void): void;
on(event: 'close', cb: ()=>void): void;
on(event: 'error', cb: (err: any)=>void): void;
off(event: string, fn: Function, once?: boolean): void;
dataChannel: RTCDataChannel;
label: string;
metadata: any;
@@ -52,6 +53,7 @@ declare module PeerJs{
on(event: 'stream', cb: (stream: any)=>void): void;
on(event: 'close', cb: ()=>void): void;
on(event: 'error', cb: (err: any)=>void): void;
off(event: string, fn: Function, once?: boolean): void;
open: boolean;
metadata: any;
peer: string;
@@ -126,6 +128,13 @@ declare module PeerJs{
* @param cb Callback Function
*/
on(event: 'error', cb: (err: any)=>void): void;
/**
* Remove event listeners.(EventEmitter3)
* @param {String} event The event we want to remove.
* @param {Function} fn The listener that we need to find.
* @param {Boolean} once Only remove once listeners.
*/
off(event: string, fn: Function, once?: boolean): void;
/**
* Close the connection to the server, leaving all existing data and media connections intact.
*/