UNPKG

7.2 kBHTMLView Raw
1<html>
2<head>
3</head>
4<body style="background: transparent;">
5 <script src="scripts/docstrap.lib.js"></script>
6 <script src="scripts/lunr.min.js"></script>
7 <script src="scripts/fulltext-search.js"></script>
8
9 <script type="text/x-docstrap-searchdb">
10 {"global.html":{"id":"global.html","title":"Global","body":" Documentation Classes CatSnake Global denygranthistoryinfopublishsubscribe Global Methods deny(channel, client, secret) Deny a client access to a channel Parameters: Name Type Description channel string the channel in which to deny the client from client string the client to deny secret string the secret key associated with this channel grant(channel, client, secret) Grant a client access to a channel Parameters: Name Type Description channel string the channel in which to grant the client access to client string the client to grant access secret string the secret key associated with this channel history(channel, limit, opts) Get message history from a channel. Parameters: Name Type Description channel string the channel to pull history from limit number the ammount of items to pull from history opts object options such as privateKeys Properties Name Type Description privateKey string private key used for getting history from private channels info(channel, data, opts) List channels, get client info. Parameters: Name Type Description channel string the channel to look at data object additional information for request opts object additional options for subscriptions Properties Name Type Description privateKey string private key used for getting info from private channels publish(channel, data, privateKey) Publishes a message to all subscribers Parameters: Name Type Description channel string the channel to publish to data object the object to publish privateKey string optional private key for private channels subscribe(channel, callback, opts) Subscribe to a channel Parameters: Name Type Description channel string the channel to subscribe to callback function new messages are returned here via msg Properties Name Type Description msg object a new payload published to this channel opts object additional options for subscriptions Properties Name Type Description privateKey string private key used for subscribing to private channels noself string subscribe for everything but ignore your own payloads accessToken string used as a key to modify private channels. Not to be confused with privateKey private string make this channel private, clients can only connect if granted access Type Definitions stringify (data) Tries to return a stringified object. Parameters: Name Type Description data object the object to attempt to stringify × Search results Close Documentation generated by JSDoc 3.4.0 on 2016-04-07T21:54:42-04:00 using the DocStrap template. "},"classes.list.html":{"id":"classes.list.html","title":"Classes","body":" Documentation Classes CatSnake Global denygranthistoryinfopublishsubscribe Classes Classes CatSnake × Search results Close Documentation generated by JSDoc 3.4.0 on 2016-04-07T21:54:42-04:00 using the DocStrap template. "},"index.html":{"id":"index.html","title":"Index","body":" Documentation Classes CatSnake Global denygranthistoryinfopublishsubscribe CatSnake JSCatSnake JS - Open source, free to use persistant pubsub for building realtime applications. What is CatSnake JS?CatSnake JS is a PubSub solution that allows realtime communications between clients and devices. With CatSnake you can simply subscribe a device to a channel and any time a JavaScript object is published to that channel your device or client will be notified. The best part is Catsnake is built using WebSockets and MessagePack so it's incredibly fast. Something worth notingCatsnake will soon feature pluggable modules for things like Mapping, IOT and more. In addition we will have libraries for Python and Java, as well as native implementations for mobile development. Stay tuned :) DocsFor detailed documentation visit this link. Quickstart GuideSetupIf you're using npm you can simply require and create a catsnake client. const CatSnake = require('catsnake'); const catsnake = new CatSnake('ws://public.catsnake.io', { commonName: 'A Random Catsnake' });If you're using this without a module builder just go ahead and use the following without the require. CatSnake will already be defined. SubscribeBefore you can start sending messages, you should subscribe to a channel (but you don't have to). Don't worry, it's super easy. CatSnake.subscribe('General', msg =&gt; console.log(msg));PublishNow that you've subscibed to a channel, let's publish a message to all of the other subscribers, and ourselves ofcourse. CatSnake.publish('General', msg =&gt; { message: 'Ahh! Your dog is attacking me! What is it with mail men and dogs anyways?' });Access ControlCatsnake gives you multiple options for access control to a channel. We'll talk about denying access to a channel as well as granting access. Denying a client access to a channel protected by access control is easy CatSnake.deny('General', 'client-123215', 'secretKey');Granting a client access to a channel protected by access control is just as simple. CatSnake.grant('General', 'client-123215', 'secretKey');InfoNice, now let's get info from the channel, this will return information like connected clients, author, etc. CatSnake.info('General');UnsubscribeWell that was easy. Let's go over one last thing, before we get into the more advanced features of jsps. Once you're done pubsubbing you can unsubscribe from the channel. This will leave your client in an offline state but you can later reconnect with the same client id via the subscribe method, we will go over this more in the advanced features below. CatSnake.unsubscribe('General');HistoryWanna get some history? Just put the channel, the limit, and a privateKey if the channel is private. History will be sent back in the subscriber function, you can check the metadata.type for the type of 'history' CatSnake.history('General', limit); × Search results Close Documentation generated by JSDoc 3.4.0 on 2016-04-07T21:54:42-04:00 using the DocStrap template. "},"CatSnake.html":{"id":"CatSnake.html","title":"Class: CatSnake","body":" Documentation Classes CatSnake Global denygranthistoryinfopublishsubscribe Class: CatSnake CatSnake Creates a new CatSnake client. new CatSnake(address, options) Parameters: Name Type Description address string the address of the catsnake server options object options such as common name and others × Search results Close Documentation generated by JSDoc 3.4.0 on 2016-04-07T21:54:42-04:00 using the DocStrap template. "}}
11 </script>
12
13 <script type="text/javascript">
14 $(document).ready(function() {
15 Searcher.init();
16 });
17
18 $(window).on("message", function(msg) {
19 var msgData = msg.originalEvent.data;
20
21 if (msgData.msgid != "docstrap.quicksearch.start") {
22 return;
23 }
24
25 var results = Searcher.search(msgData.searchTerms);
26
27 window.parent.postMessage({"results": results, "msgid": "docstrap.quicksearch.done"}, "*");
28 });
29 </script>
30</body>
31</html>