open-index/open-npm huggingface dataset:
npm package: @olemop/client-js
Description: 备忘：ws 和 wss 的区别在于 Protocol.strdecode，详看该段的内部注释
Latest version: 0.0.59

备忘：ws 和 wss 的区别在于 Protocol.strdecode，详看该段的内部注释

```javascript
return String.fromCharCode.apply(null, array)
// -===== for ws: DIFF by @olemop/core template build.js/build.js.wss，除协议符，两者就这里不同，实际上，上面就够了 =====-
// let res = ''
// const chunk = 8 * 1024
// for (let i = 0; i < array.length / chunk; i++) {
//   res += String.fromCharCode.apply(null, array.slice(i * chunk, (i + 1) * chunk))
// }
// res += String.fromCharCode.apply(null, array.slice(i * chunk))
// return res
```
npm package: @olemop/core
Description: > 推荐使用 PM2 来管理服务器实例。工具后面再加。
Latest version: 0.0.59

## Olemop -- a fast, scalable game server framework for node.js

> 推荐使用 PM2 来管理服务器实例。工具后面再加。

Olemop is a fast, scalable game server framework for NodeJS.

It provides the basic development framework and many related components, including libraries and tools.

Olemop is also suitable for real-time web applications; its distributed architecture makes olemop scale better than other real-time web frameworks.

## Features

### Complete support of game server and realtime application server architecture

- Multiple-player game: mobile, social, web, MMO rpg(middle size)
- Realtime application: chat,  message push, etc.

### Fast, scalable

- Distributed (multi-process) architecture, can be easily scale up
- Flexible server extension
- Full performance optimization and test

### Easy

- Simple API: request, response, broadcast, etc.
- Lightweight: high development efficiency based on node.js
- Convention over configuration: almost zero config

### Powerful

- Many clients support, including javascript, flash, android, iOS, cocos2d-x, C
- Many libraries and tools, including command line tool, admin tool, performance test tool, AI, path finding etc.
- Good reference materials: full docs, many examples and [an open-source MMO RPG demo](@todo)

### Extensible

- Support plugin architecture, easy to add new features through plugins. We also provide many plugins like online status, master high availability.
- Custom features, users can define their own network protocol, custom components very easy.

## Why should I use olemop?

Fast, scalable, real-time game server development is not an easy job, and a good container or framework can reduce its complexity.

Unfortunately, unlike web, finding a game server framework solution is difficult, especially an open source solution. Olemop fills this gap, providing a full solution for building game server frameworks.

Olemop has the following advantages:

- The architecture is scalable. It uses a multi-process, single thread runtime architecture, which has been proven in the industry and is especially suited to the node.js thread model.
- Easy to use, the development model is quite similar to web, using convention over configuration, with almost zero config. The [API](@todo) is also easy to use.
- The framework is extensible. Based on the node.js micro module principle, the core of olemop is small. All of the components, libraries and tools are individual npm modules, and anyone can create their own module to extend the framework.
- The reference materials and documentation are quite complete. In addition to the documentation, we also provide [an open-source MMO RPG demo](@todo) (HTML5 client), which is a far better reference material than any book.
npm package: @olemop/loader
Description: Load codes for olemop based on the convention over configuration rules.
Latest version: 0.0.49

# @olemop/loader - loader module for olemop

Load codes for olemop based on the convention over configuration rules.

@olemop/rpc could load modules in batch but not load the sub-directory recursively.

## Regulation

- Module name

Module would use the filename by default. For example: load `lib/a.js` and the return result would be: `{ a: require('./lib/a') }`

It would use the name if the module with a name property. For example

```javascript
// a.js
exports.name = 'test'
```

the return result would be: `{ test: require('./lib/a') }`

- Module definiation

If the module exported as a function, @olemop/loader would take it as a factory method and generate a new instance of module by calling the function. And it would return the module directly for other situation.

```javascript
module.exports = (context) => {
  // return some module instance
  return {}
}
```

## Installation

```bash
npm install @olemop/loader
```

## Usage

```javascript
const Loader = require('@olemop/loader')

const res = Loader.load('.')

console.log('res: %j', res)
```

## API

### Loader.load(path, context)

Load all modules in the path.

#### Parameters

- path loaded path
- context if the module provides a factory method, the context would be pass as a parameter as the factory method.
npm package: @olemop/logger
Description: @olemop/logger is a [log4js](https://github.com/nomiddlename/log4js-node) wrapper for olemop which provides some useful features.
Latest version: 0.0.59

# @olemop/logger

@olemop/logger is a [log4js](https://github.com/nomiddlename/log4js-node) wrapper for olemop which provides some useful features.  

## Installation

```bash
npm install @olemop/logger
```

## Features

### Log prefix

besides category, you can output prefix as you like in your log. prefix can be filename, serverId, serverType, host etc. To use this feature, you just pass prefix params to getLogger function.

```javascript
const logger = require('@olemop/logger').getLogger(category, prefix1, prefix2, ...)
```

log output msg will output with prefix ahead   

### Get line number in debug

when in debug environment, you may want to get the line number of the log. To use this feature, add this code.

```javascript
process.env.LOGGER_LINE = true
```

In olemop, you just configure the log4js file and set **lineDebug** for true

```json
{
  "appenders": [
  ],

  "levels": {
  }, 

  "replaceConsole": true,

  "lineDebug": true
}
```

### Log raw messages

in raw message mode, your log message will be simply your messages, no prefix and color format strings. To use this feature, add this code:

```javascript
process.env.RAW_MESSAGE = true
```

In olemop, you just configure the log4js file and set **rawMessage** for true

```json
{
  "appenders": [
  ],

  "levels": {
  }, 

  "replaceConsole": true,

  "rawMessage": true
}
```

### Dynamic configure logger level

In olemop logger configuration file log4js.json, you can add reloadSecs option. The reloadSecs means reload logger configuration file every given time. For example:

```json
{
	"reloadSecs": 30
}
```

the above configuration means reload the configuration file every 30 seconds. You can dynamic change the logger level, but it does not support dynamiclly changing configuration of appenders.

## Example

```javascript
const logger = require('@olemop/logger').getLogger('log', __filename, process.pid)

process.env.LOGGER_LINE = true

logger.info('test1')
logger.warn('test2')
logger.error('test3')
```
npm package: @olemop/monitor
Description: monitor the operating-system and process information
Latest version: 0.0.49

## Monitor

Simple, comprehensive monitoring tool for operating-system and process in nodejs.

## Installation

```bash
npm install -g @olemop/monitor
```

## Usage

```javascript
const monitor = require('@olemop/monitor')

monitor.psmonitor.getPsInfo({
  pid: process.pid,
  serverId: 'node-1'
}, (err, data) => {
  console.log('process information is: %j', data)
})

monitor.sysmonitor.getSysInfo((err, data) => {
  console.log('operating-system information is: %j', data)
})
```

## Features

- Simple and comprehensive
- Only for linux or mac
- SystemMonitor aims to monitor system info, such as hostname, loadAvg, mem, CPU(I/O), DISK(O/I) etc, according to the command 'iostat'
- ProcessMonitor aims to monitor process info, such as serverId, serverType, cpu%, mem%, vsz, rss etc, according to the command 'ps auxw'
npm package: @olemop/plugin-sync
Description: sync plugin for olemop
Latest version: 0.0.59

# @olemop/plugin-sync

sync plugin for olemop

# Installation

```bash
npm install @olemop/plugin-sync
```

# Usage

```
const sync = require('@olemop/plugin-sync')

//app.js

app.use(sync, {
  sync: {
    key1: value1,
    key2: value2
  }
})

//get
app.get('globalChannelService')
```
npm package: @olemop/protocol
Description: Encode and decode binary protocol for Pomelo framework.
Latest version: 0.0.59

# @olemop/protocol

Encode and decode binary protocol for Pomelo framework.

More details about Pomelo Protocol, please refer
[Pomelo Protocol](https://github.com/NetEase/pomelo/wiki/Pomelo-%E5%8D%8F%E8%AE%AE)
and
[Pomelo data compression](https://github.com/NetEase/pomelo/wiki/Pomelo-%E6%95%B0%E6%8D%AE%E5%8E%8B%E7%BC%A9%E5%8D%8F%E8%AE%AE).

And the English document would provide later.

 * Homepage: <http://pomelo.netease.com/>
 * Mailing list: <https://groups.google.com/group/pomelo>
 * Documentation: <http://github.com/netease/pomelo>
 * Wiki: <https://github.com/netease/netease/wiki/>
 * Issues: <https://github.com/netease/netease/issues/>
 * Tags: game, nodejs,protocol,js,javascript
npm package: @olemop/status-plugin
Description: `@olemop/status-plugin` is a plugin for olemop. It provides global status service for olemop, which uses persistent storage to save users information.
Latest version: 0.0.59

# @olemop/status-plugin

`@olemop/status-plugin` is a plugin for olemop. It provides global status service for olemop, which uses persistent storage to save users information.

## Installation

```bash
npm install @olemop/status-plugin
```

## Usage

```javascript
const status = require('@olemop/status-plugin')

app.use(status, {
  status: {
    statusKeyPrefix: 'OLEMOP:STATUS',
    host: '127.0.0.1',
    port: 6379,
    // ...options for module redis
  }
})
```

## API

### getSidsByUid(uid, cb)

get frontend server id by user id

- uid - user id
- cb - callback function

Return:

- err - error
- list - array of frontend server ids

### getStatusByUid(uid, cb)

- uid - user id
- cb - callback function

Return:

- err - error
- status - boolean, true if user is online (at least one session with a frontend) or false otherwise

### getStatusByUids(uids, cb)

- uids - array of user ids
- cb - callback function

Return:

- err - error
- statuses - object with uid as keys and boolean as value, true if user is online (at least one session with a frontend) or false otherwise

### pushByUids(uids, route, msg, cb)

- uids - array of user ids
- route - route string
- msg - messages would be sent to clients
- cb - callback function

Return:

- err - error
- fails - array of failed to send user ids

## Notice

status plugin use redis as a default persistent storage, you can change it with your own implementation.

```javascript
const status = require('@olemop/status-plugin')
const mysqlStatusManager = require('./mysqlStatusManager')

app.use(status, {
  status: {
    host: '127.0.0.1',
    port: 6379,
    channelManager: mysqlStatusManager
  }
})
```

cleanOnStartUp option: when you enable this option, status plugin would clean up the old data with the given prefix string.

```javascript
app.use(status, {
  status: {
    host: '127.0.0.1',
    port: 6379,
    cleanOnStartUp: true
  }
})
```
npm package: @olemop/sync
Description: **MODIFIED BASED ON https://github.com/NetEase/pomelo-sync**
Latest version: 0.0.59

# data-sync

**MODIFIED BASED ON https://github.com/NetEase/pomelo-sync**

data sync module is simple sync memory data into store engine like mysql,redis,file.

As we known, updating data is very frequently in game application. Especial in MMORPG kind game. User game data,such as location,flood,equipment,etc. almost always change as time going. For the purpose of avoid such update action cost, we decide to keep a copy data in memory. And keep synchronized with a timer and log

Data sync can support both timer call and instance invoke for the different situation. Most of time the developer don't pay attention to it

Data sync also can support memory operation like NOSQL database such as redis,mongodb etc. most of time developer can seem as a memory database without transaction.

Data sync features include timer sync,set,get,mset,mget,hset,hget,incr,decr,flush,merger,showdown,info,etc. and the developer can extend it very easily.

## Installation

```bash
npm install @olemop/sync
```

## Usage

```javascript
var opt = opt || {}

var updateUser = function (dbclient,val) {
    console.log('mock save %j',val)
}

var dbclient = {};//db connection etc
var id = 10001
var optKey = 'updateUser'
var mapping = {}; //key function mapping
mapping[optKey]=updateUser
opt.mapping = mapping
opt.client = dbclient
opt.interval = 2000

var Sync = require('pomelo-sync')
var sync = new Sync(opt) 
sync.exec(optKey,id,{name:'hello'})
```

## API

### sync.exec(key,id,val,cb)

Add a object to sync for timer exec call back.

#### Arguments

+ key - the key function mapping for wanted to call back,it must be unique.
+ id - object primary key for merger operation.
+ val -  the object wanted to synchronized.
+ cb - the function call back when timer exec.

### sync.flush(key,id,val,cb)

immediately synchronized the memory data with out waiting timer and will remove
waiting queue data

#### Arguments

+ key - the key function mapping for wanted to call back,it must be unique.
+ id - object primary key for merger operation.
+ val -  the object wanted to synchronized.
+ cb - the function call back when timer exec.

### sync.isDone

get the db sync status when the queue is empty,it should return true;otherwise
return false

## Notice

system default sync time is 1000 * 60,
if you use mysql or redis sync,you should set options.client,the file sync is default but it doesn't load in current.
Mysql OR mapping in this modules do not support,user should realize it self.

## ADD

for more usage detail , reading source and benchmark and test case from
source is recommended