journeta 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/instant_messenger.rb +0 -0
- data/lib/journeta/journeta_engine.rb +2 -1
- data/lib/journeta/peer_connection.rb +3 -3
- data/lib/journeta/presence_listener.rb +22 -18
- data/lib/journeta/version.rb +1 -1
- data/lib/journeta.rb +1 -0
- metadata +2 -2
File without changes
|
@@ -160,6 +160,7 @@ module Journeta
|
|
160
160
|
# the existing record will be updated and given instance #PeerConnection#stop'd.
|
161
161
|
# This prevents pending outbound data from being accidentally dropped.
|
162
162
|
def register_peer(peer)
|
163
|
+
putsd "Registering peer: #{peer.uuid}"
|
163
164
|
peer_registry.register(peer)
|
164
165
|
end
|
165
166
|
|
@@ -172,4 +173,4 @@ module Journeta
|
|
172
173
|
|
173
174
|
end
|
174
175
|
|
175
|
-
end
|
176
|
+
end
|
@@ -80,9 +80,9 @@ module Journeta
|
|
80
80
|
#
|
81
81
|
# Sorry that this is deceptively complicated. It's a design gotcha! :)
|
82
82
|
putsd "Peer #{uuid} has gone away. Deregistering in the background."
|
83
|
-
Thread.new
|
84
|
-
@engine.unregister_peer(
|
85
|
-
|
83
|
+
Thread.new(self) do |me|
|
84
|
+
@engine.unregister_peer(me)
|
85
|
+
end
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -34,29 +34,33 @@ module Journeta
|
|
34
34
|
loop do
|
35
35
|
# Why 1024? umm.. because it's Thursday!
|
36
36
|
data, meta = socket.recvfrom 1024
|
37
|
-
Thread.new(data)
|
37
|
+
Thread.new(data, meta) do |data, meta|
|
38
38
|
event = YAML.load(data)
|
39
39
|
if event.uuid != @engine.uuid
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
40
|
+
begin
|
41
|
+
m = YAML::load(data)
|
42
|
+
peer = PeerConnection.new @engine
|
43
|
+
# Why is this always [2]? Not sure.. they should have returned a hash instead.
|
44
|
+
peer.ip_address = meta[2]
|
45
|
+
peer.peer_port = m.peer_port
|
46
|
+
peer.uuid = m.uuid
|
47
|
+
peer.version = m.version
|
48
|
+
peer.groups = m.groups
|
49
|
+
peer.created_at = peer.updated_at = Time.now
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
# We should not start the #PeerConnection before registering because
|
52
|
+
# the peer might already be registered. In this case, we'd have wasted a thread,
|
53
|
+
# so we'll let the registry handle startup (if it happens at all.)
|
54
|
+
#
|
55
|
+
# peer.start
|
55
56
|
|
56
|
-
|
57
|
-
|
57
|
+
# TODO validate peer entry is sane before registering it
|
58
|
+
@engine.register_peer peer
|
59
|
+
rescue => e
|
60
|
+
putsd "Error during peer registration: #{e.message}"
|
61
|
+
end
|
58
62
|
end
|
59
|
-
|
63
|
+
end
|
60
64
|
# putsd "Event received!"
|
61
65
|
end
|
62
66
|
ensure
|
data/lib/journeta/version.rb
CHANGED
data/lib/journeta.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: journeta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Preston Lee
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|