Subj : Re: JSON database
To   : echicken
From : Kirkman
Date : Tue Sep 30 2014 02:26 pm

> Overwriting the .json file will probably work.  The sequence of events will
> be important.  I imagine it'll be fine if you "close" the DB module,
> overwrite the file, then reload the DB module.

I'm trying to recreate the "reload" function in json-svc-ctrl.js. I think I
have put together something really short and simple that should woek, but I
keep getting an error:

"!JavaScript : uncaught exception: User not found: [object Object]"

Here's what I have. The error seems to be produced by the wait("OK");

Any idea what I'm doing wrong? My username and password are correct in the
script itself.




load('json-client.js');

var db;
var user = '[removed]';
var pass = '[removed]';

var server = 'localhost';
var port = '10088';

function wait(func) {
       var start = Date.now();
       do {
               var packet = db.receive();
               log(packet);
               if(!packet)
                       continue;
               else if(packet.func == func)
                       return packet.data;
               else
                       db.updates.push(packet.data);
       } while(Date.now() - start < db.settings.SOCK_TIMEOUT);
       throw("timed out waiting for server response");
}

if(!db) {
       db = new JSONClient(server,port);
}
if(!db.socket.is_connected)
       db.connect();
db.ident('ADMIN',user,pass);

var trash = wait("OK");

db.send({scope:'sportsstats',func:'RELOAD'});

////--------------------------------------------------
BiC -=- http://breakintochat.com -=- bbs wiki and blog

---
� Synchronet