<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: Client</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: Client</h1> <section> <header> <h2>Client</h2> </header> <article> <div class="container-overview"> <h4 class="name" id="Client"><span class="type-signature"></span>new Client<span class="signature">(config)</span><span class="type-signature"></span></h4> <div class="description"> Backgammon client </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>config</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Configuration object <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>containerID</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">ID of HTML container tag (defaults to 'backgammon')</td> </tr> <tr> <td class="name"><code>boardID</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">ID of board tag (defaults to 'board')</td> </tr> <tr> <td class="name"><code>rulePath</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">path to rules directory, relative to lib directory (defaults to './rules/')</td> </tr> <tr> <td class="name"><code>boardUI</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">board UI filename, relative to project root (defaults to '../app/browser/js/SimpleBoardUI.js')</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line22">line 22</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Members</h3> <h4 class="name" id="_callbackList"><span class="type-signature"></span>_callbackList<span class="type-signature"> :Object</span></h4> <div class="description"> Map of callback functions to be executed after server replies to a message </div> <h5>Type:</h5> <ul> <li> <span class="param-type">Object</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line40">line 40</a> </li></ul></dd> </dl> <h4 class="name" id="_clientMsgSeq"><span class="type-signature"></span>_clientMsgSeq<span class="type-signature"> :number</span></h4> <div class="description"> Counter used to generate unique sequence number for messages in client's session </div> <h5>Type:</h5> <ul> <li> <span class="param-type">number</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line34">line 34</a> </li></ul></dd> </dl> <h4 class="name" id="_msgSubscriptions"><span class="type-signature"></span>_msgSubscriptions<span class="type-signature"> :Object</span></h4> <div class="description"> Dictionary of arrays, containing subscriptions for reception of messages by id/type. The key of the dictionary is the message ID. The value of the dictionary is an array with callback functions to execute when message is received. </div> <h5>Type:</h5> <ul> <li> <span class="param-type">Object</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line48">line 48</a> </li></ul></dd> </dl> <h4 class="name" id="_socket"><span class="type-signature"></span>_socket<span class="type-signature"> :Socket</span></h4> <div class="description"> Client's socket object </div> <h5>Type:</h5> <ul> <li> <span class="param-type">Socket</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line28">line 28</a> </li></ul></dd> </dl> <h4 class="name" id="config"><span class="type-signature"></span>config<span class="type-signature"> :Object</span></h4> <div class="description"> Default client configuration </div> <h5>Type:</h5> <ul> <li> <span class="param-type">Object</span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line78">line 78</a> </li></ul></dd> </dl> <h4 class="name" id="match"><span class="type-signature"></span>match<span class="type-signature"> :<a href="Match.html">Match</a></span></h4> <div class="description"> Current match </div> <h5>Type:</h5> <ul> <li> <span class="param-type"><a href="Match.html">Match</a></span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line66">line 66</a> </li></ul></dd> </dl> <h4 class="name" id="otherPlayer"><span class="type-signature"></span>otherPlayer<span class="type-signature"> :<a href="Player.html">Player</a></span></h4> <div class="description"> Other player object </div> <h5>Type:</h5> <ul> <li> <span class="param-type"><a href="Player.html">Player</a></span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line60">line 60</a> </li></ul></dd> </dl> <h4 class="name" id="player"><span class="type-signature"></span>player<span class="type-signature"> :<a href="Player.html">Player</a></span></h4> <div class="description"> Client's player object </div> <h5>Type:</h5> <ul> <li> <span class="param-type"><a href="Player.html">Player</a></span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line54">line 54</a> </li></ul></dd> </dl> <h4 class="name" id="rule"><span class="type-signature"></span>rule<span class="type-signature"> :<a href="Rule.html">Rule</a></span></h4> <div class="description"> Rule used in current match </div> <h5>Type:</h5> <ul> <li> <span class="param-type"><a href="Rule.html">Rule</a></span> </li> </ul> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line72">line 72</a> </li></ul></dd> </dl> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="_notify"><span class="type-signature"></span>_notify<span class="signature">(msg, params)</span><span class="type-signature"></span></h4> <div class="description"> Subscribe for notification on message reception </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>msg</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">The ID of the message received</td> </tr> <tr> <td class="name"><code>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line591">line 591</a> </li></ul></dd> </dl> <h4 class="name" id="_openSocket"><span class="type-signature"></span>_openSocket<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Prepare socket and attach message handlers </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line106">line 106</a> </li></ul></dd> </dl> <h4 class="name" id="handleConnect"><span class="type-signature"></span>handleConnect<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Handle connection to server. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line217">line 217</a> </li></ul></dd> </dl> <h4 class="name" id="handleCreateGuest"><span class="type-signature"></span>handleCreateGuest<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle reply - Guest player created </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>player</code></td> <td class="type"> <span class="param-type"><a href="Player.html">Player</a></span> </td> <td class="description last">Player object created</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line313">line 313</a> </li></ul></dd> </dl> <h4 class="name" id="handleCreateMatch"><span class="type-signature"></span>handleCreateMatch<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle reply - New match has been created </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line346">line 346</a> </li></ul></dd> </dl> <h4 class="name" id="handleEventDiceRoll"><span class="type-signature"></span>handleEventDiceRoll<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle event - Dice rolled </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line420">line 420</a> </li></ul></dd> </dl> <h4 class="name" id="handleEventGameOver"><span class="type-signature"></span>handleEventGameOver<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle event - Game over. Current game is over. Prepare for next game of match, if any. </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>match</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Match that has been started</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line464">line 464</a> </li></ul></dd> </dl> <h4 class="name" id="handleEventGameRestart"><span class="type-signature"></span>handleEventGameRestart<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle event - Game restart. Current game in match is over. Match is not finished, so start next game. </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line483">line 483</a> </li></ul></dd> </dl> <h4 class="name" id="handleEventMatchOver"><span class="type-signature"></span>handleEventMatchOver<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle event - Match is over. Offer rematch or starting a new game. </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>match</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Match that has been started</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line474">line 474</a> </li></ul></dd> </dl> <h4 class="name" id="handleEventMatchStart"><span class="type-signature"></span>handleEventMatchStart<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle event - Piece moved </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>match</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Match that has been started</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line442">line 442</a> </li></ul></dd> </dl> <h4 class="name" id="handleEventPieceMove"><span class="type-signature"></span>handleEventPieceMove<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle event - Piece moved </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>position</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Position of piece being moved</td> </tr> <tr> <td class="name"><code>type</code></td> <td class="type"> <span class="param-type"><a href="global.html#PieceType">PieceType</a></span> </td> <td class="description last">Type of piece being moved</td> </tr> <tr> <td class="name"><code>steps</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Number steps the piece is moved with</td> </tr> <tr> <td class="name"><code>moveActionList</code></td> <td class="type"> <span class="param-type">Array.<<a href="MoveAction.html">MoveAction</a>></span> </td> <td class="description last">List of actions that have to be played in UI</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line432">line 432</a> </li></ul></dd> </dl> <h4 class="name" id="handleEventPlayerJoined"><span class="type-signature"></span>handleEventPlayerJoined<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle event - Another player joined match </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line400">line 400</a> </li></ul></dd> </dl> <h4 class="name" id="handleEventTurnStart"><span class="type-signature"></span>handleEventTurnStart<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle event - New turn started </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line410">line 410</a> </li></ul></dd> </dl> <h4 class="name" id="handleEventUndoMoves"><span class="type-signature"></span>handleEventUndoMoves<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle event - Undo moves </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line493">line 493</a> </li></ul></dd> </dl> <h4 class="name" id="handleGetMatchList"><span class="type-signature"></span>handleGetMatchList<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle reply - List of matfches returned </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line329">line 329</a> </li></ul></dd> </dl> <h4 class="name" id="handleJoinMatch"><span class="type-signature"></span>handleJoinMatch<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle reply - Joined new match </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line362">line 362</a> </li></ul></dd> </dl> <h4 class="name" id="handleMessage"><span class="type-signature"></span>handleMessage<span class="signature">(msg, params)</span><span class="type-signature"></span></h4> <div class="description"> Handle reply/event message. </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>msg</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">Message ID</td> </tr> <tr> <td class="name"><code>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line230">line 230</a> </li></ul></dd> </dl> <h4 class="name" id="handleMovePiece"><span class="type-signature"></span>handleMovePiece<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle reply - Piece moved </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line389">line 389</a> </li></ul></dd> </dl> <h4 class="name" id="handlePlayRandom"><span class="type-signature"></span>handlePlayRandom<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle reply - Start random match </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line338">line 338</a> </li></ul></dd> </dl> <h4 class="name" id="handleRollDice"><span class="type-signature"></span>handleRollDice<span class="signature">(params)</span><span class="type-signature"></span></h4> <div class="description"> Handle reply - Dice rolled </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>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Message parameters</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line379">line 379</a> </li></ul></dd> </dl> <h4 class="name" id="init"><span class="type-signature"></span>init<span class="signature">(config)</span><span class="type-signature"></span></h4> <div class="description"> Initialize client </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>config</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Configuration object <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>containerID</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">ID of HTML container tag (defaults to 'backgammon')</td> </tr> <tr> <td class="name"><code>boardID</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">ID of board tag (defaults to 'board')</td> </tr> <tr> <td class="name"><code>rulePath</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">path to rules directory, relative to lib directory (defaults to './rules/')</td> </tr> <tr> <td class="name"><code>boardUI</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">board UI filename, relative to project root (defaults to '../app/browser/js/SimpleBoardUI.js')</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line93">line 93</a> </li></ul></dd> </dl> <h4 class="name" id="loadRule"><span class="type-signature"></span>loadRule<span class="signature">(ruleName)</span><span class="type-signature"> → {<a href="Rule.html">Rule</a>}</span></h4> <div class="description"> Load rule module </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>ruleName</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">Rule's name, equal to rule's class name (eg. RuleBgCasual)</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line504">line 504</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - Corresponding rule object </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="Rule.html">Rule</a></span> </dd> </dl> <h4 class="name" id="reqConfirmMoves"><span class="type-signature"></span>reqConfirmMoves<span class="signature">(callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <div class="description"> Confirm moves made </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type"><a href="global.html#messageCallback">messageCallback</a></span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Callback function to be called when server sends a reply</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line662">line 662</a> </li></ul></dd> </dl> <h4 class="name" id="reqCreateMatch"><span class="type-signature"></span>reqCreateMatch<span class="signature">(ruleName, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <div class="description"> Request creating a new match. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>ruleName</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="description last">Name of rule to use (eg. RuleBgCasual)</td> </tr> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type"><a href="global.html#messageCallback">messageCallback</a></span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Callback function to be called when server sends a reply</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line625">line 625</a> </li></ul></dd> </dl> <h4 class="name" id="reqJoinMatch"><span class="type-signature"></span>reqJoinMatch<span class="signature">(matchID, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <div class="description"> Request joining a specific match. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>matchID</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> </td> <td class="description last">ID of match to join</td> </tr> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type"><a href="global.html#messageCallback">messageCallback</a></span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Callback function to be called when server sends a reply</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line640">line 640</a> </li></ul></dd> </dl> <h4 class="name" id="reqMove"><span class="type-signature"></span>reqMove<span class="signature">(piece, steps, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <div class="description"> Request moving a piece. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>piece</code></td> <td class="type"> <span class="param-type"><a href="Piece.html">Piece</a></span> </td> <td class="attributes"> </td> <td class="description last">Denormalized position from which a piece has to be moved</td> </tr> <tr> <td class="name"><code>steps</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> </td> <td class="description last">Number of steps to move forward to first home position</td> </tr> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type"><a href="global.html#messageCallback">messageCallback</a></span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Callback function to be called when server sends a reply</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line680">line 680</a> </li></ul></dd> </dl> <h4 class="name" id="reqPlayRandom"><span class="type-signature"></span>reqPlayRandom<span class="signature">(ruleName, params<span class="signature-attributes">opt</span>, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <div class="description"> Request playing a match with random player - from waiting queue. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>ruleName</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="description last">Name of rule to use (eg. RuleBgCasual)</td> </tr> <tr> <td class="name"><code>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Object map with message parameters</td> </tr> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type"><a href="global.html#messageCallback">messageCallback</a></span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Callback function to be called when server sends a reply</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line607">line 607</a> </li></ul></dd> </dl> <h4 class="name" id="reqRollDice"><span class="type-signature"></span>reqRollDice<span class="signature">(callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <div class="description"> Request rolling dice </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type"><a href="global.html#messageCallback">messageCallback</a></span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Callback function to be called when server sends a reply</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line654">line 654</a> </li></ul></dd> </dl> <h4 class="name" id="reqUndoMoves"><span class="type-signature"></span>reqUndoMoves<span class="signature">(callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <div class="description"> Undo moves made since last confirm </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type"><a href="global.html#messageCallback">messageCallback</a></span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Callback function to be called when server sends a reply</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line670">line 670</a> </li></ul></dd> </dl> <h4 class="name" id="resetBoard"><span class="type-signature"></span>resetBoard<span class="signature">(match, rule)</span><span class="type-signature"></span></h4> <div class="description"> Init game </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>match</code></td> <td class="type"> <span class="param-type"><a href="Match.html">Match</a></span> </td> <td class="description last">Game</td> </tr> <tr> <td class="name"><code>rule</code></td> <td class="type"> <span class="param-type"><a href="Rule.html">Rule</a></span> </td> <td class="description last">Rule object to use</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line517">line 517</a> </li></ul></dd> </dl> <h4 class="name" id="resizeUI"><span class="type-signature"></span>resizeUI<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Notify UI that DOM was rezised and UI may have to be updated </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line696">line 696</a> </li></ul></dd> </dl> <h4 class="name" id="sendMessage"><span class="type-signature"></span>sendMessage<span class="signature">(msg, params<span class="signature-attributes">opt</span>, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <div class="description"> Send message to server. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>msg</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="description last">Message ID</td> </tr> <tr> <td class="name"><code>params</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Object map with message parameters</td> </tr> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type"><a href="global.html#messageCallback">messageCallback</a></span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Callback function to be called when server sends a reply to this message</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line202">line 202</a> </li></ul></dd> </dl> <h4 class="name" id="subscribe"><span class="type-signature"></span>subscribe<span class="signature">(msgID, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <div class="description"> Subscribe for notification on message reception </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>msgID</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> </td> <td class="description last">The type of message to subscribe for</td> </tr> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type"><a href="global.html#messageCallback">messageCallback</a></span> </td> <td class="attributes"> <optional><br> </td> <td class="description last">Callback function to be called on reception of this message</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line580">line 580</a> </li></ul></dd> </dl> <h4 class="name" id="updateMatch"><span class="type-signature"></span>updateMatch<span class="signature">(match)</span><span class="type-signature"></span></h4> <div class="description"> Update match object. After an object has been updated, an update to UI should also be triggered. </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>match</code></td> <td class="type"> <span class="param-type"><a href="Match.html">Match</a></span> </td> <td class="description last">Updated match object to use</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line550">line 550</a> </li></ul></dd> </dl> <h4 class="name" id="updateOtherPlayer"><span class="type-signature"></span>updateOtherPlayer<span class="signature">(player)</span><span class="type-signature"></span></h4> <div class="description"> Update other player. After an object has been updated, an update to UI should also be triggered. </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>player</code></td> <td class="type"> <span class="param-type"><a href="Player.html">Player</a></span> </td> <td class="description last">Updated other player's object to use</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line539">line 539</a> </li></ul></dd> </dl> <h4 class="name" id="updatePlayer"><span class="type-signature"></span>updatePlayer<span class="signature">(player)</span><span class="type-signature"></span></h4> <div class="description"> Update player. After an object has been updated, an update to UI should also be triggered. </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>player</code></td> <td class="type"> <span class="param-type"><a href="Player.html">Player</a></span> </td> <td class="description last">Updated player's object to use</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line528">line 528</a> </li></ul></dd> </dl> <h4 class="name" id="updateRule"><span class="type-signature"></span>updateRule<span class="signature">(rule)</span><span class="type-signature"></span></h4> <div class="description"> Update rule object. After an object has been updated, an update to UI should also be triggered. </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>rule</code></td> <td class="type"> <span class="param-type"><a href="Rule.html">Rule</a></span> </td> <td class="description last">Updated rule object to use</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line562">line 562</a> </li></ul></dd> </dl> <h4 class="name" id="updateUI"><span class="type-signature"></span>updateUI<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Trigger update of board's UI. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="client.js.html">client.js</a>, <a href="client.js.html#line570">line 570</a> </li></ul></dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.html">Client</a></li><li><a href="Dice.html">Dice</a></li><li><a href="Game.html">Game</a></li><li><a href="Match.html">Match</a></li><li><a href="MoveAction.html">MoveAction</a></li><li><a href="Piece.html">Piece</a></li><li><a href="Player.html">Player</a></li><li><a href="PlayerStats.html">PlayerStats</a></li><li><a href="Random.html">Random</a></li><li><a href="Rule.html">Rule</a></li><li><a href="RuleBgCasual.html">RuleBgCasual</a></li><li><a href="RuleBgGulbara.html">RuleBgGulbara</a></li><li><a href="RuleBgTapa.html">RuleBgTapa</a></li><li><a href="State.html">State</a></li><li><a href="Utils.html">Utils</a></li></ul><h3>Global</h3><ul><li><a href="global.html#Message">Message</a></li><li><a href="global.html#MoveActionType">MoveActionType</a></li><li><a href="global.html#PieceType">PieceType</a></li><li><a href="global.html#Protocol">Protocol</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Sun Dec 18 2016 20:10:05 GMT+0200 (EET) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>