You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/06/20 03:03:47 UTC
[07/51] [abbrv] [partial] incubator-weex-site git commit: Site
updated: 2017-06-20 11:03:26
http://git-wip-us.apache.org/repos/asf/incubator-weex-site/blob/55f57f79/cn/references/modules/websocket.html
----------------------------------------------------------------------
diff --git a/cn/references/modules/websocket.html b/cn/references/modules/websocket.html
deleted file mode 100644
index 8c99d6d..0000000
--- a/cn/references/modules/websocket.html
+++ /dev/null
@@ -1,1503 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <meta charset="utf-8">
-
- <title>WebSocket | Weex</title>
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
- <meta name="description" content="WebSocketv0.12+ SummaryWebSockets 是一种先进的技术, 这使得在用户的 H5/iOS/Android 和一个服务器之间打开一个的交互式通信会话成为可能, 有了这个 API,你可以向服务器发送消息, 并接收事件驱动的响应, 无需轮询服务器的响应 注意: iOS和h5提供 WebSockets 的 protocol 默认实现,安卓使用需要提供自定义 adapter 实现">
-<meta property="og:type" content="website">
-<meta property="og:title" content="WebSocket">
-<meta property="og:url" content="https://weex-project.io/cn/references/modules/websocket.html">
-<meta property="og:site_name" content="Weex">
-<meta property="og:description" content="WebSocketv0.12+ SummaryWebSockets 是一种先进的技术, 这使得在用户的 H5/iOS/Android 和一个服务器之间打开一个的交互式通信会话成为可能, 有了这个 API,你可以向服务器发送消息, 并接收事件驱动的响应, 无需轮询服务器的响应 注意: iOS和h5提供 WebSockets 的 protocol 默认实现,安卓使用需要提供自定义 adapter 实现">
-<meta property="og:updated_time" content="2017-06-14T04:08:17.000Z">
-<meta name="twitter:card" content="summary">
-<meta name="twitter:title" content="WebSocket">
-<meta name="twitter:description" content="WebSocketv0.12+ SummaryWebSockets 是一种先进的技术, 这使得在用户的 H5/iOS/Android 和一个服务器之间打开一个的交互式通信会话成为可能, 有了这个 API,你可以向服务器发送消息, 并接收事件驱动的响应, 无需轮询服务器的响应 注意: iOS和h5提供 WebSockets 的 protocol 默认实现,安卓使用需要提供自定义 adapter 实现">
-
- <link rel="alternate" href="/atom.xml" title="Weex" type="application/atom+xml">
-
-
- <link rel="icon" href="//gw.alicdn.com/tps/TB1XNqxPXXXXXcSXVXXXXXXXXXX-64-63.png">
-
-
- <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
-
- <link rel="stylesheet" href="/css/style.css">
- <link rel="stylesheet" href="/css/swiper.min.css">
-</head>
-
-<body id="references" class="lang-cn">
-
- <script>
- window.PAGE_TYPE = "references";
- window.ROOT = "/"
- </script>
- <header id="header">
- <div class="navbar">
- <a id="logo" href="/cn/">
- <img src="//img.alicdn.com/tps/TB1zBLaPXXXXXXeXXXXXXXXXXXX-121-59.svg" />
- </a>
- <div class="main-nav">
- <ul class="links">
- <li><a href="/cn/guide">教程</a></li>
- <li><a href="/cn/references">手册</a></li>
- <li class="dropdown">
- <a href="javascript:;">参考</a>
- <ul class="dropdown-menu subnav">
- <li>
- <a href="/cn/faq.html">FAQ</a>
- </li>
- <li>
- <a href="/cn/releasenote.html">版本说明</a>
- </li>
- </ul>
- </li>
- <li class="dropdown">
- <a href="javascript:;">工具和服务</a>
- <ul class="dropdown-menu subnav">
- <li>
- <a href="/cn/playground.html">Playground</a>
- </li>
- <li>
- <a href="/cn/guide/tools/toolkit.html">Weex-toolkit</a>
- </li>
- <li>
- <a href="http://dotwe.org" target="_blank">Code Snippets</a>
- </li>
- <li>
- <a href="https://market.dotwe.org" target="_blank">Market</a>
- </li>
- </ul>
- </li>
- </ul>
- <ul class="info">
- <li><a href="https://github.com/apache/incubator-weex/" target="_blank"><span class="btn-github iconfont icon-github"></span></a></li>
- </ul>
- <ul class="tools">
- <li>
- <div class="search">
- <form id="search-form" class="search-form"> <!-- 搜索框相关 -->
- <input type="text" id="search-input-header" name="q" results="0" class="form-control search-input" autocomplete="off" autocorrect="off"/>
- <span class="iconfont icon-search"></span>
- </form>
- <div class="results-panel">
- </div>
-</div>
- </li>
- <li>
- <div class="dropdown select-lang">
- <a href="javascript:;" class="dropdown-toggle">
- Language
- <span class="caret"></span>
- </a>
- <ul class="dropdown-menu pick-lang">
- <li>
- <a href="/references/modules/websocket.html" data-lang="en">English</a>
- </li>
- <li>
- <a href="/cn/references/modules/websocket.html" data-lang="zh-cn">中文</a>
- </li>
- </ul>
- </div>
- </li>
- <!--<li></li>-->
- </ul>
- </div>
- </div>
- <div id="mobile-nav">
- <a id="logo" href="/cn/">
- <img src="//img.alicdn.com/tps/TB1zBLaPXXXXXXeXXXXXXXXXXXX-121-59.svg" />
- </a>
- <a class="btn-menu"><span class="iconfont icon-nav"></span></a>
- </div>
-</header>
-
- <div id="sidebar" class="">
- <div class="sidebar-menu">
-
- <div class="search">
- <form id="search-form" class="search-form"> <!-- 搜索框相关 -->
- <input type="text" id="search-input-sidebar" name="q" results="0" class="form-control search-input" autocomplete="off" autocorrect="off"/>
- <span class="iconfont icon-search"></span>
- </form>
- <div class="results-panel">
- </div>
-</div>
-
-
-<div class="doc-nav-version">
- <select class="versionBtn" stype="/cn/references">
-
- <option value="2v" selected>v2.x</option>
- <option value="1v">v1.x</option>
-
- </select>
-</div>
-<div class="summary">
- <h2 class="part-title">
-
- 手册
-
- </h2>
- <ul class="doc-summary">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/index.html" class="sidebar-link ">通用特性</a></h3>
-
- <ul class="chapter">
-
- <li>
- <a href="/cn/references/ios-apis.html" class="sidebar-link ">iOS APIs</a>
- </li>
-
- <li>
- <a href="/cn/references/android-apis.html" class="sidebar-link ">Android APIs</a>
- </li>
-
- <li>
- <a href="/cn/references/jsfm-apis.html" class="sidebar-link ">JS Framework APIs</a>
- </li>
-
- <li>
- <a href="/cn/v-0.10/references/bubble.html" class="sidebar-link ">事件冒泡</a>
- </li>
-
- <li>
- <a href="/cn/references/downgrade.html" class="sidebar-link ">降级方案</a>
- </li>
-
- <li>
- <a href="/cn/references/bubble.html" class="sidebar-link ">事件冒泡</a>
- </li>
-
- <li>
- <a href="/cn/references/html5-apis.html" class="sidebar-link ">HTML5 APIs</a>
- </li>
-
- <li>
- <a href="/cn/references/common-style.html" class="sidebar-link ">通用样式</a>
- </li>
-
- <li>
- <a href="/cn/references/text-style.html" class="sidebar-link ">文本样式</a>
- </li>
-
- <li>
- <a href="/cn/references/color-names.html" class="sidebar-link ">颜色名称列表</a>
- </li>
-
- <li>
- <a href="/cn/references/gesture.html" class="sidebar-link ">手势</a>
- </li>
-
- <li>
- <a href="/cn/references/path.html" class="sidebar-link ">Path (英)</a>
- </li>
-
- </ul>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/components/index.html" class="sidebar-link ">内建组件</a></h3>
-
- <ul class="chapter">
-
- <li>
- <a href="/cn/references/components/a.html" class="sidebar-link "><a></a>
- </li>
-
- <li>
- <a href="/cn/references/components/slider.html" class="sidebar-link "><slider></a>
- </li>
-
- <li>
- <a href="/cn/references/components/indicator.html" class="sidebar-link "><indicator></a>
- </li>
-
- <li>
- <a href="/cn/references/components/switch.html" class="sidebar-link "><switch></a>
- </li>
-
- <li>
- <a href="/cn/references/components/text.html" class="sidebar-link "><text></a>
- </li>
-
- <li>
- <a href="/cn/references/components/textarea.html" class="sidebar-link "><textarea></a>
- </li>
-
- <li>
- <a href="/cn/references/components/video.html" class="sidebar-link "><video></a>
- </li>
-
- <li>
- <a href="/cn/references/components/web.html" class="sidebar-link "><web></a>
- </li>
-
- <li>
- <a href="/cn/references/components/div.html" class="sidebar-link "><div></a>
- </li>
-
- <li>
- <a href="/cn/references/components/image.html" class="sidebar-link "><image></a>
- </li>
-
- <li>
- <a href="/cn/references/components/input.html" class="sidebar-link "><input></a>
- </li>
-
- <li>
- <a href="/cn/references/components/waterfall.html" class="sidebar-link "><waterfall></a>
- </li>
-
- <li>
- <a href="/cn/references/components/list.html" class="sidebar-link "><list></a>
- </li>
-
- <li>
- <a href="/cn/references/components/cell.html" class="sidebar-link "><cell></a>
- </li>
-
- <li>
- <a href="/cn/references/components/loading.html" class="sidebar-link "><loading></a>
- </li>
-
- <li>
- <a href="/cn/references/components/refresh.html" class="sidebar-link "><refresh></a>
- </li>
-
- <li>
- <a href="/cn/references/components/scroller.html" class="sidebar-link "><scroller></a>
- </li>
-
- </ul>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/modules/index.html" class="sidebar-link ">内建模块</a></h3>
-
- <ul class="chapter">
-
- <li>
- <a href="/cn/references/modules/animation.html" class="sidebar-link ">animation</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/picker.html" class="sidebar-link ">picker</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/websocket.html" class="sidebar-link current ">WebSocket</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/clipboard.html" class="sidebar-link ">clipboard</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/dom.html" class="sidebar-link ">dom</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/modal.html" class="sidebar-link ">modal</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/navigator.html" class="sidebar-link ">navigator</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/storage.html" class="sidebar-link ">storage</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/stream.html" class="sidebar-link ">stream</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/webview.html" class="sidebar-link ">webview</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/globalevent.html" class="sidebar-link ">globalEvent</a>
- </li>
-
- </ul>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/unit.html" class="sidebar-link ">CSS 单位</a></h3>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/common-event.html" class="sidebar-link ">通用事件</a></h3>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/native-dom-api.html" class="sidebar-link ">Native DOM APIs</a></h3>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/weex-variable.html" class="sidebar-link ">Weex 实例变量</a></h3>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/web-standards.html" class="sidebar-link ">Web 标准</a></h3>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/js-service/index.html" class="sidebar-link ">JS Service</a></h3>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/vue/index.html" class="sidebar-link ">Vue</a></h3>
-
- <ul class="chapter">
-
- <li>
- <a href="/cn/references/vue/difference-with-web.html" class="sidebar-link ">Vue 2.x 在 Weex 和 Web 中的差异</a>
- </li>
-
- <li>
- <a href="/cn/references/vue/difference-of-vuex.html" class="sidebar-link ">使用 Vuex 和 vue-router</a>
- </li>
-
- </ul>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/advanced/index.html" class="sidebar-link ">高阶知识</a></h3>
-
- <ul class="chapter">
-
- <li>
- <a href="/cn/references/advanced/extend-to-ios.html" class="sidebar-link ">iOS 扩展</a>
- </li>
-
- <li>
- <a href="/cn/references/advanced/extend-to-android.html" class="sidebar-link ">Android 扩展</a>
- </li>
-
- <li>
- <a href="/cn/references/advanced/extend-to-html5.html" class="sidebar-link ">HTML5 扩展</a>
- </li>
-
- <li>
- <a href="/cn/references/advanced/extend-jsfm.html" class="sidebar-link ">拓展 JS framework</a>
- </li>
-
- <li>
- <a href="/cn/references/advanced/integrate-devtool-to-android.html" class="sidebar-link ">集成 Devtools 到 Android</a>
- </li>
-
- <li>
- <a href="/cn/references/advanced/integrate-devtool-to-ios.html" class="sidebar-link ">集成 Devtools 到 iOS</a>
- </li>
-
- </ul>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/platform-difference.html" class="sidebar-link ">Weex 和 Web 平台的差异</a></h3>
-
- <ul class="chapter">
-
- <li>
- <a href="/cn/references/migration/index.html" class="sidebar-link ">迁移</a>
- </li>
-
- <li>
- <a href="/cn/references/migration/migration-from-weex.html" class="sidebar-link ">如何将原有 Weex 项目改造成 Vue 版本</a>
- </li>
-
- <li>
- <a href="/cn/references/migration/difference.html" class="sidebar-link ">Weex 和 Vue 2.x 的语法差异</a>
- </li>
-
- </ul>
-
- </li>
-
-
- </ul>
-</div>
-
- <a class="btn-close-sidebar iconfont icon-close"></a>
- </div>
-</div>
-
- <div class="article-wrapper page-layout">
- <div class="doc-nav">
-
-
-
-<div class="doc-nav-version">
- <select class="versionBtn" stype="/cn/references">
-
- <option value="2v" selected>v2.x</option>
- <option value="1v">v1.x</option>
-
- </select>
-</div>
-<div class="summary">
- <h2 class="part-title">
-
- 手册
-
- </h2>
- <ul class="doc-summary">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/index.html" class="sidebar-link ">通用特性</a></h3>
-
- <ul class="chapter">
-
- <li>
- <a href="/cn/references/ios-apis.html" class="sidebar-link ">iOS APIs</a>
- </li>
-
- <li>
- <a href="/cn/references/android-apis.html" class="sidebar-link ">Android APIs</a>
- </li>
-
- <li>
- <a href="/cn/references/jsfm-apis.html" class="sidebar-link ">JS Framework APIs</a>
- </li>
-
- <li>
- <a href="/cn/v-0.10/references/bubble.html" class="sidebar-link ">事件冒泡</a>
- </li>
-
- <li>
- <a href="/cn/references/downgrade.html" class="sidebar-link ">降级方案</a>
- </li>
-
- <li>
- <a href="/cn/references/bubble.html" class="sidebar-link ">事件冒泡</a>
- </li>
-
- <li>
- <a href="/cn/references/html5-apis.html" class="sidebar-link ">HTML5 APIs</a>
- </li>
-
- <li>
- <a href="/cn/references/common-style.html" class="sidebar-link ">通用样式</a>
- </li>
-
- <li>
- <a href="/cn/references/text-style.html" class="sidebar-link ">文本样式</a>
- </li>
-
- <li>
- <a href="/cn/references/color-names.html" class="sidebar-link ">颜色名称列表</a>
- </li>
-
- <li>
- <a href="/cn/references/gesture.html" class="sidebar-link ">手势</a>
- </li>
-
- <li>
- <a href="/cn/references/path.html" class="sidebar-link ">Path (英)</a>
- </li>
-
- </ul>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/components/index.html" class="sidebar-link ">内建组件</a></h3>
-
- <ul class="chapter">
-
- <li>
- <a href="/cn/references/components/a.html" class="sidebar-link "><a></a>
- </li>
-
- <li>
- <a href="/cn/references/components/slider.html" class="sidebar-link "><slider></a>
- </li>
-
- <li>
- <a href="/cn/references/components/indicator.html" class="sidebar-link "><indicator></a>
- </li>
-
- <li>
- <a href="/cn/references/components/switch.html" class="sidebar-link "><switch></a>
- </li>
-
- <li>
- <a href="/cn/references/components/text.html" class="sidebar-link "><text></a>
- </li>
-
- <li>
- <a href="/cn/references/components/textarea.html" class="sidebar-link "><textarea></a>
- </li>
-
- <li>
- <a href="/cn/references/components/video.html" class="sidebar-link "><video></a>
- </li>
-
- <li>
- <a href="/cn/references/components/web.html" class="sidebar-link "><web></a>
- </li>
-
- <li>
- <a href="/cn/references/components/div.html" class="sidebar-link "><div></a>
- </li>
-
- <li>
- <a href="/cn/references/components/image.html" class="sidebar-link "><image></a>
- </li>
-
- <li>
- <a href="/cn/references/components/input.html" class="sidebar-link "><input></a>
- </li>
-
- <li>
- <a href="/cn/references/components/waterfall.html" class="sidebar-link "><waterfall></a>
- </li>
-
- <li>
- <a href="/cn/references/components/list.html" class="sidebar-link "><list></a>
- </li>
-
- <li>
- <a href="/cn/references/components/cell.html" class="sidebar-link "><cell></a>
- </li>
-
- <li>
- <a href="/cn/references/components/loading.html" class="sidebar-link "><loading></a>
- </li>
-
- <li>
- <a href="/cn/references/components/refresh.html" class="sidebar-link "><refresh></a>
- </li>
-
- <li>
- <a href="/cn/references/components/scroller.html" class="sidebar-link "><scroller></a>
- </li>
-
- </ul>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/modules/index.html" class="sidebar-link ">内建模块</a></h3>
-
- <ul class="chapter">
-
- <li>
- <a href="/cn/references/modules/animation.html" class="sidebar-link ">animation</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/picker.html" class="sidebar-link ">picker</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/websocket.html" class="sidebar-link current ">WebSocket</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/clipboard.html" class="sidebar-link ">clipboard</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/dom.html" class="sidebar-link ">dom</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/modal.html" class="sidebar-link ">modal</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/navigator.html" class="sidebar-link ">navigator</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/storage.html" class="sidebar-link ">storage</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/stream.html" class="sidebar-link ">stream</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/webview.html" class="sidebar-link ">webview</a>
- </li>
-
- <li>
- <a href="/cn/references/modules/globalevent.html" class="sidebar-link ">globalEvent</a>
- </li>
-
- </ul>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/unit.html" class="sidebar-link ">CSS 单位</a></h3>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/common-event.html" class="sidebar-link ">通用事件</a></h3>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/native-dom-api.html" class="sidebar-link ">Native DOM APIs</a></h3>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/weex-variable.html" class="sidebar-link ">Weex 实例变量</a></h3>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/web-standards.html" class="sidebar-link ">Web 标准</a></h3>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/js-service/index.html" class="sidebar-link ">JS Service</a></h3>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/vue/index.html" class="sidebar-link ">Vue</a></h3>
-
- <ul class="chapter">
-
- <li>
- <a href="/cn/references/vue/difference-with-web.html" class="sidebar-link ">Vue 2.x 在 Weex 和 Web 中的差异</a>
- </li>
-
- <li>
- <a href="/cn/references/vue/difference-of-vuex.html" class="sidebar-link ">使用 Vuex 和 vue-router</a>
- </li>
-
- </ul>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/advanced/index.html" class="sidebar-link ">高阶知识</a></h3>
-
- <ul class="chapter">
-
- <li>
- <a href="/cn/references/advanced/extend-to-ios.html" class="sidebar-link ">iOS 扩展</a>
- </li>
-
- <li>
- <a href="/cn/references/advanced/extend-to-android.html" class="sidebar-link ">Android 扩展</a>
- </li>
-
- <li>
- <a href="/cn/references/advanced/extend-to-html5.html" class="sidebar-link ">HTML5 扩展</a>
- </li>
-
- <li>
- <a href="/cn/references/advanced/extend-jsfm.html" class="sidebar-link ">拓展 JS framework</a>
- </li>
-
- <li>
- <a href="/cn/references/advanced/integrate-devtool-to-android.html" class="sidebar-link ">集成 Devtools 到 Android</a>
- </li>
-
- <li>
- <a href="/cn/references/advanced/integrate-devtool-to-ios.html" class="sidebar-link ">集成 Devtools 到 iOS</a>
- </li>
-
- </ul>
-
- </li>
-
- <li>
- <h3 class="chapter-title"><a href="/cn/references/platform-difference.html" class="sidebar-link ">Weex 和 Web 平台的差异</a></h3>
-
- <ul class="chapter">
-
- <li>
- <a href="/cn/references/migration/index.html" class="sidebar-link ">迁移</a>
- </li>
-
- <li>
- <a href="/cn/references/migration/migration-from-weex.html" class="sidebar-link ">如何将原有 Weex 项目改造成 Vue 版本</a>
- </li>
-
- <li>
- <a href="/cn/references/migration/difference.html" class="sidebar-link ">Weex 和 Vue 2.x 的语法差异</a>
- </li>
-
- </ul>
-
- </li>
-
-
- </ul>
-</div>
- </div>
-
-
-<article class="article article-type-references">
- <div class="article-entry" itemprop="articleBody">
- <header class="article-header">
-
-
- <h1 class="article-title" itemprop="name">
- WebSocket
- </h1>
-
-
- <time class="article-date" datetime="2017-06-14T04:08:17.000Z">Updated time: 14/06/2017</time>
-</header>
- <h1 id="WebSocket" class="article-heading"><a href="#WebSocket" class="headerlink" title="WebSocket"></a>WebSocket<a class="article-anchor" href="#WebSocket" aria-hidden="true"></a></h1><p><span class="weex-version">v0.12+</span></p>
-<h2 id="Summary" class="article-heading"><a href="#Summary" class="headerlink" title="Summary"></a>Summary<a class="article-anchor" href="#Summary" aria-hidden="true"></a></h2><p>WebSockets 是一种先进的技术, 这使得在用户的 H5/iOS/Android 和一个服务器之间打开一个的交互式通信会话成为可能, 有了这个 API,你可以向服务器发送消息, 并接收事件驱动的响应, 无需轮询服务器的响应</p>
-<h2 id="注意:" class="article-heading"><a href="#注意:" class="headerlink" title="注意:"></a><strong>注意:</strong><a class="article-anchor" href="#注意:" aria-hidden="true"></a></h2><ul>
-<li>iOS和h5提供 WebSockets 的 protocol 默认实现,安卓使用需要提供自定义 adapter 实现,source: <ul>
-<li><a href="https://github.com/apache/incubator-weex/blob/dev/android/commons/src/main/java/com/alibaba/weex/commons/adapter/DefaultWebSocketAdapter.java" target="_blank" rel="external">DefaultWebSocketAdapter.java</a>;</li>
-<li><a href="https://github.com/apache/incubator-weex/blob/dev/android/commons/src/main/java/com/alibaba/weex/commons/adapter/DefaultWebSocketAdapterFactory.java" target="_blank" rel="external">DefaultWebSocketAdapterFactory.java</a>;</li>
-<li>集成例子参考weex <a href="https://github.com/apache/incubator-weex/tree/dev/android/playground" target="_blank" rel="external">playground</a></li>
-</ul>
-</li>
-</ul>
-<h2 id="API" class="article-heading"><a href="#API" class="headerlink" title="API"></a>API<a class="article-anchor" href="#API" aria-hidden="true"></a></h2><h3 id="WebSocket-url-protocol" class="article-heading"><a href="#WebSocket-url-protocol" class="headerlink" title="WebSocket(url, protocol)"></a><code>WebSocket(url, protocol)</code><a class="article-anchor" href="#WebSocket-url-protocol" aria-hidden="true"></a></h3><p>创建 WebSockets,并连接服务器</p>
-<h4 id="Arguments" class="article-heading"><a href="#Arguments" class="headerlink" title="Arguments"></a>Arguments<a class="article-anchor" href="#Arguments" aria-hidden="true"></a></h4><ul>
-<li><code>url {string}</code>: 表示要连接的 URL;</li>
-<li><code>protocol {string}</code>: WebSockets 协议</li>
-</ul>
-<h3 id="send-data" class="article-heading"><a href="#send-data" class="headerlink" title="send(data)"></a><code>send(data)</code><a class="article-anchor" href="#send-data" aria-hidden="true"></a></h3><p>通过WebSocket连接向服务器发送数据</p>
-<h4 id="Arguments-1" class="article-heading"><a href="#Arguments-1" class="headerlink" title="Arguments"></a>Arguments<a class="article-anchor" href="#Arguments-1" aria-hidden="true"></a></h4><ul>
-<li><code>data{string}</code>:要发送到服务器的数据</li>
-</ul>
-<h3 id="close-code-reason" class="article-heading"><a href="#close-code-reason" class="headerlink" title="close(code,reason)"></a><code>close(code,reason)</code><a class="article-anchor" href="#close-code-reason" aria-hidden="true"></a></h3><p>关闭 WebSockets 的链接</p>
-<h4 id="Arguments-2" class="article-heading"><a href="#Arguments-2" class="headerlink" title="Arguments"></a>Arguments<a class="article-anchor" href="#Arguments-2" aria-hidden="true"></a></h4><ul>
-<li><code>code {number}</code>: 关闭连接的状态号.</li>
-<li><code>reason {string}</code>: 关闭的原因</li>
-</ul>
-<h3 id="onopen-options" class="article-heading"><a href="#onopen-options" class="headerlink" title="onopen(options)"></a><code>onopen(options)</code><a class="article-anchor" href="#onopen-options" aria-hidden="true"></a></h3><p>链接打开的监听</p>
-<h4 id="Arguments-3" class="article-heading"><a href="#Arguments-3" class="headerlink" title="Arguments"></a>Arguments<a class="article-anchor" href="#Arguments-3" aria-hidden="true"></a></h4><ul>
-<li><code>options {object}</code>: 一个空的对象</li>
-</ul>
-<h3 id="onmessage-options" class="article-heading"><a href="#onmessage-options" class="headerlink" title="onmessage(options)"></a><code>onmessage(options)</code><a class="article-anchor" href="#onmessage-options" aria-hidden="true"></a></h3><p>消息事件的监听器</p>
-<h4 id="Arguments-4" class="article-heading"><a href="#Arguments-4" class="headerlink" title="Arguments"></a>Arguments<a class="article-anchor" href="#Arguments-4" aria-hidden="true"></a></h4><ul>
-<li><code>options {object}</code>: 服务器返回的消息对象<ul>
-<li><code>data {string}</code>: 监听器接收的到的消息</li>
-</ul>
-</li>
-</ul>
-<h3 id="onclose-options" class="article-heading"><a href="#onclose-options" class="headerlink" title="onclose(options)"></a><code>onclose(options)</code><a class="article-anchor" href="#onclose-options" aria-hidden="true"></a></h3><p>关闭事件的监听器</p>
-<h4 id="Arguments-5" class="article-heading"><a href="#Arguments-5" class="headerlink" title="Arguments"></a>Arguments<a class="article-anchor" href="#Arguments-5" aria-hidden="true"></a></h4><ul>
-<li><code>options {object}</code>: 监听器接收到的对象<ul>
-<li><code>code {number}</code>: 服务器返回关闭的状态码</li>
-<li><code>reason {string}</code>: 服务器返回的关闭原因</li>
-<li><code>wasClean {boolen}</code>: 是否完全关闭.</li>
-</ul>
-</li>
-</ul>
-<h3 id="onerror-options" class="article-heading"><a href="#onerror-options" class="headerlink" title="onerror(options)"></a><code>onerror(options)</code><a class="article-anchor" href="#onerror-options" aria-hidden="true"></a></h3><p>错误事件的监听器</p>
-<h4 id="Arguments-6" class="article-heading"><a href="#Arguments-6" class="headerlink" title="Arguments"></a>Arguments<a class="article-anchor" href="#Arguments-6" aria-hidden="true"></a></h4><ul>
-<li><code>options {object}</code>: 错误信息的事件<ul>
-<li><code>data {string}</code>: 监听器接收到的信息</li>
-</ul>
-</li>
-</ul>
-<h3 id="Example" class="article-heading"><a href="#Example" class="headerlink" title="Example"></a>Example<a class="article-anchor" href="#Example" aria-hidden="true"></a></h3><figure class="highlight html"><table><tr><td class="code"><pre><div class="line"><span class="tag"><<span class="name">template</span>></span></div><div class="line"> <span class="tag"><<span class="name">scroller</span>></span></div><div class="line"> <span class="tag"><<span class="name">div</span>></span></div><div class="line"> <span class="tag"><<span class="name">div</span> <span class="attr">style</span>=<span class="string">"background-color: #286090"</span>></span></div><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">class</span>=<span class="string">"title"</span> <span class="attr">style</span>=<span class="string">"height: 80px ;padding: 20px;color: white"</span>></span>websocket<span class="tag"></<span class
="name">text</span>></span></div><div class="line"> <span class="tag"></<span class="name">div</span>></span></div><div class="line"> <span class="tag"><<span class="name">input</span> <span class="attr">type</span>=<span class="string">"text"</span> <span class="attr">placeholder</span>=<span class="string">"please input message to send"</span> <span class="attr">class</span>=<span class="string">"input"</span> <span class="attr">autofocus</span>=<span class="string">"false"</span> <span class="attr">value</span>=<span class="string">""</span> @<span class="attr">change</span>=<span class="string">"onchange"</span> @<span class="attr">input</span>=<span class="string">"oninput"</span> <span class="attr">ref</span>=<span class="string">"input"</span>/></span></div><div class="line"> <span class="tag"><<span class="name">div</span> <span class="attr">style</span>=<span class="string">"flex-direction: row; justify-content: center;"</span>></span></d
iv><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">class</span>=<span class="string">"button"</span> @<span class="attr">click</span>=<span class="string">"connect"</span>></span>connect<span class="tag"></<span class="name">text</span>></span></div><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">class</span>=<span class="string">"button"</span> @<span class="attr">click</span>=<span class="string">"send"</span>></span>send<span class="tag"></<span class="name">text</span>></span></div><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">class</span>=<span class="string">"button"</span> @<span class="attr">click</span>=<span class="string">"close"</span>></span>close<span class="tag"></<span class="name">text</span>></span></div><div class="line"> <span class="tag"></<span class="name">div</span>></span
></div><div class="line"></div><div class="line"> <span class="tag"><<span class="name">div</span> <span class="attr">style</span>=<span class="string">"background-color: lightgray"</span>></span></div><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">class</span>=<span class="string">"title"</span> <span class="attr">style</span>=<span class="string">"height: 80px ;padding: 20px;color: black"</span>></span>method = send<span class="tag"></<span class="name">text</span>></span></div><div class="line"> <span class="tag"></<span class="name">div</span>></span></div><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">style</span>=<span class="string">"color: black;height: 80px"</span>></span>{{sendinfo}}<span class="tag"></<span class="name">text</span>></span></div><div class="line"></div><div class="line"></div><div class="line">
<span class="tag"><<span class="name">div</span> <span class="attr">style</span>=<span class="string">"background-color: lightgray"</span>></span></div><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">class</span>=<span class="string">"title"</span> <span class="attr">style</span>=<span class="string">"height: 80px ;padding: 20px;color: black"</span>></span>method = onopen<span class="tag"></<span class="name">text</span>></span></div><div class="line"> <span class="tag"></<span class="name">div</span>></span></div><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">style</span>=<span class="string">"color: black;height: 80px"</span>></span>{{onopeninfo}}<span class="tag"></<span class="name">text</span>></span></div><div class="line"></div><div class="line"> <span class="tag"><<span class="name">div</span> <span class="attr">st
yle</span>=<span class="string">"background-color: lightgray"</span>></span></div><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">class</span>=<span class="string">"title"</span> <span class="attr">style</span>=<span class="string">"height: 80px ;padding: 20px;color: black"</span>></span>method = onmessage<span class="tag"></<span class="name">text</span>></span></div><div class="line"> <span class="tag"></<span class="name">div</span>></span></div><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">style</span>=<span class="string">"color: black;height: 400px"</span>></span>{{onmessage}}<span class="tag"></<span class="name">text</span>></span></div><div class="line"></div><div class="line"> <span class="tag"><<span class="name">div</span> <span class="attr">style</span>=<span class="string">"background-color: lightgray"</span>>
;</span></div><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">class</span>=<span class="string">"title"</span> <span class="attr">style</span>=<span class="string">"height: 80px ;padding: 20px;color: black"</span>></span>method = onclose<span class="tag"></<span class="name">text</span>></span></div><div class="line"> <span class="tag"></<span class="name">div</span>></span></div><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">style</span>=<span class="string">"color: black;height: 80px"</span>></span>{{oncloseinfo}}<span class="tag"></<span class="name">text</span>></span></div><div class="line"></div><div class="line"> <span class="tag"><<span class="name">div</span> <span class="attr">style</span>=<span class="string">"background-color: lightgray"</span>></span></div><div class="line"> <span class="tag"><<span clas
s="name">text</span> <span class="attr">class</span>=<span class="string">"title"</span> <span class="attr">style</span>=<span class="string">"height: 80px ;padding: 20px;color: black"</span>></span>method = onerror<span class="tag"></<span class="name">text</span>></span></div><div class="line"> <span class="tag"></<span class="name">div</span>></span></div><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">style</span>=<span class="string">"color: black;height: 80px"</span>></span>{{onerrorinfo}}<span class="tag"></<span class="name">text</span>></span></div><div class="line"></div><div class="line"> <span class="tag"><<span class="name">div</span> <span class="attr">style</span>=<span class="string">"background-color: lightgray"</span>></span></div><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">class</span>=<span class="string
">"title"</span> <span class="attr">style</span>=<span class="string">"height: 80px ;padding: 20px;color: black"</span>></span>method = close<span class="tag"></<span class="name">text</span>></span></div><div class="line"> <span class="tag"></<span class="name">div</span>></span></div><div class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">style</span>=<span class="string">"color: black;height: 80px"</span>></span>{{closeinfo}}<span class="tag"></<span class="name">text</span>></span></div><div class="line"></div><div class="line"> <span class="tag"></<span class="name">div</span>></span></div><div class="line"></div><div class="line"> <span class="tag"></<span class="name">scroller</span>></span></div><div class="line"><span class="tag"></<span class="name">template</span>></span></div><div class="line"></div><div class="line"><span class="tag"><<span class="name">styl
e</span> <span class="attr">scoped</span>></span><span class="css"></span></div><div class="line"> <span class="selector-class">.input</span> {</div><div class="line"> <span class="attribute">font-size</span>: <span class="number">40px</span>;</div><div class="line"> <span class="attribute">height</span>: <span class="number">80px</span>;</div><div class="line"> <span class="attribute">width</span>: <span class="number">600px</span>;</div><div class="line"> }</div><div class="line"> <span class="selector-class">.button</span> {</div><div class="line"> <span class="attribute">font-size</span>: <span class="number">36px</span>;</div><div class="line"> <span class="attribute">width</span>: <span class="number">150px</span>;</div><div class="line"> <span class="attribute">color</span>: <span class="number">#41B883</span>;</div><div class="line"> <span class="attribute">text-align</span>: center;</div><div class="line"> <span class="attribute"
>padding-top</span>: <span class="number">25px</span>;</div><div class="line"> <span class="attribute">padding-bottom</span>: <span class="number">25px</span>;</div><div class="line"> <span class="attribute">border-width</span>: <span class="number">2px</span>;</div><div class="line"> <span class="attribute">border-style</span>: solid;</div><div class="line"> <span class="attribute">margin-right</span>: <span class="number">20px</span>;</div><div class="line"> <span class="attribute">border-color</span>: <span class="built_in">rgb</span>(162, 217, 192);</div><div class="line"> <span class="attribute">background-color</span>: <span class="built_in">rgba</span>(162, 217, 192, 0.2);</div><div class="line"> }</div><div class="line"><span class="tag"></<span class="name">style</span>></span></div><div class="line"></div><div class="line"></div><div class="line"><span class="tag"><<span class="name">script</span>></span><span class="javascript"></span><
/div><div class="line"> <span class="keyword">var</span> websocket = weex.requireModule(<span class="string">'webSocket'</span>)</div><div class="line"> <span class="keyword">export</span> <span class="keyword">default</span> {</div><div class="line"> data () {</div><div class="line"> <span class="keyword">return</span> {</div><div class="line"> <span class="attr">connectinfo</span>: <span class="string">''</span>,</div><div class="line"> <span class="attr">sendinfo</span>: <span class="string">''</span>,</div><div class="line"> <span class="attr">onopeninfo</span>: <span class="string">''</span>,</div><div class="line"> <span class="attr">onmessage</span>: <span class="string">''</span>,</div><div class="line"> <span class="attr">oncloseinfo</span>: <span class="string">''</span>,</div><div class="line"> <span class="attr">onerrorinfo</span>: <span class="string">''</span>,</div><div class="line"> <span class
="attr">closeinfo</span>: <span class="string">''</span>,</div><div class="line"> <span class="attr">txtInput</span>:<span class="string">''</span>,</div><div class="line"> <span class="attr">navBarHeight</span>: <span class="number">88</span>,</div><div class="line"> <span class="attr">title</span>: <span class="string">'Navigator'</span>,</div><div class="line"> <span class="attr">dir</span>: <span class="string">'examples'</span>,</div><div class="line"> <span class="attr">baseURL</span>: <span class="string">''</span></div><div class="line"> }</div><div class="line"> },</div><div class="line"> <span class="attr">methods</span>: {</div><div class="line"> <span class="attr">connect</span>:<span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>{</div><div class="line"> websocket.WebSocket(<span class="string">'ws://echo.websocket.org'</span>,<span class="string">
''</span>);</div><div class="line"> <span class="keyword">var</span> self = <span class="keyword">this</span>;</div><div class="line"> self.onopeninfo = <span class="string">'connecting...'</span></div><div class="line"> websocket.onopen = <span class="function"><span class="keyword">function</span>(<span class="params">e</span>)</span></div><div class="line"> {</div><div class="line"> self.onopeninfo = <span class="string">'websocket open'</span>;</div><div class="line"> }</div><div class="line"> websocket.onmessage = <span class="function"><span class="keyword">function</span>(<span class="params">e</span>)</span></div><div class="line"> {</div><div class="line"> self.onmessage = e.data;</div><div class="line"> }</div><div class="line"> websocket.onerror = <span class="function"><span class="keyword">function</span>(<span class="params">e</span>)</span></div><div class="line">
{</div><div class="line"> self.onerrorinfo = e.data;</div><div class="line"> }</div><div class="line"> websocket.onclose = <span class="function"><span class="keyword">function</span>(<span class="params">e</span>)</span></div><div class="line"> {</div><div class="line"> self.onopeninfo = <span class="string">''</span>;</div><div class="line"> self.onerrorinfo = e.code;</div><div class="line"> }</div><div class="line"> },</div><div class="line"> <span class="attr">send</span>:<span class="function"><span class="keyword">function</span>(<span class="params">e</span>) </span>{</div><div class="line"> <span class="keyword">var</span> input = <span class="keyword">this</span>.$refs.input;</div><div class="line"> input.blur();</div><div class="line"> websocket.send(<span class="keyword">this</span>.txtInput);</div><div class="line"> <span class="keyword">this</spa
n>.sendinfo = <span class="keyword">this</span>.txtInput;</div><div class="line"> },</div><div class="line"> <span class="attr">oninput</span>: <span class="function"><span class="keyword">function</span>(<span class="params">event</span>) </span>{</div><div class="line"> <span class="keyword">this</span>.txtInput = event.value;</div><div class="line"> },</div><div class="line"> <span class="attr">close</span>:<span class="function"><span class="keyword">function</span>(<span class="params">e</span>) </span>{</div><div class="line"> websocket.close();</div><div class="line"> },</div><div class="line"> },</div><div class="line"> }</div><div class="line"><span class="tag"></<span class="name">script</span>></span></div></pre></td></tr></table></figure>
-<p><a href="http://dotwe.org/vue/6d8bdfe66f24fda1a2dc6158b0182573" target="_blank" rel="external">Have a try</a></p>
-
- </div>
-
-</article>
-</div>
-
- <footer id="footer">
- <div class="row clearfix">
- <div class="dropdown select-lang">
- <a href="javascript:;" class="dropdown-toggle">
- Language
- <span class="caret"></span>
- </a>
- <ul class="dropdown-menu pick-lang">
- <li>
- <a href="/references/modules/websocket.html" data-lang="en">English</a>
- </li>
- <li>
- <a href="/cn/references/modules/websocket.html" data-lang="zh-cn">中文</a>
- </li>
- </ul>
- </div>
- </div>
- <div class="disclaimer">
- <div><img src="//gw.alicdn.com/tfs/TB1pTBZQFXXXXX9XXXXXXXXXXXX-794-280.png" width="200px" alt="Apache Incubator"></div>
- <div><span class="title">Disclaimer:</span> Apache Weex is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.</div>
- <br/>
- </div>
- <hr>
- <div class="row">
- <p> <img src="//gw.alicdn.com/tfs/TB1bg8SQFXXXXcHXXXXXXXXXXXX-85-170.png" height="50px" alt="Apache"><span>Copyright(c) 2017 The Apache Software Foundation. Licensed under the </span> <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a></p>
- </div>
- <div class="row clearfix">
- <div></div>
- </div>
-</footer>
- <div style="display: none;">
- <script src="//s95.cnzz.com/z_stat.php?id=1261496509&web_id=1261496509" language="JavaScript"></script>
-</div>
-
- <script src="/js/reqwest.js"></script>
- <script src="/js/common.js"></script>
-</body>
-</html>