UNPKG

8.93 kBHTMLView Raw
1<!DOCTYPE html>
2
3<html lang="en">
4<head>
5 <meta charset="utf-8">
6 <meta name="viewport" content="width=device-width">
7 <title>Documentation Index</title>
8
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
12 <link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
13
14 <link type="text/css" rel="stylesheet" href="styles/site.simplex.css">
15
16</head>
17
18<body>
19
20<div class="navbar navbar-default navbar-fixed-top ">
21<div class="container">
22 <div class="navbar-header">
23 <a class="navbar-brand" href="index.html">Documentation</a>
24 <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
25 <span class="icon-bar"></span>
26 <span class="icon-bar"></span>
27 <span class="icon-bar"></span>
28 </button>
29 </div>
30 <div class="navbar-collapse collapse" id="topNavigation">
31 <ul class="nav navbar-nav">
32
33 <li class="dropdown">
34 <a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
35 <ul class="dropdown-menu ">
36 <li><a href="CatSnake.html">CatSnake</a></li>
37 </ul>
38 </li>
39
40 <li class="dropdown">
41 <a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
42 <ul class="dropdown-menu ">
43 <li><a href="global.html#deny">deny</a></li><li><a href="global.html#grant">grant</a></li><li><a href="global.html#history">history</a></li><li><a href="global.html#info">info</a></li><li><a href="global.html#publish">publish</a></li><li><a href="global.html#subscribe">subscribe</a></li>
44 </ul>
45 </li>
46
47 </ul>
48 <div class="col-sm-3 col-md-3">
49 <form class="navbar-form" role="search">
50 <div class="input-group">
51 <input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
52 <div class="input-group-btn">
53 <button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
54 </div>
55 </div>
56 </form>
57 </div>
58 </div>
59
60</div>
61</div>
62
63
64<div class="container" id="toc-content">
65<div class="row">
66
67
68 <div class="col-md-8">
69
70 <div id="main">
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 <section class="readme-section">
94 <article><h1>CatSnake JS</h1><p>CatSnake JS - Open source, free to use persistant pubsub for building realtime applications.</p>
95<h2>What is CatSnake JS?</h2><p>CatSnake JS is a PubSub solution that allows realtime communications between clients and
96devices. With CatSnake you can simply subscribe a device to a channel and any time
97a JavaScript object is published to that channel your device or client will be notified.</p>
98<p>The best part is Catsnake is built using WebSockets and
99<a href="http://msgpack.org">MessagePack</a> so it's incredibly fast.</p>
100<h2>Something worth noting</h2><p>Catsnake will soon feature pluggable modules for things like Mapping, IOT and more.
101In addition we will have libraries for Python and Java, as well as native implementations for mobile development. Stay tuned :)</p>
102<h2>Docs</h2><p>For detailed documentation <a href="https://rawgit.com/catsnakejs/catsnake-client/master/out/index.html">visit this link.</a></p>
103<h2>Quickstart Guide</h2><h3>Setup</h3><p>If you're using npm you can simply require and create a catsnake client.</p>
104<pre class="prettyprint source lang-javascript"><code>const CatSnake = require('catsnake');
105const catsnake = new CatSnake('ws://public.catsnake.io', {
106 commonName: 'A Random Catsnake'
107});</code></pre><p>If you're using this without a module builder just go ahead and use the following without the require. CatSnake will
108already be defined.</p>
109<h3>Subscribe</h3><p>Before you can start sending messages, you should subscribe to a channel (but you don't have to). Don't worry, it's super easy.</p>
110<pre class="prettyprint source lang-javascript"><code>CatSnake.subscribe('General', msg => console.log(msg));</code></pre><h3>Publish</h3><p>Now that you've subscibed to a channel, let's publish a message to all of the other subscribers, and ourselves ofcourse.</p>
111<pre class="prettyprint source lang-javascript"><code>CatSnake.publish('General', msg => {
112 message: 'Ahh! Your dog is attacking me! What is it with mail men and dogs anyways?'
113});</code></pre><h3>Access Control</h3><p>Catsnake gives you multiple options for access control to a channel. We'll talk
114about denying access to a channel as well as granting access.</p>
115<p>Denying a client access to a channel protected by access control is easy</p>
116<pre class="prettyprint source lang-javascript"><code>CatSnake.deny('General', 'client-123215', 'secretKey');</code></pre><p>Granting a client access to a channel protected by access control is just as simple.</p>
117<pre class="prettyprint source lang-javascript"><code>CatSnake.grant('General', 'client-123215', 'secretKey');</code></pre><h3>Info</h3><p>Nice, now let's get info from the channel, this will return information like connected clients, author, etc.</p>
118<pre class="prettyprint source lang-javascript"><code>CatSnake.info('General');</code></pre><h3>Unsubscribe</h3><p>Well that was easy. Let's go over one last thing, before we get into the more advanced features of jsps.
119Once you're done pubsubbing you can unsubscribe from the channel. This will leave your client in an offline state but
120you can later reconnect with the same client id via the subscribe method, we will go over this more in the advanced
121features below.</p>
122<pre class="prettyprint source lang-javascript"><code>CatSnake.unsubscribe('General');</code></pre><h3>History</h3><p>Wanna get some history? Just put the channel, the limit, and a privateKey if the channel is private.
123History will be sent back in the subscriber function, you can check the metadata.type for the type of 'history'</p>
124<pre class="prettyprint source lang-javascript"><code>CatSnake.history('General', limit);</code></pre></article>
125 </section>
126
127
128
129
130
131
132
133 </div>
134 </div>
135
136 <div class="clearfix"></div>
137
138
139 <div class="col-md-3">
140 <div id="toc" class="col-md-3 hidden-xs hidden-sm hidden-md"></div>
141 </div>
142
143
144</div>
145</div>
146
147<div class="modal fade" id="searchResults">
148 <div class="modal-dialog">
149 <div class="modal-content">
150 <div class="modal-header">
151 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
152 <h4 class="modal-title">Search results</h4>
153 </div>
154 <div class="modal-body"></div>
155 <div class="modal-footer">
156 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
157 </div>
158 </div><!-- /.modal-content -->
159 </div><!-- /.modal-dialog -->
160</div>
161
162<footer>
163
164
165<span class="jsdoc-message">
166 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a>
167
168 on 2016-04-07T21:54:42-04:00
169
170 using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
171</span>
172</footer>
173
174<script src="scripts/docstrap.lib.js"></script>
175<script src="scripts/toc.js"></script>
176<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
177
178<script>
179$( function () {
180 $( "[id*='$']" ).each( function () {
181 var $this = $( this );
182
183 $this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
184 } );
185
186 $( ".tutorial-section pre, .readme-section pre" ).each( function () {
187 var $this = $( this );
188
189 var example = $this.find( "code" );
190 exampleText = example.html();
191 var lang = /{@lang (.*?)}/.exec( exampleText );
192 if ( lang && lang[1] ) {
193 exampleText = exampleText.replace( lang[0], "" );
194 example.html( exampleText );
195 lang = lang[1];
196 } else {
197 var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
198 lang = langClassMatch ? langClassMatch[1] : "javascript";
199 }
200
201 if ( lang ) {
202
203 $this
204 .addClass( "sunlight-highlight-" + lang )
205 .addClass( "linenums" )
206 .html( example.html() );
207
208 }
209 } );
210
211 Sunlight.highlightAll( {
212 lineNumbers : false,
213 showMenu : true,
214 enableDoclinks : true
215 } );
216
217 $.catchAnchorLinks( {
218 navbarOffset: 10
219 } );
220 $( "#toc" ).toc( {
221 anchorName : function ( i, heading, prefix ) {
222 var id = $( heading ).attr( "id" );
223 return id && id.replace(/\~/g, '-inner-').replace(/\./g, '-static-') || ( prefix + i );
224 },
225 selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
226 showAndHide : false,
227 smoothScrolling: true
228 } );
229
230 $( "#main span[id^='toc']" ).addClass( "toc-shim" );
231 $( '.dropdown-toggle' ).dropdown();
232
233 $( "table" ).each( function () {
234 var $this = $( this );
235 $this.addClass('table');
236 } );
237
238} );
239</script>
240
241
242
243<!--Navigation and Symbol Display-->
244
245
246<!--Google Analytics-->
247
248
249<script type="text/javascript">
250 $(document).ready(function() {
251 SearcherDisplay.init();
252 });
253</script>
254
255</body>
256</html>
\No newline at end of file