npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yunba-javascript-sdk

v2.0.3

Published

javascript sdk for yunba.io services

Downloads

7

Readme

Build Status Coverage Status

Yunba JavaScript SDK over Socket.IO

文档 http://yunba.io/docs2/Javascript_SDK/

依赖

socket.io-1.3.5.min.js

说明

推荐使用 connect_by_customid() :

为了保存 离线消息、已订阅的频道和别名 等信息,我们推荐使用 connect_by_customid() 进行连接,connect_by_customid() 使用特定的会话 ID 进行连接,连接后的会话状态会与上次连接保持一致。

connect_by_customid 官网文档链接

使用 connect() 连接:

在浏览器支持并开启 cookie 的情况下,会自动生成一个 uid 作为 customid 并保存到 cookie 中然后进行 connect_by_customid 连接,若不支持或没开启 cookie 则只会进行普通的 connect 连接。

普通 connect() 连接兼容旧版本接口,并无法保存会话状态。

connect 官网文档链接

connect() 中的 uid 构成方法:

uid_ + 当前时间的时间戳 + 10000以内随机数

publish 相关操作时 messageId 构成方法:

publish、publish2、publish_to_alias、publish2_to_alias 操作时若不指定 messageId 时则会自动生成 messageId。

messageId 是一个64位数字转化成的字符串

高41位当前时间的时间戳 + 低23位随机数

浏览器支持

IE 7以下版本支持

IE7 以下版本会报错对象不支持 "stringify" 属性或方法,在导入 socket.io.js 前导入 json2.js 即可解决。

https://github.com/douglascrockford/JSON-js

<!--[if lte IE 7]>
<script  type='text/javascript' src='/javascripts/json2.js'></script>
<![endif]-->

试用例子

examples/yunba_javascript_demo_customid.html 演示了如何使用 Yunba JavaScript SDK。试用前先确保 Appkey 正确:

	var yunba = new Yunba({appkey:'52fcc04c4dc903d66d6f8f92'});

** 替换为您的 Appkey **

然后用浏览器打开即可。

Test

npm install
npm run test