teletype-client-modified
Version:
I have modified the library developed by Atom to make it compatible with non-browser facility. I am using it only for experimentation purposes. I will remove this package post my experiment and raise a PR at Atom to finally merge this package so that this
23 lines (17 loc) • 675 B
JavaScript
const StarOverlayNetwork = require('../../lib/star-overlay-network')
module.exports =
function buildStarNetwork (id, peerPool, {isHub, connectionTimeout}={}) {
const network = new StarOverlayNetwork({id, peerPool, isHub, connectionTimeout})
network.testJoinEvents = []
network.onMemberJoin(({peerId}) => network.testJoinEvents.push(peerId))
network.testLeaveEvents = []
network.onMemberLeave(({peerId, connectionLost}) => network.testLeaveEvents.push({peerId, connectionLost}))
network.testInbox = []
network.onReceive(({senderId, message}) => {
network.testInbox.push({
senderId,
message: message.toString()
})
})
return network
}