256 lines
11 KiB
HTML
256 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
|
|
|
<link rel="shortcut icon" href="../img/favicon.ico">
|
|
<title>Cobra - IXWebSocket</title>
|
|
<link href="../css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="../css/font-awesome.min.css" rel="stylesheet">
|
|
<link href="../css/base.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css">
|
|
|
|
<script src="../js/jquery-1.10.2.min.js" defer></script>
|
|
<script src="../js/bootstrap.min.js" defer></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
|
|
<script>hljs.initHighlightingOnLoad();</script>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="navbar fixed-top navbar-expand-lg navbar-dark bg-primary">
|
|
<div class="container">
|
|
<a class="navbar-brand" href="..">IXWebSocket</a>
|
|
<!-- Expander button -->
|
|
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbar-collapse">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
|
|
<!-- Expanded navigation -->
|
|
<div id="navbar-collapse" class="navbar-collapse collapse">
|
|
<!-- Main navigation -->
|
|
<ul class="nav navbar-nav">
|
|
<li class="navitem">
|
|
<a href=".." class="nav-link">Home</a>
|
|
</li>
|
|
<li class="navitem">
|
|
<a href="../CHANGELOG/" class="nav-link">Changelog</a>
|
|
</li>
|
|
<li class="navitem">
|
|
<a href="../build/" class="nav-link">Build</a>
|
|
</li>
|
|
<li class="navitem active">
|
|
<a href="./" class="nav-link">Cobra</a>
|
|
</li>
|
|
<li class="navitem">
|
|
<a href="../design/" class="nav-link">Design</a>
|
|
</li>
|
|
<li class="navitem">
|
|
<a href="../packages/" class="nav-link">Packages</a>
|
|
</li>
|
|
<li class="navitem">
|
|
<a href="../usage/" class="nav-link">Examples</a>
|
|
</li>
|
|
<li class="navitem">
|
|
<a href="../ws/" class="nav-link">Ws</a>
|
|
</li>
|
|
</ul>
|
|
|
|
<ul class="nav navbar-nav ml-auto">
|
|
<li class="nav-item">
|
|
<a href="#" class="nav-link" data-toggle="modal" data-target="#mkdocs_search_modal">
|
|
<i class="fa fa-search"></i> Search
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a rel="prev" href="../build/" class="nav-link">
|
|
<i class="fa fa-arrow-left"></i> Previous
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a rel="next" href="../design/" class="nav-link">
|
|
Next <i class="fa fa-arrow-right"></i>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-md-3"><div class="navbar-light navbar-expand-md bs-sidebar hidden-print affix" role="complementary">
|
|
<div class="navbar-header">
|
|
<button type="button" class="navbar-toggler collapsed" data-toggle="collapse" data-target="#toc-collapse" title="Table of Contents">
|
|
<span class="fa fa-angle-down"></span>
|
|
</button>
|
|
</div>
|
|
|
|
|
|
<div id="toc-collapse" class="navbar-collapse collapse card bg-secondary">
|
|
<ul class="nav flex-column">
|
|
|
|
<li class="nav-item" data-level="2"><a href="#general" class="nav-link">General</a>
|
|
<ul class="nav flex-column">
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div></div>
|
|
<div class="col-md-9" role="main">
|
|
|
|
<h2 id="general">General</h2>
|
|
<p><a href="https://github.com/machinezone/cobra">cobra</a> is a real time messaging server. The <code>ws</code> utility can run a cobra server (named snake), and has client to publish and subscribe to a cobra server.</p>
|
|
<p>Bring up 3 terminals and run a server, a publisher and a subscriber in each one. As you publish data you should see it being received by the subscriber. You can run <code>redis-cli MONITOR</code> too to see how redis is being used.</p>
|
|
<h3 id="server">Server</h3>
|
|
<p>You will need to have a redis server running locally. To run the server:</p>
|
|
<pre><code class="bash">$ cd <ixwebsocket-top-level-folder>/ixsnake/ixsnake
|
|
$ ws snake
|
|
{
|
|
"apps": {
|
|
"FC2F10139A2BAc53BB72D9db967b024f": {
|
|
"roles": {
|
|
"_sub": {
|
|
"secret": "66B1dA3ED5fA074EB5AE84Dd8CE3b5ba"
|
|
},
|
|
"_pub": {
|
|
"secret": "1c04DB8fFe76A4EeFE3E318C72d771db"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
redis host: 127.0.0.1
|
|
redis password:
|
|
redis port: 6379
|
|
</code></pre>
|
|
|
|
<h3 id="publisher">Publisher</h3>
|
|
<pre><code class="bash">$ cd <ixwebsocket-top-level-folder>/ws
|
|
$ ws cobra_publish --appkey FC2F10139A2BAc53BB72D9db967b024f --endpoint ws://127.0.0.1:8008 --rolename _pub --rolesecret 1c04DB8fFe76A4EeFE3E318C72d771db test_channel cobraMetricsSample.json
|
|
[2019-11-27 09:06:12.980] [info] Publisher connected
|
|
[2019-11-27 09:06:12.980] [info] Connection: Upgrade
|
|
[2019-11-27 09:06:12.980] [info] Sec-WebSocket-Accept: zTtQKMKbvwjdivURplYXwCVUCWM=
|
|
[2019-11-27 09:06:12.980] [info] Sec-WebSocket-Extensions: permessage-deflate; server_max_window_bits=15; client_max_window_bits=15
|
|
[2019-11-27 09:06:12.980] [info] Server: ixwebsocket/7.4.0 macos ssl/DarwinSSL zlib 1.2.11
|
|
[2019-11-27 09:06:12.980] [info] Upgrade: websocket
|
|
[2019-11-27 09:06:12.982] [info] Publisher authenticated
|
|
[2019-11-27 09:06:12.982] [info] Published msg 3
|
|
[2019-11-27 09:06:12.982] [info] Published message id 3 acked
|
|
</code></pre>
|
|
|
|
<h3 id="subscriber">Subscriber</h3>
|
|
<pre><code class="bash">$ ws cobra_subscribe --appkey FC2F10139A2BAc53BB72D9db967b024f --endpoint ws://127.0.0.1:8008 --rolename _pub --rolesecret 1c04DB8fFe76A4EeFE3E318C72d771db test_channel
|
|
#messages 0 msg/s 0
|
|
[2019-11-27 09:07:39.341] [info] Subscriber connected
|
|
[2019-11-27 09:07:39.341] [info] Connection: Upgrade
|
|
[2019-11-27 09:07:39.341] [info] Sec-WebSocket-Accept: 9vkQWofz49qMCUlTSptCCwHWm+Q=
|
|
[2019-11-27 09:07:39.341] [info] Sec-WebSocket-Extensions: permessage-deflate; server_max_window_bits=15; client_max_window_bits=15
|
|
[2019-11-27 09:07:39.341] [info] Server: ixwebsocket/7.4.0 macos ssl/DarwinSSL zlib 1.2.11
|
|
[2019-11-27 09:07:39.341] [info] Upgrade: websocket
|
|
[2019-11-27 09:07:39.342] [info] Subscriber authenticated
|
|
[2019-11-27 09:07:39.345] [info] Subscriber: subscribed to channel test_channel
|
|
#messages 0 msg/s 0
|
|
#messages 0 msg/s 0
|
|
#messages 0 msg/s 0
|
|
{"baz":123,"foo":"bar"}
|
|
|
|
#messages 1 msg/s 1
|
|
#messages 1 msg/s 0
|
|
#messages 1 msg/s 0
|
|
{"baz":123,"foo":"bar"}
|
|
|
|
{"baz":123,"foo":"bar"}
|
|
|
|
#messages 3 msg/s 2
|
|
#messages 3 msg/s 0
|
|
{"baz":123,"foo":"bar"}
|
|
|
|
#messages 4 msg/s 1
|
|
^C
|
|
</code></pre></div>
|
|
</div>
|
|
</div>
|
|
|
|
<footer class="col-md-12">
|
|
<hr>
|
|
<p>Documentation built with <a href="https://www.mkdocs.org/">MkDocs</a>.</p>
|
|
</footer>
|
|
<script>
|
|
var base_url = "..",
|
|
shortcuts = {"help": 191, "next": 78, "previous": 80, "search": 83};
|
|
</script>
|
|
<script src="../js/base.js" defer></script>
|
|
<script src="../search/main.js" defer></script>
|
|
|
|
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="dialog" aria-labelledby="searchModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h4 class="modal-title" id="searchModalLabel">Search</h4>
|
|
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p>
|
|
From here you can search these documents. Enter
|
|
your search terms below.
|
|
</p>
|
|
<form>
|
|
<div class="form-group">
|
|
<input type="search" class="form-control" placeholder="Search..." id="mkdocs-search-query" title="Type search term here">
|
|
</div>
|
|
</form>
|
|
<div id="mkdocs-search-results"></div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div><div class="modal" id="mkdocs_keyboard_modal" tabindex="-1" role="dialog" aria-labelledby="keyboardModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h4 class="modal-title" id="keyboardModalLabel">Keyboard Shortcuts</h4>
|
|
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th style="width: 20%;">Keys</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td class="help shortcut"><kbd>?</kbd></td>
|
|
<td>Open this help</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="next shortcut"><kbd>n</kbd></td>
|
|
<td>Next page</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="prev shortcut"><kbd>p</kbd></td>
|
|
<td>Previous page</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="search shortcut"><kbd>s</kbd></td>
|
|
<td>Search</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="modal-footer">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|