17 lines
374 B
TypeScript
17 lines
374 B
TypeScript
|
import Peer, { DataConnection } from "peerjs";
|
||
|
|
||
|
export default class NetworkPeer {
|
||
|
protected peer: Peer;
|
||
|
protected constructor() {
|
||
|
this.peer = new Peer();
|
||
|
this.peer.on("open", function(id) {
|
||
|
console.info("Peer ID assigned: %s", id);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
protected send<T>(conn: DataConnection, data: T) {
|
||
|
//TODO Debugging support?
|
||
|
conn.send(data);
|
||
|
}
|
||
|
}
|