Skip to content
frank198 edited this page May 3, 2017 · 1 revision

<!DOCTYPE html> <html lang=“en”> <head>

<meta charset="utf-8">
<title>JSDoc: Class: GlobalChannelService</title>

<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
  <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">

</head>

<body>

<div id=“main”>

<h1 class="page-title">Class: GlobalChannelService</h1>

<section>

<header>

<h2>GlobalChannelService</h2>

</header>

<article>

<div class="container-overview">

<h4 class="name" id="GlobalChannelService"><span class="type-signature"></span>new GlobalChannelService<span class="signature">()</span><span class="type-signature"></span></h4>

<div class=“description”>

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’)‘. </div>

<dl class=“details”>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
    <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line24">line 24</a>
</li></ul></dd>

</dl>

</div>

    <h3 class="subsection-title">Methods</h3>

<h4 class="name" id="add"><span class="type-signature"></span>add<span class="signature">(uid, sid, channelName)</span><span class="type-signature"> &rarr; {*}</span></h4>

<div class=“description”>

添加一个玩家 到指定channelName

Add a member into channel. </div>

<h5>Parameters:</h5>

<table class=“params”>

<thead>
<tr>

    <th>Name</th>

    <th>Type</th>

    <th>Default</th>

    <th class="last">Description</th>
</tr>
</thead>

<tbody>

    <tr>

            <td class="name"><code>uid</code></td>

        <td class="type">

<span class=“param-type”>String</span>

    </td>

        <td class="default">

        </td>

    <td class="description last">user id</td>
</tr>

<tr>

        <td class="name"><code>sid</code></td>

    <td class="type">

<span class=“param-type”>String</span>

    </td>

        <td class="default">

        </td>

    <td class="description last">frontend server id</td>
</tr>

<tr>

        <td class="name"><code>channelName</code></td>

    <td class="type">

<span class=“param-type”>String</span>

        </td>

            <td class="default">

                null

            </td>

        <td class="description last">if channelName == null add redis</td>
    </tr>

</tbody>

</table>

<dl class=“details”>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
    <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line266">line 266</a>
</li></ul></dd>

</dl>

<h5>Returns:</h5>

<div class=“param-desc”>

is add: 1 add success, 0 fail

</div>

<dl>

<dt>
    Type
</dt>
<dd>

<span class=“param-type”>*</span>

</dd>

</dl>

<h4 class="name" id="destroyChannel"><span class="type-signature"></span>destroyChannel<span class="signature">(channelName)</span><span class="type-signature"></span></h4>

<div class=“description”>

Destroy a global channel.

</div>

<h5>Parameters:</h5>

<table class=“params”>

<thead>
<tr>

    <th>Name</th>

    <th>Type</th>

    <th class="last">Description</th>
</tr>
</thead>

<tbody>

    <tr>

            <td class="name"><code>channelName</code></td>

        <td class="type">

<span class=“param-type”>String</span>

        </td>

        <td class="description last">global channel name</td>
    </tr>

</tbody>

</table>

<dl class=“details”>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
    <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line251">line 251</a>
</li></ul></dd>

</dl>

<h4 class="name" id="getMembersByChannelName"><span class="type-signature"></span>getMembersByChannelName<span class="signature">(serverType, channelName)</span><span class="type-signature"></span></h4>

<div class=“description”>

Get members by channel name.

获取指定 channelName 和 服务器类型的成员</div>

<h5>Parameters:</h5>

<table class=“params”>

<thead>
<tr>

    <th>Name</th>

    <th>Type</th>

    <th class="last">Description</th>
</tr>
</thead>

<tbody>

    <tr>

            <td class="name"><code>serverType</code></td>

        <td class="type">

<span class=“param-type”>String</span>

    </td>

    <td class="description last">frontend server type string</td>
</tr>

<tr>

        <td class="name"><code>channelName</code></td>

    <td class="type">

<span class=“param-type”>String</span>

        </td>

        <td class="description last">channel name</td>
    </tr>

</tbody>

</table>

<dl class=“details”>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
    <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line156">line 156</a>
</li></ul></dd>

</dl>

<h4 class="name" id="getMembersBySid"><span class="type-signature"></span>getMembersBySid<span class="signature">(channelName, frontId)</span><span class="type-signature"></span></h4>

<div class=“description”>

Get members by frontend server id.

获取指定服务器和channelName 的玩家列表</div>

<h5>Parameters:</h5>

<table class=“params”>

<thead>
<tr>

    <th>Name</th>

    <th>Type</th>

    <th class="last">Description</th>
</tr>
</thead>

<tbody>

    <tr>

            <td class="name"><code>channelName</code></td>

        <td class="type">

<span class=“param-type”>String</span>

    </td>

    <td class="description last">channel name</td>
</tr>

<tr>

        <td class="name"><code>frontId</code></td>

    <td class="type">

<span class=“param-type”>String</span>

        </td>

        <td class="description last">frontend server id</td>
    </tr>

</tbody>

</table>

<dl class=“details”>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
    <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line170">line 170</a>
</li></ul></dd>

</dl>

<h4 class="name" id="getSidsByUid"><span class="type-signature"></span>getSidsByUid<span class="signature">(uid)</span><span class="type-signature"> &rarr; {*}</span></h4>

<div class=“description”>

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

</div>

<h5>Parameters:</h5>

<table class=“params”>

<thead>
<tr>

    <th>Name</th>

    <th>Type</th>

    <th class="last">Description</th>
</tr>
</thead>

<tbody>

    <tr>

            <td class="name"><code>uid</code></td>

        <td class="type">

        </td>

        <td class="description last"></td>
    </tr>

</tbody>

</table>

<dl class=“details”>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
    <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line182">line 182</a>
</li></ul></dd>

</dl>

<h5>Returns:</h5>

<dl>

<dt>
    Type
</dt>
<dd>

<span class=“param-type”>*</span>

</dd>

</dl>

<h4 class="name" id="getSidsByUidArr"><span class="type-signature"></span>getSidsByUidArr<span class="signature">(uidArr)</span><span class="type-signature"> &rarr; {*}</span></h4>

<div class=“description”>

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

</div>

<h5>Parameters:</h5>

<table class=“params”>

<thead>
<tr>

    <th>Name</th>

    <th>Type</th>

    <th class="last">Description</th>
</tr>
</thead>

<tbody>

    <tr>

            <td class="name"><code>uidArr</code></td>

        <td class="type">

        </td>

        <td class="description last"></td>
    </tr>

</tbody>

</table>

<dl class=“details”>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
    <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line194">line 194</a>
</li></ul></dd>

</dl>

<h5>Returns:</h5>

<dl>

<dt>
    Type
</dt>
<dd>

<span class=“param-type”>*</span>

</dd>

</dl>

<h4 class="name" id="leave"><span class="type-signature"></span>leave<span class="signature">(channelName, uid, sid)</span><span class="type-signature"></span></h4>

<div class=“description”>

Remove user from channel.

移除一个玩家</div>

<h5>Parameters:</h5>

<table class=“params”>

<thead>
<tr>

    <th>Name</th>

    <th>Type</th>

    <th>Default</th>

    <th class="last">Description</th>
</tr>
</thead>

<tbody>

    <tr>

            <td class="name"><code>channelName</code></td>

        <td class="type">

<span class=“param-type”>String</span>

    </td>

        <td class="default">

            null

        </td>

    <td class="description last">channel name</td>
</tr>

<tr>

        <td class="name"><code>uid</code></td>

    <td class="type">

<span class=“param-type”>String</span>

    </td>

        <td class="default">

        </td>

    <td class="description last">user id</td>
</tr>

<tr>

        <td class="name"><code>sid</code></td>

    <td class="type">

<span class=“param-type”>String</span>

        </td>

            <td class="default">

            </td>

        <td class="description last">frontend server id</td>
    </tr>

</tbody>

</table>

<dl class=“details”>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
    <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line282">line 282</a>
</li></ul></dd>

</dl>

<h4 class="name" id="pushMessage"><span class="type-signature"></span>pushMessage<span class="signature">(serverType, route, msg, channelName)</span><span class="type-signature"></span></h4>

<div class=“description”>

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

</div>

<h5>Parameters:</h5>

<table class=“params”>

<thead>
<tr>

    <th>Name</th>

    <th>Type</th>

    <th class="last">Description</th>
</tr>
</thead>

<tbody>

    <tr>

            <td class="name"><code>serverType</code></td>

        <td class="type">

<span class=“param-type”>String</span>

    </td>

    <td class="description last">frontend server type</td>
</tr>

<tr>

        <td class="name"><code>route</code></td>

    <td class="type">

<span class=“param-type”>String</span>

    </td>

    <td class="description last">route string</td>
</tr>

<tr>

        <td class="name"><code>msg</code></td>

    <td class="type">

<span class=“param-type”>Object</span>

    </td>

    <td class="description last">message would be sent to clients</td>
</tr>

<tr>

        <td class="name"><code>channelName</code></td>

    <td class="type">

<span class=“param-type”>String</span>

        </td>

        <td class="description last">channel name</td>
    </tr>

</tbody>

</table>

<dl class=“details”>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
    <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line122">line 122</a>
</li></ul></dd>

</dl>

<h4 class="name" id="pushMessageByUidArr"><span class="type-signature"></span>pushMessageByUidArr<span class="signature">(uidArr, route, msg, frontServerId)</span><span class="type-signature"> &rarr; {*}</span></h4>

<div class=“description”>

群发消息给玩家

</div>

<h5>Parameters:</h5>

<table class=“params”>

<thead>
<tr>

    <th>Name</th>

    <th>Type</th>

    <th>Default</th>

    <th class="last">Description</th>
</tr>
</thead>

<tbody>

    <tr>

            <td class="name"><code>uidArr</code></td>

        <td class="type">

        </td>

            <td class="default">

            </td>

        <td class="description last">要发送的玩家列表</td>
    </tr>

    <tr>

            <td class="name"><code>route</code></td>

        <td class="type">

        </td>

            <td class="default">

            </td>

        <td class="description last">消息号</td>
    </tr>

    <tr>

            <td class="name"><code>msg</code></td>

        <td class="type">

        </td>

            <td class="default">

            </td>

        <td class="description last">消息内容</td>
    </tr>

    <tr>

            <td class="name"><code>frontServerId</code></td>

        <td class="type">

        </td>

            <td class="default">

                null

            </td>

        <td class="description last">指定的前端服务器Id, 默认不指定</td>
    </tr>

</tbody>

</table>

<dl class=“details”>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
    <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line67">line 67</a>
</li></ul></dd>

</dl>

<h5>Returns:</h5>

<dl>

<dt>
    Type
</dt>
<dd>

<span class=“param-type”>*</span>

</dd>

</dl>

<h4 class="name" id="pushMessageForUid"><span class="type-signature"></span>pushMessageForUid<span class="signature">(serverType, frontServerId, route, sendUids, msg)</span><span class="type-signature"> &rarr; {*}</span></h4>

<div class=“description”>

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

</div>

<h5>Parameters:</h5>

<table class=“params”>

<thead>
<tr>

    <th>Name</th>

    <th>Type</th>

    <th class="last">Description</th>
</tr>
</thead>

<tbody>

    <tr>

            <td class="name"><code>serverType</code></td>

        <td class="type">

        </td>

        <td class="description last">frontend server type</td>
    </tr>

    <tr>

            <td class="name"><code>frontServerId</code></td>

        <td class="type">

        </td>

        <td class="description last">frontend server Id</td>
    </tr>

    <tr>

            <td class="name"><code>route</code></td>

        <td class="type">

        </td>

        <td class="description last">route string</td>
    </tr>

    <tr>

            <td class="name"><code>sendUids</code></td>

        <td class="type">

        </td>

        <td class="description last">uids</td>
    </tr>

    <tr>

            <td class="name"><code>msg</code></td>

        <td class="type">

        </td>

        <td class="description last"></td>
    </tr>

</tbody>

</table>

<dl class=“details”>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
    <a href="GlobalChannelService.js.html">GlobalChannelService.js</a>, <a href="GlobalChannelService.js.html#line42">line 42</a>
</li></ul></dd>

</dl>

<h5>Returns:</h5>

<dl>

<dt>
    Type
</dt>
<dd>

<span class=“param-type”>*</span>

</dd>

</dl>

</article>

</section>

</div>

<nav>

<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="GlobalChannelService.html">GlobalChannelService</a></li></ul>

</nav>

<br class=“clear”>

<footer>

Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Wed May 03 2017 18:50:08 GMT+0800 (CST)

</footer>

<script> prettyPrint(); </script> <script src=“scripts/linenumber.js”> </script> </body> </html>

Clone this wiki locally