jaros1 / Money-Network

Demo with complementary and alternative money. Implemented in ZeroNet and AngularJS. Focus on privacy, encryption, max data in client and min data on ZeroNet. Work in progress.
GNU General Public License v2.0
4 stars 4 forks source link

API - create generic ZeroNet API cmd wrapper #299

Open jaros1 opened 6 years ago

jaros1 commented 6 years ago

A problem is hanging ZeroNet API calls. For example error from UI server, stopped/started UI server and other problems. Callback function must always be executed to prevent hanging operations.

There has been created special ZeroNet API wrappers with hanging cmd detection for some commands (z_site_publish, z_file_get, z_file_write, z_site_info). But big work to create wrappers for all ZeroNet API commands.

One other solution could be merging z_api_operation_start, ZeroFrame.cmd and debug_z_api_operation_end into one function z_debug_api_operation call to ensure that cb in ZeroFrame.cmd request is always called. Timeout after x ms. Different timeout for each ZeroFrame cmd.

    // combine debug_z_api_operation_start, ZeroFrame.cmd & debug_z_api_operation_end into one function call
    // see https://github.com/jaros1/Money-Network/issues/296#issuecomment-355840053
    // params:
    // - pgm: calling pgm
    // - alias: alias for cmd. normally null or blank. used for qbQuery alias
    // - cmd: ZeroFrame cmd
    // - params: arguments to ZeroFrame cmd
    // - debug_this: null, true or false. debug option only for this call
    // - group_debug_seq: bundle sequence of connected ZeroFrame calls. For example send_message or process_incoming_message
    // - cb: optional cb. not used in all ZeroFrame API calls
    // forced timeout after x ms. x different for each ZeroFrame cmd
    function debug_z_api_operation (pgm, alias, cmd, params, debug_this, group_debug_seq, cb) {
        var inner_path ;
        if (alias) inner_path = alias ;
        else {
            // cmd with inner_path.
        }

    } // debug_z_api_operation