3.1.15 • Published 11 years ago

nodevent v3.1.15

Weekly downloads
148
License
-
Repository
github
Last release
11 years ago

NoDevent

A bridge for posting server events to a redis pubsub and having it go out to browsers.

This is useful for notifying browser js clients about events happening on the server such as private messages, new discussion posts, or interesting resque jobs.

Quick* Start (Rails)

1) Install Node.js

2) Install and start NoDevent with npm:

npm install NoDevent
npm start NoDevent

3) Add the following to the gemspec

gem 'nodevent'

nodevent expects a $redis global to exist and be a connect to your redis server.

4) Send some events

ActiveRecord Models:

class SomeModel < ActiveRecord::Base
  include NoDevent
end

#Emit a model instance as a json object to that model
SomeModel.first.emit('the_event', SomeModel.first)

#Or just emit a message
NoDevent::Emitter.emit('the_room', 'the_event', 'the_message')

#You can also use an active record model as the room.
NoDevent::Emitter.emit(SomeModel.first, 'the_event', 'the_message')

3) Connect and listen for events in the browser Load the socket.io layer:

<script src="http://YOURHOST/socket.io/socket.io.js" type="text/javascript">

Connect to a room

var io = io.connect('http://YOURHOST/');
$(function() {
  io.on('connect', function(socket) {
    io.emit('join', '<%= SomeModel.first.room %>');
  });
});

Listen for events

$(function(){
  io.on("the_event",function(data){
    /* Do stuff with data */
  });
})

Thats it!

*Ok, so it's not that quick.

More Detail

To finish later

3.1.15

11 years ago

3.1.14

11 years ago

3.1.13

11 years ago

3.1.12

11 years ago

3.1.11

12 years ago

3.1.10

12 years ago

3.1.9

12 years ago

3.1.8

12 years ago

3.1.7

12 years ago

3.1.6

12 years ago

3.1.5

12 years ago

3.1.4

12 years ago

3.1.3

12 years ago

3.1.2

12 years ago

3.1.1

12 years ago

3.1.0

12 years ago

3.0.3

12 years ago

3.0.2

12 years ago

3.0.1

12 years ago

3.0.0

12 years ago

2.2.0

12 years ago

2.1.0

12 years ago

2.0.2

12 years ago

2.0.1

12 years ago

2.0.0

12 years ago

1.2.0

12 years ago

1.1.4

12 years ago

1.1.3

12 years ago

1.1.2

12 years ago

1.1.1

12 years ago

1.1.0

12 years ago

1.0.3

12 years ago

1.0.2

12 years ago

1.0.1

12 years ago

1.0.0

12 years ago

0.2.0

12 years ago