flotype-bridge 0.1.0.beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +6 -0
- data/Rakefile +24 -0
- data/doc/Bridge.html +954 -0
- data/doc/Bridge/Callback.html +495 -0
- data/doc/Bridge/CallbackRef.html +343 -0
- data/doc/Bridge/Conn.html +409 -0
- data/doc/Bridge/Core.html +762 -0
- data/doc/Bridge/LocalRef.html +509 -0
- data/doc/Bridge/Ref.html +647 -0
- data/doc/Bridge/Service.html +135 -0
- data/doc/Bridge/Sys.html +278 -0
- data/doc/Bridge/Util.html +746 -0
- data/doc/_index.html +202 -0
- data/doc/class_list.html +47 -0
- data/doc/classes/Bridge.html +263 -0
- data/doc/classes/Bridge.src/M000001.html +24 -0
- data/doc/classes/Bridge.src/M000002.html +18 -0
- data/doc/classes/Bridge.src/M000003.html +18 -0
- data/doc/classes/Bridge.src/M000004.html +20 -0
- data/doc/classes/Bridge.src/M000005.html +26 -0
- data/doc/classes/Bridge.src/M000006.html +22 -0
- data/doc/classes/Bridge.src/M000007.html +18 -0
- data/doc/classes/Bridge.src/M000008.html +18 -0
- data/doc/created.rid +1 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +55 -0
- data/doc/css/style.css +322 -0
- data/doc/file.README.html +71 -0
- data/doc/file_list.html +49 -0
- data/doc/files/lib/bridge_rb.html +108 -0
- data/doc/fr_class_index.html +27 -0
- data/doc/fr_file_index.html +27 -0
- data/doc/fr_method_index.html +34 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +71 -0
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +16 -0
- data/doc/method_list.html +510 -0
- data/doc/rdoc-style.css +208 -0
- data/doc/top-level-namespace.html +105 -0
- data/examples/chat/chat_client.rb +41 -0
- data/examples/chat/chat_server.rb +24 -0
- data/examples/pong/pong.rb +29 -0
- data/flotype-bridge.gemspec +24 -0
- data/lib/bb/callback.rb +33 -0
- data/lib/bb/conn.rb +31 -0
- data/lib/bb/core.rb +109 -0
- data/lib/bb/localref.rb +37 -0
- data/lib/bb/ref.rb +49 -0
- data/lib/bb/svc.rb +7 -0
- data/lib/bb/sys.rb +17 -0
- data/lib/bb/util.rb +93 -0
- data/lib/bb/version.rb +3 -0
- data/lib/bridge.rb +130 -0
- data/rakelib/package.rake +4 -0
- data/rakelib/test.rake +8 -0
- data/tests/bb_test_helper.rb +3 -0
- data/tests/test_serialize.rb +4 -0
- metadata +196 -0
data/doc/rdoc-style.css
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
|
2
|
+
body {
|
3
|
+
font-family: Verdana,Arial,Helvetica,sans-serif;
|
4
|
+
font-size: 90%;
|
5
|
+
margin: 0;
|
6
|
+
margin-left: 40px;
|
7
|
+
padding: 0;
|
8
|
+
background: white;
|
9
|
+
}
|
10
|
+
|
11
|
+
h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
|
12
|
+
h1 { font-size: 150%; }
|
13
|
+
h2,h3,h4 { margin-top: 1em; }
|
14
|
+
|
15
|
+
a { background: #eef; color: #039; text-decoration: none; }
|
16
|
+
a:hover { background: #039; color: #eef; }
|
17
|
+
|
18
|
+
/* Override the base stylesheet's Anchor inside a table cell */
|
19
|
+
td > a {
|
20
|
+
background: transparent;
|
21
|
+
color: #039;
|
22
|
+
text-decoration: none;
|
23
|
+
}
|
24
|
+
|
25
|
+
/* and inside a section title */
|
26
|
+
.section-title > a {
|
27
|
+
background: transparent;
|
28
|
+
color: #eee;
|
29
|
+
text-decoration: none;
|
30
|
+
}
|
31
|
+
|
32
|
+
/* === Structural elements =================================== */
|
33
|
+
|
34
|
+
div#index {
|
35
|
+
margin: 0;
|
36
|
+
margin-left: -40px;
|
37
|
+
padding: 0;
|
38
|
+
font-size: 90%;
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
div#index a {
|
43
|
+
margin-left: 0.7em;
|
44
|
+
}
|
45
|
+
|
46
|
+
div#index .section-bar {
|
47
|
+
margin-left: 0px;
|
48
|
+
padding-left: 0.7em;
|
49
|
+
background: #ccc;
|
50
|
+
font-size: small;
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
div#classHeader, div#fileHeader {
|
55
|
+
width: auto;
|
56
|
+
color: white;
|
57
|
+
padding: 0.5em 1.5em 0.5em 1.5em;
|
58
|
+
margin: 0;
|
59
|
+
margin-left: -40px;
|
60
|
+
border-bottom: 3px solid #006;
|
61
|
+
}
|
62
|
+
|
63
|
+
div#classHeader a, div#fileHeader a {
|
64
|
+
background: inherit;
|
65
|
+
color: white;
|
66
|
+
}
|
67
|
+
|
68
|
+
div#classHeader td, div#fileHeader td {
|
69
|
+
background: inherit;
|
70
|
+
color: white;
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
div#fileHeader {
|
75
|
+
background: #057;
|
76
|
+
}
|
77
|
+
|
78
|
+
div#classHeader {
|
79
|
+
background: #048;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
.class-name-in-header {
|
84
|
+
font-size: 180%;
|
85
|
+
font-weight: bold;
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
div#bodyContent {
|
90
|
+
padding: 0 1.5em 0 1.5em;
|
91
|
+
}
|
92
|
+
|
93
|
+
div#description {
|
94
|
+
padding: 0.5em 1.5em;
|
95
|
+
background: #efefef;
|
96
|
+
border: 1px dotted #999;
|
97
|
+
}
|
98
|
+
|
99
|
+
div#description h1,h2,h3,h4,h5,h6 {
|
100
|
+
color: #125;;
|
101
|
+
background: transparent;
|
102
|
+
}
|
103
|
+
|
104
|
+
div#validator-badges {
|
105
|
+
text-align: center;
|
106
|
+
}
|
107
|
+
div#validator-badges img { border: 0; }
|
108
|
+
|
109
|
+
div#copyright {
|
110
|
+
color: #333;
|
111
|
+
background: #efefef;
|
112
|
+
font: 0.75em sans-serif;
|
113
|
+
margin-top: 5em;
|
114
|
+
margin-bottom: 0;
|
115
|
+
padding: 0.5em 2em;
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
/* === Classes =================================== */
|
120
|
+
|
121
|
+
table.header-table {
|
122
|
+
color: white;
|
123
|
+
font-size: small;
|
124
|
+
}
|
125
|
+
|
126
|
+
.type-note {
|
127
|
+
font-size: small;
|
128
|
+
color: #DEDEDE;
|
129
|
+
}
|
130
|
+
|
131
|
+
.xxsection-bar {
|
132
|
+
background: #eee;
|
133
|
+
color: #333;
|
134
|
+
padding: 3px;
|
135
|
+
}
|
136
|
+
|
137
|
+
.section-bar {
|
138
|
+
color: #333;
|
139
|
+
border-bottom: 1px solid #999;
|
140
|
+
margin-left: -20px;
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
.section-title {
|
145
|
+
background: #79a;
|
146
|
+
color: #eee;
|
147
|
+
padding: 3px;
|
148
|
+
margin-top: 2em;
|
149
|
+
margin-left: -30px;
|
150
|
+
border: 1px solid #999;
|
151
|
+
}
|
152
|
+
|
153
|
+
.top-aligned-row { vertical-align: top }
|
154
|
+
.bottom-aligned-row { vertical-align: bottom }
|
155
|
+
|
156
|
+
/* --- Context section classes ----------------------- */
|
157
|
+
|
158
|
+
.context-row { }
|
159
|
+
.context-item-name { font-family: monospace; font-weight: bold; color: black; }
|
160
|
+
.context-item-value { font-size: small; color: #448; }
|
161
|
+
.context-item-desc { color: #333; padding-left: 2em; }
|
162
|
+
|
163
|
+
/* --- Method classes -------------------------- */
|
164
|
+
.method-detail {
|
165
|
+
background: #efefef;
|
166
|
+
padding: 0;
|
167
|
+
margin-top: 0.5em;
|
168
|
+
margin-bottom: 1em;
|
169
|
+
border: 1px dotted #ccc;
|
170
|
+
}
|
171
|
+
.method-heading {
|
172
|
+
color: black;
|
173
|
+
background: #ccc;
|
174
|
+
border-bottom: 1px solid #666;
|
175
|
+
padding: 0.2em 0.5em 0 0.5em;
|
176
|
+
}
|
177
|
+
.method-signature { color: black; background: inherit; }
|
178
|
+
.method-name { font-weight: bold; }
|
179
|
+
.method-args { font-style: italic; }
|
180
|
+
.method-description { padding: 0 0.5em 0 0.5em; }
|
181
|
+
|
182
|
+
/* --- Source code sections -------------------- */
|
183
|
+
|
184
|
+
a.source-toggle { font-size: 90%; }
|
185
|
+
div.method-source-code {
|
186
|
+
background: #262626;
|
187
|
+
color: #ffdead;
|
188
|
+
margin: 1em;
|
189
|
+
padding: 0.5em;
|
190
|
+
border: 1px dashed #999;
|
191
|
+
overflow: hidden;
|
192
|
+
}
|
193
|
+
|
194
|
+
div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
195
|
+
|
196
|
+
/* --- Ruby keyword styles --------------------- */
|
197
|
+
|
198
|
+
.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
|
199
|
+
|
200
|
+
.ruby-constant { color: #7fffd4; background: transparent; }
|
201
|
+
.ruby-keyword { color: #00ffff; background: transparent; }
|
202
|
+
.ruby-ivar { color: #eedd82; background: transparent; }
|
203
|
+
.ruby-operator { color: #00ffee; background: transparent; }
|
204
|
+
.ruby-identifier { color: #ffdead; background: transparent; }
|
205
|
+
.ruby-node { color: #ffa07a; background: transparent; }
|
206
|
+
.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
|
207
|
+
.ruby-regexp { color: #ffa07a; background: transparent; }
|
208
|
+
.ruby-value { color: #7fffd4; background: transparent; }
|
@@ -0,0 +1,105 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Top Level Namespace
|
8
|
+
|
9
|
+
— Documentation by YARD 0.7.5
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
relpath = '';
|
19
|
+
if (relpath != '') relpath += '/';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
25
|
+
|
26
|
+
|
27
|
+
</head>
|
28
|
+
<body>
|
29
|
+
<script type="text/javascript" charset="utf-8">
|
30
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
31
|
+
</script>
|
32
|
+
|
33
|
+
<div id="header">
|
34
|
+
<div id="menu">
|
35
|
+
|
36
|
+
<a href="_index.html">Index</a> »
|
37
|
+
|
38
|
+
|
39
|
+
<span class="title">Top Level Namespace</span>
|
40
|
+
|
41
|
+
|
42
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<div id="search">
|
46
|
+
|
47
|
+
<a id="class_list_link" href="#">Class List</a>
|
48
|
+
|
49
|
+
<a id="method_list_link" href="#">Method List</a>
|
50
|
+
|
51
|
+
<a id="file_list_link" href="#">File List</a>
|
52
|
+
|
53
|
+
</div>
|
54
|
+
<div class="clear"></div>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<iframe id="search_frame"></iframe>
|
58
|
+
|
59
|
+
<div id="content"><h1>Top Level Namespace
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
</h1>
|
64
|
+
|
65
|
+
<dl class="box">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
</dl>
|
75
|
+
<div class="clear"></div>
|
76
|
+
|
77
|
+
<h2>Defined Under Namespace</h2>
|
78
|
+
<p class="children">
|
79
|
+
|
80
|
+
|
81
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Bridge.html" title="Bridge (module)">Bridge</a></span>
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
</p>
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
</div>
|
97
|
+
|
98
|
+
<div id="footer">
|
99
|
+
Generated on Sun Mar 4 11:14:11 2012 by
|
100
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
101
|
+
0.7.5 (ruby-1.8.7).
|
102
|
+
</div>
|
103
|
+
|
104
|
+
</body>
|
105
|
+
</html>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'bridge'
|
2
|
+
require 'eventmachine'
|
3
|
+
|
4
|
+
module MsgHandler
|
5
|
+
include Bridge::Service
|
6
|
+
def self.msg(name, message)
|
7
|
+
puts(name + ': ' + message)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class LobbyHandler
|
12
|
+
include Bridge::Service
|
13
|
+
def initialize(name)
|
14
|
+
@name = name
|
15
|
+
@lobby = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(channel)
|
19
|
+
@lobby = channel
|
20
|
+
self.send('Hello, world.')
|
21
|
+
end
|
22
|
+
|
23
|
+
def send(message)
|
24
|
+
@lobby.msg(@name, message)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
start_client = lambda {
|
29
|
+
lobby = LobbyHandler.new('Vedant')
|
30
|
+
chat = Bridge::get_service('chatserver')
|
31
|
+
puts 'sending a join.'
|
32
|
+
chat.join('lobby', MsgHandler, lobby)
|
33
|
+
}
|
34
|
+
|
35
|
+
EM::run do
|
36
|
+
Bridge::initialize({ 'api_key' => 'abcdefgh',
|
37
|
+
'host' => 'localhost',
|
38
|
+
'port' => 8090,
|
39
|
+
'reconnect' => false })
|
40
|
+
Bridge::ready(start_client)
|
41
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'bridge'
|
2
|
+
|
3
|
+
module ChatServer
|
4
|
+
def self.join(name, handler, callback)
|
5
|
+
puts("Got join request for #{name}.")
|
6
|
+
Bridge::join_channel('lobby', handler, callback)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
start_server = lambda do
|
11
|
+
puts("start_server called (from chatserver.rb)")
|
12
|
+
on_client_join = lambda do |lobby|
|
13
|
+
puts("Client joined lobby (#{lobby}).")
|
14
|
+
end
|
15
|
+
Bridge::publish_service('chatserver', ChatServer, on_client_join)
|
16
|
+
end
|
17
|
+
|
18
|
+
EM::run do
|
19
|
+
Bridge::initialize({ 'api_key' => 'abcdefgh',
|
20
|
+
'host' => 'localhost',
|
21
|
+
'port' => 8090,
|
22
|
+
'reconnect' => false })
|
23
|
+
Bridge::ready(start_server)
|
24
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'eventmachine'
|
2
|
+
require 'bridge'
|
3
|
+
|
4
|
+
|
5
|
+
module EchoModule
|
6
|
+
def self.echo name, msg
|
7
|
+
puts(name + ": " + msg)
|
8
|
+
end
|
9
|
+
def self.pong msg, count, fun
|
10
|
+
if msg == "ping"
|
11
|
+
puts :pong
|
12
|
+
fun.call(count + 1)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
EventMachine::run {
|
18
|
+
Bridge::initialize({ :reconnect => false,
|
19
|
+
:host => '127.0.0.1',
|
20
|
+
:port => 8090})
|
21
|
+
Bridge::ready lambda {
|
22
|
+
puts 'Connected.'
|
23
|
+
}
|
24
|
+
puts 'enqueued ready func'
|
25
|
+
Bridge::publish_service("pong", EchoModule)
|
26
|
+
puts 'published pong service'
|
27
|
+
Bridge::join_channel("duuuude", EchoModule, lambda {puts "Duuude."})
|
28
|
+
puts 'joined channel'
|
29
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path('../lib/bb/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'flotype-bridge'
|
5
|
+
s.version = Bridge::VERSION
|
6
|
+
s.homepage = 'http://flotype.com'
|
7
|
+
|
8
|
+
s.authors = ["Flotype"]
|
9
|
+
s.email = ["team@flotype.com"]
|
10
|
+
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
|
13
|
+
s.add_dependency 'eventmachine', '>= 0.12.0'
|
14
|
+
s.add_dependency 'json', ">= 1.5.0"
|
15
|
+
|
16
|
+
s.add_development_dependency 'yard', '>= 0.7.2'
|
17
|
+
s.add_development_dependency 'rake-compiler', '>= 0.7.9'
|
18
|
+
|
19
|
+
s.summary = 'Ruby/Bridge library'
|
20
|
+
s.description = "Ruby client for Flotype Bridge."
|
21
|
+
|
22
|
+
s.rdoc_options = ["--title", "Bridge", "--main", "README.md", "-x", "lib/bb/version"]
|
23
|
+
s.extra_rdoc_files = ["README.md"] + `git ls-files -- docs/*`.split("\n")
|
24
|
+
end
|
data/lib/bb/callback.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Bridge
|
2
|
+
# Wrapper for callbacks passed in as arguments.
|
3
|
+
class Callback
|
4
|
+
def initialize fun
|
5
|
+
@fun = fun
|
6
|
+
end
|
7
|
+
|
8
|
+
def callback *args
|
9
|
+
@fun.call *args
|
10
|
+
end
|
11
|
+
|
12
|
+
def call *args
|
13
|
+
@fun.call(*call)
|
14
|
+
end
|
15
|
+
|
16
|
+
def method atom
|
17
|
+
if atom.to_s == 'callback'
|
18
|
+
@fun
|
19
|
+
else
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def methods bool
|
25
|
+
[:callback]
|
26
|
+
end
|
27
|
+
|
28
|
+
def respond_to? atom
|
29
|
+
atom = atom.to_s
|
30
|
+
atom == 'call' || atom == 'to_json'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|