simple_pusher 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +2 -2
- data/Rakefile +9 -0
- data/lib/simple_pusher/connection.rb +1 -0
- data/lib/simple_pusher/version.rb +1 -1
- data/vendor/assets/javascripts/simple_pusher.coffee +10 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjQxMTcwYzBlZDE1NDg4NjY5MGJiYTE3OGNlZjRhMGJmYTQ0NmU4ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2VlNzhkMTE0MWVlN2IwY2ViNjQ0NDY1OGZjZmI0ZDk4NmQxZTA0Ng==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzQ1YmNhM2YyOTQxZjI2MmZiNmFhN2FjMTEyZjMwYzkwZjU2ZDY2YzBmZjZh
|
10
|
+
MzQxM2Y0NDQ3OTQ1Mzk4ZTMxMWU3MmJlMDM5Yjg0OTNlYzg2NjRlNDM4ZDlk
|
11
|
+
ZWExZDMwNDUxOTU1NWFjNTk3MzkzZjg5NzJkMmZkOThiMmE0NGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWJiMGYyNTQ2NzlmYTdkMDhjNTQ3YjViMmJlMWM2NWIwNjQyY2RjNzU5OTk3
|
14
|
+
MDk0OTIyMmY0MzFmMmJiNTI5YWNkZTcxNGQ1NmI0NWNkZDVlNzhhMjdhMDVh
|
15
|
+
OTMxMzE1MTJkZGYyZjY2MzU0MjI5MGNkNWIxMzlmYjZiOWU4MTg=
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# SimplePusher
|
1
|
+
# SimplePusher [![Gem Version](https://badge.fury.io/rb/simple_pusher@2x.png)](http://badge.fury.io/rb/simple_pusher)
|
2
2
|
|
3
|
-
SimplePusher is a HTML5 websocket powered realtime messaging tool used in Rails project.
|
3
|
+
SimplePusher is a HTML5 websocket powered realtime messaging tool used in Rails / Sintra project.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
data/Rakefile
CHANGED
@@ -1,20 +1,17 @@
|
|
1
1
|
class SimplePusher
|
2
2
|
constructor: (url) ->
|
3
3
|
@websocket = new WebSocket(url)
|
4
|
-
@
|
5
|
-
|
4
|
+
@_callbacks ||= {}
|
5
|
+
@websocket.onmessage = (e) =>
|
6
|
+
data = e.data.split(":")
|
7
|
+
event = data[0]
|
8
|
+
message = data[1..-1].join(":")
|
9
|
+
callback_fn.call(this, message) for callback_fn in @_callbacks[event]
|
6
10
|
|
7
|
-
on: (event_name,
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
else if event_name == 'message'
|
12
|
-
console.log("on message")
|
13
|
-
@websocket.onmessage = (e) ->
|
14
|
-
callback(e.data)
|
15
|
-
else if event_name == 'close'
|
16
|
-
console.log("on close")
|
17
|
-
@websocket.onclose = callback
|
11
|
+
on: (event_name, callback_fn) ->
|
12
|
+
@_callbacks[event_name] = (@_callbacks[event_name] ||= [])
|
13
|
+
@_callbacks[event_name].push(callback_fn)
|
14
|
+
this
|
18
15
|
|
19
16
|
broadcast: (message) ->
|
20
17
|
@websocket.send("broadcast:#{message}")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_pusher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- qichunren
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-websocket
|