socket.io-emitter 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +27 -9
- data/lib/socket.io/emitter.rb +3 -3
- data/lib/socket.io/emitter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20c7ad7c5bf64297f833e433feff914d1ce62c2d
|
4
|
+
data.tar.gz: 6c18218cf9ad4ab872eff0612b9b1436496bca1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23ac834cd52c6fa0a8f97bd3af6387a98f590028e943c3cd6cfdddcfa241600502e2eca7f489500e760f657602c55cd9f5c215d3517ed299b75d9cf7f420cd0d
|
7
|
+
data.tar.gz: d8efc036e436fcc81fbdd2e6e0666a55cacc6d160a6c3c8f3fa7ca167127eca1b95b793fb466ec92840d6591c520c44017d71222ab3f97d1b84250dcfe55b9a1
|
data/Readme.md
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
|
2
2
|
# SocketIO::Emitter
|
3
3
|
|
4
|
-
|
4
|
+
A Ruby implementation of [socket.io-emitter](https://github.com/Automattic/socket.io-emitter).
|
5
|
+
|
6
|
+
## How to use
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
require 'socket.io-emitter'
|
10
|
+
|
11
|
+
emitter = SocketIO::Emitter.new
|
12
|
+
emitter.emit('time', DateTime.now.to_s)
|
13
|
+
```
|
5
14
|
|
6
15
|
## Installation
|
7
16
|
|
@@ -17,17 +26,26 @@ Or install it yourself as:
|
|
17
26
|
|
18
27
|
$ gem install socket.io-emitter
|
19
28
|
|
20
|
-
##
|
29
|
+
## API
|
30
|
+
|
31
|
+
### Emitter.new([opts])
|
32
|
+
|
33
|
+
The following options are allowed:
|
34
|
+
|
35
|
+
- key: the name of the key to pub/sub events on as prefix (`socket.io`)
|
36
|
+
- redis: the Instance of [Redis](https://github.com/redis/redis-rb) (`redis://127.0.0.1:6379/0`)
|
37
|
+
|
38
|
+
### Emitter#to(room)
|
39
|
+
|
40
|
+
Specifies a specific room that you want to emit to.
|
41
|
+
|
42
|
+
### Emitter#in(room)
|
21
43
|
|
22
|
-
|
44
|
+
_Alias of `Emitter#to`._
|
23
45
|
|
24
|
-
|
46
|
+
### Emitter#of(namespace)
|
25
47
|
|
26
|
-
|
27
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
28
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
29
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
30
|
-
5. Create a new Pull Request
|
48
|
+
Specifies a specific namespace that you want to emit to.
|
31
49
|
|
32
50
|
## License
|
33
51
|
|
data/lib/socket.io/emitter.rb
CHANGED
@@ -20,14 +20,14 @@ module SocketIO
|
|
20
20
|
def method_missing(name)
|
21
21
|
match = /(?<flag>\S+)\?$/.match(name)
|
22
22
|
unless match.nil?
|
23
|
-
return !!@flags[:flag]
|
23
|
+
return !!@flags[match[:flag].to_sym]
|
24
24
|
end
|
25
25
|
@flags[name.to_sym] = true
|
26
26
|
self
|
27
27
|
end
|
28
28
|
|
29
29
|
def in(room)
|
30
|
-
@rooms << room unless @rooms.
|
30
|
+
@rooms << room unless @rooms.include?(room)
|
31
31
|
self
|
32
32
|
end
|
33
33
|
|
@@ -62,7 +62,7 @@ module SocketIO
|
|
62
62
|
packet[:nsp] = '/'
|
63
63
|
end
|
64
64
|
|
65
|
-
packed = MessagePack.pack([packet,
|
65
|
+
packed = MessagePack.pack([packet, { rooms: @rooms, flags: @flags }])
|
66
66
|
@redis.publish(@key, packed)
|
67
67
|
|
68
68
|
@rooms = []
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socket.io-emitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nulltask
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|