-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
219 lines (182 loc) · 13.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="user-scalable=no, width=device-width" />
<title>Remote Control Demo</title>
<link rel="stylesheet" href="style/master.css">
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/hydna/1.0.0/hydna.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" charset="utf-8"></script>
</head>
<body>
<a href="http://www.hydna.com/" title="hydna" class="logo"><img src="images/logo.png"></a>
<div class="reveal">
<div class="slides">
<section>
<h1>Hydna: a scalable real-time platform</h1>
<p>Presentation by Isak Wiström <<a href="mailto:iw@hydna.com">iw@hydna.com</a>></p>
<div class="control-details">
<p>To control this slideshow from your <strong>iOS</strong> or <strong>Android</strong> phone (through Hydna):<br/>
Visit <a href="http://bit.ly/18jEDRL">bit.ly/18jEDRL</a> and enter the following code:</p>
<p class="secret-code"><span id="secret_id">0</span></p>
</div>
<p class="note">Slideshow code courtesy of <a href="http://lab.hakim.se/reveal-js/">reveal.js</a>.</p>
</section>
<section>
<h2>What is Hydna?</h2>
<p>Hydna is a hosted backend into which you can send data and have it instantly appear on other devices.</p>
</section>
<section>
<h2>A hosted ...</h2>
<ul>
<li>No servers to setup/maintain</li>
<li>Get started in seconds</li>
<li>Scalable</li>
<li>Focus on your core business</li>
</ul>
</section>
<section>
<h2>... backend</h2>
<ol>
<li>Transports</li>
<li>Routing</li>
<li>Behaviors</li>
</ol>
</section>
<section>
<h2>1. Transports</h2>
<p>Transports are the different protocols clients can use to communicate with Hydna. The following are currently supported:</p>
<p>WebSockets - Binary TCP - Flash - Comet - HTTP/Push</p>
</section>
<section>
<h2>2. Routing</h2>
<p>Routing is the act of accepting data from a sender and delivering it to the intended recipients. Routing works across transports.</p>
<ul>
<li>Domains (e.g. <code>public.hydna.net</code>).</li>
<li>Channels (e.g. <code>/chat</code> or <code>/user-32</code>)</li>
<li>Modes (<code>r</code>, <code>w</code>, <code>e</code>). Permissions.</li>
</ul>
</section>
<section>
<h2>3. Behaviors</h2>
<p>Behaviors are small snippets of JavaScript that you deploy to Hydna's infrastructure. They are used to instruct Hydna how to behave when clients perform different actions (open channels, emit signals etc).</p>
<p>Authentication, communication with external services, global state etc</p>
</section>
<section>
<h2>What can you do with Hydna?</h2>
<p>Hydna is ideal for building dashboards, activity streams, notification- and chat systems, real-time collaboration, live statistics, remote controls, multiplayer games, and more.</p>
</section>
<section>
<h2>Client libraries</h2>
<p>Client libraries detect and select best available transport.</p>
<p>JavaScript, Node.js, Erlang, Java, Objective-C, C++</p>
<p>Python, PHP, Ruby, Go etc.</p>
</section>
<section>
<section>
<h2>Client libraries - Examples</h2>
<h3>JavaScript</h3>
<div class="code highlight"><pre>
<span class="c1">// open a channel on the domain `public.hydna.net` in read and write mode.</span>
<span class="kd">var</span> <span class="nx">channel</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">HydnaChannel</span><span class="p">(</span><span class="s1">'public.hydna.net/hello-world'</span><span class="p">,</span> <span class="s1">'rw'</span><span class="p">);</span>
<span class="c1">// register an event handler that alerts the data-part of messages when</span>
<span class="c1">// they are received.</span>
<span class="nx">channel</span><span class="p">.</span><span class="nx">onmessage</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">alert</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">data</span><span class="p">);</span>
<span class="p">};</span>
<span class="c1">// send a message immediately when the channel has been opened.</span>
<span class="nx">channel</span><span class="p">.</span><span class="nx">onopen</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="nx">channel</span><span class="p">.</span><span class="nx">send</span><span class="p">(</span><span class="s1">'Hello there!'</span><span class="p">);</span>
<span class="p">};</span></pre></div>
<p class="footer"><span class="navigate-down enabled">Hydna <strong>Push API</strong></a> example</span></p>
</section>
<section>
<p class="header"><span class="navigate-up enabled"><strong>Javascript</strong> example</span></p>
<h2>Push API</h2>
<p>Simple HTTP interface. Limited to sending messages and emitting signals. Does not require a client library. Example using <em>curl</em>:</p>
<div class="code highlight">
<pre>curl --data <span class="s2">"hello world"</span> http://public.hydna.net/hello-push</pre>
</div>
<p class="footer">
<span class="navigate-down enabled"><strong>Python</strong> example</span>
</p>
</section>
<section>
<p class="header"><span class="navigate-up enabled"><strong>Push API</strong> example</span></p>
<h2>Python (push) lib</h2>
<p>Full documentation on <a href="https://github.com/hydna/hydna-python">GitHub</a></p>
<div class="code highlight"><pre><span class="kn">import</span> <span class="nn">hydna</span>
<span class="c1"># send a message</span>
<span class="n">hydna</span><span class="o">.</span><span class="n">push</span><span class="p">(</span><span class="s">'public.hydna.net/hello-push'</span><span class="p">,</span> <span class="s">'test'</span><span class="p">)</span>
<span class="c1"># emit a signal</span>
<span class="n">hydna</span><span class="o">.</span><span class="n">emit</span><span class="p">(</span><span class="s">'public.hydna.net/hello-emit'</span><span class="p">,</span> <span class="s">'test'</span><span class="p">)</span></pre>
</div>
<p class="footer"><span class="navigate-down enabled"><strong>Ruby</strong> example</span></p>
</section>
<section>
<p class="header"><span class="navigate-up enabled"><strong>Python</strong> example</span></p>
<h2>Ruby (push) lib</h2>
<p>Full documentation on <a href="https://github.com/hydna/hydna-ruby">GitHub</a></p>
<div class="code highlight"><pre><span class="kn">require</span> 'hydna'
<span class="c1"># send a message</span>
<span class="n">Hydna</span><span class="o">.</span><span class="n">push</span><span class="p">(</span><span class="s">'public.hydna.net/hello-push'</span><span class="p">,</span> <span class="s">'test'</span><span class="p">)</span>
<span class="c1"># emit a signal</span>
<span class="n">Hydna</span><span class="o">.</span><span class="n">emit</span><span class="p">(</span><span class="s">'public.hydna.net/hello-emit'</span><span class="p">,</span> <span class="s">'test'</span><span class="p">)</span></pre>
</div>
<p class="footer"><span class="navigate-down enabled"><strong>PHP</strong> example</span></p>
</section>
<section>
<p class="header"><span class="navigate-up enabled"><strong>Ruby</strong> example</span></p>
<h2>PHP (push) lib</h2>
<p>Full documentation on <a href="https://github.com/hydna/hydna-php">GitHub</a></p>
<div class="code highlight">
<pre><span class="nb">require</span><span class="p">(</span><span class="s">"hydna-push.php"</span><span class="p">);</span>
<span class="nv">$hydna</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Hydna</span><span class="p">();</span>
<span class="n">try</span> <span class="p">{</span>
<span class="sr">//</span> <span class="nb">send</span> <span class="n">a</span> <span class="n">message</span>
<span class="nv">$hydna</span><span class="o">-></span><span class="nb">push</span><span class="p">(</span><span class="s">"http://public.hydna.net/hello-push"</span><span class="p">,</span> <span class="s">"Hello World!"</span><span class="p">);</span>
<span class="sr">//</span> <span class="n">emit</span> <span class="n">a</span> <span class="n">signal</span>
<span class="nv">$hydna</span><span class="o">-></span><span class="n">emit</span><span class="p">(</span><span class="s">"http://public.hydna.net/hello-emit"</span><span class="p">,</span> <span class="s">"Hello World!"</span><span class="p">);</span>
<span class="p">}</span> <span class="n">catch</span><span class="p">(</span><span class="n">Exception</span> <span class="nv">$e</span><span class="p">) {</span>
<span class="k">print</span> <span class="nv">$e</span><span class="o">-></span><span class="n">getMessage</span><span class="p">();</span>
<span class="p">}</span></pre>
</div>
</section>
</section>
<section>
<h2>Behaviors - Examples</h2>
<h3>Simple authentication</h3>
<div class="highlight"><pre><span class="nx">behavior</span><span class="p">(</span><span class="s1">'/admin'</span><span class="p">,</span> <span class="p">{</span>
<span class="nx">open</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">event</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">event</span><span class="p">.</span><span class="nx">write</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// the client requested to write to the channel. let's examine</span>
<span class="c1">// whether the token matches the secret password.</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">event</span><span class="p">.</span><span class="nx">token</span> <span class="o">!=</span> <span class="s1">'secret password'</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">event</span><span class="p">.</span><span class="nx">deny</span><span class="p">(</span><span class="s1">'Not allowed to write to channel.'</span><span class="p">);</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">event</span><span class="p">.</span><span class="nx">allow</span><span class="p">(</span><span class="s1">'Allowed to write to channel.'</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="c1">// the client did not request to write, we can allow that</span>
<span class="c1">// without looking at the token.</span>
<span class="nx">event</span><span class="p">.</span><span class="nx">allow</span><span class="p">(</span><span class="s1">'Allowed to read from channel.'</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">});</span>
</pre></div>
</section>
<section>
<div class="mark"><img src="images/mark.png" /></div>
<h2>That's it! Now get cracking!</h2>
<p><a href="https://www.hydna.com/demo/">Demo applications</a> / <a href="https://www.hydna.com/documentation/">Documentation</a> / <a href="https://www.hydna.com/documentation/#tutorials">Tutorials</a></p>
<div class="create-account">
<a href="https://www.hydna.com/account/create/" class="button signup">Create your free developer account</a>
</div>
</section>
</div>
</div>
<script src="script/deps/reveal.js"></script>
<script src="script/app.js"></script>
</body>
</html>