Browse Source

fix js

pull/1780/head
Ethan Buchman 9 years ago
parent
commit
3fb3a81b92
3 changed files with 7 additions and 8 deletions
  1. +5
    -5
      example/js/app.js
  2. +1
    -3
      example/js/server.js
  3. +1
    -0
      example/js/wire.js

+ 5
- 5
example/js/app.js View File

@ -36,13 +36,13 @@ CounterAppContext.prototype.set_option = function(key, value){
CounterAppContext.prototype.append_tx = function(txBytes){
if (this.serial) {
txByteArray = txBytes
if (txByte.length >= 2 && txBytes.slice(0, 2) == "0x") {
txByteArray = new Buffer(txBytes)
if (txBytes.length >= 2 && txBytes.slice(0, 2) == "0x") {
txByteArray = wire.hex2bytes(txBytes.slice(2));
}
r = new wire.BytesReader(txByteArray)
txValue = decode_big_endian(r, txBytes.length)
if (txValue != this.txcount){
r = new msg.buffer(txByteArray)
txValue = wire.decode_big_endian(r, txBytes.length)
if (txValue != this.txCount){
return {"ret_code":1}
}
}


+ 1
- 3
example/js/server.js View File

@ -88,13 +88,11 @@ AppServer.prototype.createServer = function(){
// done decoding
conn.msgLength = 0
// NOTE: this throws of the "this"'s in app.js
//reqFunc = appCtx[reqType];
var res = function(){
if (args == null){
return appCtx[reqType]();
} else if (Array.isArray(args)){
return appCtx[reqType].apply(this, args);
return appCtx[reqType].apply(appCtx, args);
} else {
return appCtx[reqType](args)
}


+ 1
- 0
example/js/wire.js View File

@ -3,6 +3,7 @@ math = require("math")
module.exports = {
decode_string: decode_string,
decode_varint: decode_varint,
decode_big_endian: decode_big_endian,
encode_big_endian: encode_big_endian,
encode: encode,
reverse: reverse,


Loading…
Cancel
Save