NodeJS client code websocket
var WebSocketClient = require('websocket').client; var client = new WebSocketClient(); client.on('connectFailed', function(error) {
console.log('Connect Error: ' + error.toString());
}); client.on('connect', function(connection) {
console.log('WebSocket Client Connected');
connection.on('error', function(error) {
console.log("Connection Error: " + error.toString());
});
connection.on('close', function() {
console.log('echo-protocol Connection Closed');
});
connection.on('message', function(message) {
if (message.type === 'utf8') {
console.log("Received: '" + message.utf8Data + "'");
}
}); function sendNumber() {
if (connection.connected) {
var number = Math.round(Math.random() * 0xFFFFFF);
connection.sendUTF(number.toString());
setTimeout(sendNumber, 1000);
}
}
sendNumber();
}); client.connect('ws://localhost:8080/', 'echo-protocol');
NodeJS client code websocket的更多相关文章
- OData Client Code Generator
转发. [Tutorial & Sample] How to use OData Client Code Generator to generate client-side proxy cla ...
- C# Socket TCP Server & Client & nodejs client
要调试公司某项目里的一个功能,因为要准备测试环境,趁这个机会重温了一下Socket(全还给老师了 -_-#),做个备份. C# Server static void Main(string[] arg ...
- What's New In Zeebe: Scaling Zeebe, New Client APIs, Faster Requests, Timestamps, NodeJS Client, and Default Topic is Back!
Written by Daniel Meyer on May 16 2018 in the What's New In Zeebe category. Welcome to the first-eve ...
- [转]OData的初步认识 OData v4 Client Code Generator
本文转自:http://www.cnblogs.com/1zhk/p/5356053.html What – OData是什么? OData - Open Data Protocol,是一个设计和使用 ...
- nodejs——js 实现webSocket 兼容移动端
nodejs——js 实现webSocket 兼容移动端 //服务器端 //npm install --save ws const express = require('express'); cons ...
- presto-gateway nodejs client
目前已经有了好几个presto nodejs 的client,为了方便presto-gateway 的连接,修改了一个现有的nodejs client 可以方便的连接presto-gateway 原理 ...
- golang micro client 报错500 {"id":"go.micro.client","code":408,"detail":"call timeout: context deadline exceeded","status":"Request Timeout"}
go micro web端连接services时,第一次访问提示500(broken pipe),排查发现客户端请求services时返回 {"id":"go.micro ...
- NodeJS反向代理websocket
如需转载请标明出处:http://blog.csdn.net/itas109QQ技术交流群:129518033 文章目录NodeJS反向代理websocket@[toc]前言代码相关问题:1.http ...
- websocket client code html
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
随机推荐
- Cordova 6.5 -Android环境搭建笔记
(Vue+Vue-cli+VueRouter+Webpack 构建单页面应用推荐看下面二个 https://lvyongbo.gitbooks.io/vue-loader/content/http:/ ...
- top 常用
top -c 查看进程 同时 shift +m 内存倒序
- go语言常见问题总结
go语言中的goroutine和其它语言中的coroutine有什么相同和不同? coroutine 意味着支持将控制转移到另一个协程的明确手段.也就是说,程序员在确定coroutine何时应该暂停执 ...
- ceph存储集群测试方案
--测试目的 测试ceph集群的读写性能,根据测试数据了解整个ceph集群的性能情况. --测试环境 1.8节点ceph集群环境,1台虚拟机(cpu 8核,内存8G),8k的块大小,时长2小时 2.8 ...
- linux系统转换root权限
有时候我们用普通用户的权限没办法完成有关权限,这时候我们就需要拿到root权限才可以,拿到root权限有两种方式 方式一: su - 或者su 此时就会提示你输入密码,输入密码成功以后就能以root权 ...
- 【webdriver自动化】Python数据驱动工具DDT
一.Python数据驱动工具ddt 1. 安装 ddt pip install ddt DDT是 “Data-Driven Tests”的缩写 资料:http://ddt.readthedocs.i ...
- ecmall 移动端 微信分享
/* 用户判断是否在微信端 */ $this->assign('isWeixin', isWeixin()); //isWeixin() 在系统核心基础类的ecmall.php里定义好了 是微信 ...
- 《ProgrammingHive》阅读笔记-第二章
书本第二章的一些知识点,在cloudera-quickstart-vm-5.8.0-0上进行操作. 配置文件 配置在/etc/hive/conf/hive-site.xml文件里面,采用mysql作为 ...
- JAVA高级篇(三、JVM编译机制、类加载机制)
一.类的加载过程 JVM将类的加载分为3个步骤: 1.装载(Load) 2.链接(Link) 3.初始化(Initialize) 其中 链接(Link)又分3个步骤,如下图所示: 1) 装载:查找并加 ...
- quartz Cron表达式解读
CronTrigger CronTriggers往往比SimpleTrigger更有用,如果您需要基于日历的概念,而非SimpleTrigger完全指定的时间间隔,复发的发射工作的时间表. CronT ...