Browse Source

new BERT API

Maxim Sokhatsky 11 years ago
parent
commit
32cb4eaf11
2 changed files with 43 additions and 43 deletions
  1. 19 19
      apps/face/priv/static/doc/js_proto.htm
  2. 24 24
      apps/face/priv/static/doc/n2o_proto.htm

+ 19 - 19
apps/face/priv/static/doc/js_proto.htm

@@ -18,10 +18,10 @@
 <p>Session Attach is the first message that should be
 <p>Session Attach is the first message that should be
 sent from JavaScript client using Authorization token. For test purposes you can use following token:</p>
 sent from JavaScript client using Authorization token. For test purposes you can use following token:</p>
 
 
-<code>ws.send(bert.encodebuf(bert.tuple(
-    bert.atom('client'),
-    bert.tuple(
-        bert.atom('session_attach'),
+<code>ws.send(enc(tuple(
+    atom('client'),
+    tuple(
+        atom('session_attach'),
         'EBAs6dg2Xw6XuCdg8qiPmlBLgYJ6N4Ti0P+oGpWgY'+
         'EBAs6dg2Xw6XuCdg8qiPmlBLgYJ6N4Ti0P+oGpWgY'+
         'z4NW4nBBUzTe/wAuLYtPnjFpsjCExxSpV78fipmsP'+
         'z4NW4nBBUzTe/wAuLYtPnjFpsjCExxSpV78fipmsP'+
         'xcf+NGy+QKIM6rmVJhpnIlKf0bpFNuGaAPjZAWthh'+
         'xcf+NGy+QKIM6rmVJhpnIlKf0bpFNuGaAPjZAWthh'+
@@ -33,9 +33,9 @@ sent from JavaScript client using Authorization token. For test purposes you can
 <p>After session established you can join the game table.
 <p>After session established you can join the game table.
 You should specify existed ID of game table. 1000001 is permanent lobby game ID:</p>
 You should specify existed ID of game table. 1000001 is permanent lobby game ID:</p>
 
 
-<code>ws.send(bert.encodebuf(bert.tuple(
-    bert.atom('client'),
-    bert.tuple(bert.atom('join_game'),1000001))));
+<code>ws.send(enc(tuple(
+    atom('client'),
+    tuple(atom('join_game'),1000001))));
 </code>
 </code>
 
 
 <h2><a name="p1.1">Game Events</a></h2>
 <h2><a name="p1.1">Game Events</a></h2>
@@ -44,7 +44,7 @@ You should specify existed ID of game table. 1000001 is permanent lobby game ID:
 All messages from server to client are encoded as game events.
 All messages from server to client are encoded as game events.
 You can make BERT huamn readable with:</P>
 You can make BERT huamn readable with:</P>
 
 
-<code>String(bert.decodebuf(raw))</code>
+<code>String(dec(raw))</code>
 
 
 <h3><a name="p1.1">Game Info</a></h3>
 <h3><a name="p1.1">Game Info</a></h3>
 
 
@@ -141,23 +141,23 @@ will mirror from server as DATA BERT event also.</P>
 
 
 <h3><a name="p1.1">Take</a></h3>
 <h3><a name="p1.1">Take</a></h3>
 
 
-<code>ws.send(bert.encodebuf(bert.tuple(
-    bert.atom('client'),
-    bert.tuple(
-        bert.atom('game_action'),
+<code>ws.send(enc(tuple(
+    atom('client'),
+    tuple(
+        atom('game_action'),
         1000001,
         1000001,
-        bert.atom('okey_take'),
+        atom('okey_take'),
         {'pile':0})))); </code>
         {'pile':0})))); </code>
 
 
 <h3><a name="p1.1">Discard</a></h3>
 <h3><a name="p1.1">Discard</a></h3>
 
 
-<code>ws.send(bert.encodebuf(bert.tuple(
-    bert.atom('client'),
-    bert.tuple(
-        bert.atom('game_action'),
+<code>ws.send(enc(tuple(
+    atom('client'),
+    tuple(
+        atom('game_action'),
         1000001,
         1000001,
-        bert.atom('okey_discard'),
-        {'tile':bert.tuple(bert.atom('OkeyPiece'),1,9)}))));</code>
+        atom('okey_discard'),
+        {'tile':tuple(atom('OkeyPiece'),1,9)}))));</code>
 
 
 </div>
 </div>
 
 

+ 24 - 24
apps/face/priv/static/doc/n2o_proto.htm

@@ -22,12 +22,12 @@ channel and want to hide the content of the message,
 that was generated on server. You can use BASE64 pickling mechanisms
 that was generated on server. You can use BASE64 pickling mechanisms
 with optional AES/RIPEMD160 encrypting.
 with optional AES/RIPEMD160 encrypting.
 
 
-<code>ws.send(bert.encodebuf(
-    bert.tuple(bert.atom('pickle'),
-    bert.binary('ddtake'),
-    bert.binary('g2gCaAVkAAJldmQABWluZGV4ZAAEdGFrZWsABH'+
+<code>ws.send(enc(
+    tuple(atom('pickle'),
+    binary('ddtake'),
+    binary('g2gCaAVkAAJldmQABWluZGV4ZAAEdGFrZWsABH'+
                  Rha2VkAAVldmVudGgDYgAABXViAAQKXmIAC3cK'),
                  Rha2VkAAVldmVudGgDYgAABXViAAQKXmIAC3cK'),
-    [bert.tuple(bert.atom('ddtake'),'0')])));</code>
+    [tuple(atom('ddtake'),'0')])));</code>
 
 
 Where Base64 represents the N2O EVENT:
 Where Base64 represents the N2O EVENT:
 
 
@@ -40,10 +40,10 @@ This request will return JSON with EVAL field only.</p>
 
 
 Client messages usually originated at client and represent the Client API Requests:
 Client messages usually originated at client and represent the Client API Requests:
 
 
-<code>ws.send(bert.encodebuf(
-    bert.tuple(
-        bert.atom('client'),
-        bert.tuple(bert.atom('join_game'),1000001))));</code>
+<code>ws.send(enc(
+    tuple(
+        atom('client'),
+        tuple(atom('join_game'),1000001))));</code>
 
 
 <p>NOTE: This request may return JSON with EVAL and DATA fields.</p>
 <p>NOTE: This request may return JSON with EVAL and DATA fields.</p>
 
 
@@ -52,10 +52,10 @@ Client messages usually originated at client and represent the Client API Reques
 <p>When you want to receive BERT messages on client you usually ask the
 <p>When you want to receive BERT messages on client you usually ask the
 server by sending:</p>
 server by sending:</p>
 
 
-<code>ws.send(bert.encodebuf(
-    bert.tuple(
-        bert.atom('bert'),
-        bert.binary('API Request'));</code>
+<code>ws.send(enc(
+    tuple(
+        atom('bert'),
+        binary('API Request'));</code>
 
 
 <p>This messages could be handled as this:</p>
 <p>This messages could be handled as this:</p>
 
 
@@ -70,10 +70,10 @@ server by sending:</p>
 <p>When you need raw binary Blob on client side,
 <p>When you need raw binary Blob on client side,
 for images or other raw data you can ask server like this:</p>
 for images or other raw data you can ask server like this:</p>
 
 
-<code>ws.send(bert.encodebuf(
-    bert.tuple(
-        bert.atom('binary'),
-        bert.binary('API Request'));</code>
+<code>ws.send(enc(
+    tuple(
+        atom('binary'),
+        binary('API Request'));</code>
 
 
 <p>And handle also in binary clause:</p>
 <p>And handle also in binary clause:</p>
 
 
@@ -96,10 +96,10 @@ server by sending <b>info</b> notifications directly to Web Socket process:
 
 
 <p>You can also send server messages from client relays:</p>
 <p>You can also send server messages from client relays:</p>
 
 
-<code>ws.send(bert.encodebuf(
-    bert.tuple(
-        bert.atom('server'),
-        bert.binary('Binary Message'));</code>
+<code>ws.send(enc(
+    tuple(
+        atom('server'),
+        binary('Binary Message'));</code>
 
 
 
 
 <p>NOTE: This request may return JSON with EVAL and DATA fields.</p>
 <p>NOTE: This request may return JSON with EVAL and DATA fields.</p>
@@ -125,18 +125,18 @@ to handle_web_socket(data) function if exists.</p>
 <h2><a name="p1.1">JSON enveloped BERT</a></h2>
 <h2><a name="p1.1">JSON enveloped BERT</a></h2>
 
 
 <p>Usually in DATA come <a href="http://bert-rpc.org">BERT</a> messages (Binary Erlang Term Format).
 <p>Usually in DATA come <a href="http://bert-rpc.org">BERT</a> messages (Binary Erlang Term Format).
-<a href="https://github.com/synrc/n2o_scripts/blob/master/n2o/bert.js">BERT.js</a>
+<a href="https://github.com/synrc/n2o_scripts/blob/master/n2o/js">js</a>
 is used to decode Game Protocol message.</p>
 is used to decode Game Protocol message.</p>
 
 
 <code>function handle_web_socket(body) {
 <code>function handle_web_socket(body) {
-    console.log(String(bert.decodebuf(body))); } </code>
+    console.log(String(dec(body))); } </code>
 
 
 <code style="background-color:white;margin-bottom:-5px;">E> Received: {message,"Hello"} </code>
 <code style="background-color:white;margin-bottom:-5px;">E> Received: {message,"Hello"} </code>
 
 
 <h2><a name="">BERT binary</a></h2>
 <h2><a name="">BERT binary</a></h2>
 
 
 <code>function handle_web_socket(body) {
 <code>function handle_web_socket(body) {
-    console.log(String(bert.decodebuf(body))); } </code>
+    console.log(String(dec(body))); } </code>
 
 
 <h2><a name="p1.1">RAW binary</a></h2>
 <h2><a name="p1.1">RAW binary</a></h2>