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

pomeloGlobalChannel

v4.0.3

Published

- es6 语法 - 兼容 pomelo2.x 系列 - 内置 redis使用 - 发送消息给某一个或多个玩家 - 发送消息给指定的channelName - 发送消息给指定 sid 和 channelName - 发送消息给用户列表中指定sid的用户

Downloads

5

Readme

使用说明

  • es6 语法
  • 兼容 pomelo2.x 系列
  • 内置 redis使用
  • 发送消息给某一个或多个玩家
  • 发送消息给指定的channelName
  • 发送消息给指定 sid 和 channelName
  • 发送消息给用户列表中指定sid的用户

pomeloGlobalChannel

pomelo 分布式服务器通讯 原址:https://github.com/NetEase/pomelo-globalchannel-plugin

##Installation

npm install pomeloGlobalChannel

##Usage

var globalChannel = require('pomeloGlobalChannel');

app.use(globalChannel, {GlobalChannel: {
  url : 'redis://127.0.0.1:6379', 
  db: 5      // optinal, from 0 to 15 with default redis configure
}});

API

Table of Contents

GlobalChannelService

Global channel service. GlobalChannelService is created by globalChannel component which is a default component of pomelo enabled by app.set('globalChannelConfig', {...}) and global channel service would be accessed by app.get('globalChannelService').

Parameters

  • app
  • opts

constructor

构造函数

Parameters

  • app any pomelo instance
  • opts Object 参数列表

pushMessageForUid

发送消息给指定服务器 中的某一些人

Parameters

  • route String route string
  • msg Object 消息内容
  • uids Array userId array
  • serverType String frontend server type
  • frontServerId String frontend server Id

Returns Array send message fail userList

pushMessageByUidArr

群发消息给玩家

Parameters

  • uidArr (String | Array) 要发送的玩家列表
  • route String 消息号
  • msg String 消息内容
  • frontServerId (String | null) 指定的前端服务器Id, 默认不指定 (optional, default null)

Returns Array send message fail userList

pushMessage

Send message by global channel. 发送消息给指定 channelName 的所有玩家

Parameters

  • serverType String frontend server type
  • route String route string
  • msg Object message would be sent to clients
  • channelName String channel name

getMembersByChannelName

Get members by channel name. 获取指定 channelName 和 服务器类型的成员

Parameters

  • serverType String frontend server type string
  • channelName String channel name

getMembersBySid

Get members by frontend server id. 获取指定服务器和channelName 的玩家列表

Parameters

  • channelName String channel name
  • frontId String frontend server id

getSidsByUid

获得指定玩家在所在的服务器

Parameters

  • uid 要查找的 玩家id

Returns Array

getSidsByUidArr

获取指定玩家的服务器列表

Parameters

  • uidArr 要查找的玩家列表

Returns Object

destroyChannel

Destroy a global channel.

Parameters

  • channelName String global channel name

add

添加一个玩家 到指定channelName Add a member into channel.

Parameters

  • uid String user id
  • sid String frontend server id
  • channelName (String | Array) 指定的 channelName (optional, default null)

Returns number is add: 1 add success, 0 fail

leave

Remove user from channel. 移除一个玩家

Parameters

##Notice

Global channel use redis as a default persistent storage, you can change it with your own implementation. 自定义管理

var globalChannel = require('pomeloGlobalChannel');
var mysqlGlobalChannelManager = require('./mysqlGlobalChannelManager');

app.use(globalChannel, {globalChannel: {
  url : 'redis://127.0.0.1:6379', 
  channelManager: mysqlGlobalChannelManager
}});