You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
filepizza/client/stores/PeerStore.js

31 lines
566 B
JavaScript

import Peer from 'peerjs';
import PeerActions from '../actions/PeerActions';
import alt from '../alt';
import uuid from 'node-uuid';
let id = uuid.v4();
let peer = new Peer(id, {
host: window.location.hostname,
port: window.location.port,
path: '/peer'
});
peer.on('connection', (conn) => {
PeerActions.peerConnected(conn);
});
export default alt.createStore(class PeerStore {
static connect(peerID, metadata) {
return peer.connect(peerID, {
reliable: true,
metadata: metadata
});
}
static getPeerID() {
return id;
}
})