命令行工具转 WebSocket 服务 websocketd

码农软件 · 软件分类 · WebSocket开发包 · 2019-04-17 18:43:31

软件介绍

websocketd 是一个很小的命令后工具,可以让你的命令行接口程序封装成可通过 WebSocket 进行访问。

例如这样一个命令行程序 count.sh:

 #!/bin/bash
for COUNT in $(seq 1 10); do
  echo $COUNT
  sleep 1
done

可通过如下命令进行封装:

$ websocketd --port=8080 ./count.sh

然后你可以创建一个网页来测试 count.html:

<!DOCTYPE html>
<pre id="log"></pre>
<script>
  // helper function: log message to screen
  function log(msg) {
    document.getElementById('log').textContent += msg + '\n';
  }

  // setup websocket with callbacks
  var ws = new WebSocket('ws://localhost:8080/');
  ws.onopen = function() {
    log('CONNECT');
  };
  ws.onclose = function() {
    log('DISCONNECT');
  };
  ws.onmessage = function(event) {
    log('MESSAGE: ' + event.data);
  };
</script>

本文地址:https://codercto.com/soft/d/3799.html

Beginning ASP.NET 4 in C# and Vb

Beginning ASP.NET 4 in C# and Vb

Imar Spaanjaars / Wrox / 2010-3-19 / GBP 29.99

This book is for anyone who wants to learn how to build rich and interactive web sites that run on the Microsoft platform. With the knowledge you gain from this book, you create a great foundation to ......一起来看看 《Beginning ASP.NET 4 in C# and Vb》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具