原创 

WebSocket 模拟库 SockJS即:SockJS-client

分类:    2269人阅读    IT小君  2015-09-03 15:28

git地址:去围观

 SockJS模拟 WebSocket :为websocket的实现提供了多套后备方案,当浏览器不支持websocket时,她可以选择不同的方案实现,并且完全与websocket的特性一样的。

下面是官方的一些简介

SockJS-client

npm versionBuild StatusDependenciesChat Sauce Test Status

SockJS is a browser JavaScript library that provides a WebSocket-like object. SockJS gives you a coherent, cross-browser, Javascript API which creates a low latency, full duplex, cross-domain communication channel between the browser and the web server.

Under the hood SockJS tries to use native WebSockets first. If that fails it can use a variety of browser-specific transport protocols and presents them through WebSocket-like abstractions.

SockJS is intended to work for all modern browsers and in environments which don\'t support the WebSocket protocol -- for example, behind restrictive corporate proxies.

SockJS-client does require a server counterpart:

Philosophy:

  • The API should follow HTML5 Websockets API as closely as possible.
  • All the transports must support cross domain connections out of the box. It\'s possible and recommended to host a SockJS server on a different server than your main web site.
  • There is support for at least one streaming protocol for every major browser.
  • Streaming transports should work cross-domain and should support cookies (for cookie-based sticky sessions).
  • Polling transports are used as a fallback for old browsers and hosts behind restrictive proxies.
  • Connection establishment should be fast and lightweight.
  • No Flash inside (no need to open port 843 - which doesn\'t work through proxies, no need to host \'crossdomain.xml\', no need to wait for 3 seconds in order to detect problems)

Subscribe to SockJS mailing list for discussions and support.

SockJS family:

Work in progress:

Getting Started

SockJS mimics the WebSockets API, but instead of WebSocket there is a SockJS Javascript object.

First, you need to load the SockJS JavaScript library. For example, you can put that in your HTML head:


网页设计开发公司网站模板

html5 svg夜空中星星流星动画场景特效

js+css3抽奖转盘旋转点餐代码

HTML5 Canvas竖直流动线条背景动画特效

html5图标下拉搜索框自动匹配代码

canvas炫酷鼠标移动文字粒子特效

jQuery右端悬浮带返回顶部特效

响应式时尚单品在线商城网站模板

html5 canvas进度条圆环图表统计动画特效

html5 canvas彩色碎片组合球形旋转动画特效

css鼠标跟随文字模糊特效

小众时尚单品在线电子商务网站模板

HTML5数字产品服务公司网站模板

有机水果蔬菜HTML5网站模板

响应式咖啡饮品宣传网站模板

HTML5现代家居装潢公司网站模板

css+js实现的颜色渐变数字时钟动画特效

现代时尚家具公司网站模板

响应式太阳能能源公司网站模板

中小型创意设计服务公司网站模板

 工具推荐 更多»