How to use the primus.createServer function in primus

To help you get started, we’ve selected a few primus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NerdyRedPanda / Better-Discord-Screen-Share / main.js View on Github external
}

child.exec('sed "s/PLACEHOLDER/' + domain + '/g; s/USERPLACE/screenshare/g; s/PASSPLACE/'+httpPassword+'/g" html/template.js > html/screenShare.plugin.js', (err, stdout, out) => {
  if (err) {
     throw new Error(err)
  }
})

const bot = new Discord.Client({
   token: token,
   autorun: true
})



const wssServer = primus.createServer({
   port: 8006,
   iknowhttpsisbetter: true,
   pathname: '/ssws'
})

wssServer.save(__dirname + '/html/primus.js')

wssServer.on('connection', spark => {
   console.log('Got connection')
   fs.readFile('html/screenShare.plugin.js', 'utf8', (err, localPlugin) => {
      let localHash = crypto.createHash('sha256').update(localPlugin).digest('hex')
      if (localHash != spark.query.version) {
         spark.write({ type: 'update', file: localPlugin })
      }
      if (share) {
         spark.write({ type: 'startView', guild: guild })
github ListnPlay / riot-isomorphic / gulpfile.js View on Github external
gulp.task('primus', function() {
    var Primus = require('primus');
    var Emitter = require('primus-emitter');
    var primus = Primus.createServer(function connection(spark) {

    }, { port: 3000, transformer: 'websockets'  });    
    primus.use('emitter', Emitter);
    var str = primus.library();
    return file('primus.js', str, { src: true  }).pipe(gulp.dest('lib'));
})

primus

Primus is a simple abstraction around real-time frameworks. It allows you to easily switch between different frameworks without any code changes.

MIT
Latest version published 1 year ago

Package Health Score

65 / 100
Full package analysis