Skip to content

particlebanana/kthxbye-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

A Node.js polling engine for use with the Kthxbye gem

Uses Socket.io with Node.js to poll job queues in Redis and update the UI with a job's status.

Uses the PUBLISH/SUBSCRIBE functionality of Redis to subscribe to job queues.

Requires

Usage

Simple example function for use in client:

function openSocket(job_id) {
  // Connect to socket.io
  var socket = new io.Socket('localhost', {port:8081}) 
  if(socket.connect()) {
    socket.on('message', function(data) {
      try {
        var status = JSON.parse(data)
      } catch (SyntaxError) {
        return false;
      }

      if(status.id != parseInt(job_id)) return false;

      if(status.status == 'job.failed') {
        failed()
      } else if(status.status == 'job.completed') {
        succeeded()
      } else if(status.status == 'job.started') {
        active()
      } else {
        alert('Unknown option! ' + status.status)
      }
      return false;
    })
  }
}

About

A Node.js polling engine behind the Kthxbye gem.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published