Changeset 100

Show
Ignore:
Timestamp:
08/03/06 03:03:25 (2 years ago)
Author:
robin
Message:

automated include packaging

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • streamservice/trunk/lib/streamservice/Dispatch.js

    r98 r100  
    1 if (typeof(streamservice) == 'undefined') { 
    2     streamservice = {}; 
    3 
    4  
    5 update(streamservice, { 
     1/*** 
     2 
     3streamservice.Dispatch 0.9.0 
     4 
     5(c) 2006 Wiretooth Ltd. All rights Reserverd. 
     6 
     7***/ 
     8 
     9MochiKit.Base.update(streamservice, { 
    610    strip_tag_inplace : function(seperator, item){ 
    711        item[0] = item[0].slice(item[0].split(seperator,1)[0].length + 1); 
     
    2630 
    2731        if(typeof(names) == "undefined" || names==null){ 
    28             self.queryparameters=parseQueryString( 
    29                 queryString([self.dispatchparametername],["[[],[]]"]), true); 
    30             /*log("***: self.queryparameters = " +  
    31                 serializeJSON(self.queryparameters));*/ 
     32            self.queryparameters=MochiKit.Base.parseQueryString( 
     33                MochiKit.Base.queryString( 
     34                    [self.dispatchparametername],["[[],[]]"]), true); 
    3235        } else { 
    3336            /* normalize parameter representation */ 
    34             self.queryparameters=parseQueryString(queryString( 
    35                 names, values), true); 
    36             log("***: self.queryparameters = " + serializeJSON( 
    37                 self.queryparameters)); 
     37            self.queryparameters=MochiKit.Base.parseQueryString( 
     38                MochiKit.Base.queryString( 
     39                    names, values), true); 
    3840            /* if there is a collision the first element of user specified 
    3941               value is clobbered */ 
     
    106108        } 
    107109        try{ 
    108             /*log("***:" + clientdata);*/ 
    109110            var sent = streamservice.split_json(clientdata); 
    110111            var recvd = [null,null]; 
    111112            if( typeof(emulatedbackendpollresult)!="undefined" && 
    112113                emulatedbackendpollresult != null){ 
    113                 /*log("***:" + emulatedbackendpollresult); 
    114                   log("***:" + typeof(emulatedbackendpollresult));*/ 
    115114                recvd = streamservice.split_json(emulatedbackendpollresult); 
    116115                if(ignoreemulatedresponses != false) 
    117116                    recvd = [recvd[0],null]; 
    118117            } 
    119             /* log("***:" + serializeJSON(recvd)); */ 
    120118            var result = streamservice.join_json(recvd[0], sent[0]); 
    121119            if(recvd[1] != null){ 
     
    130128            log("loopback raised:" + result); 
    131129            waitfail = function(seconds,  value){ 
    132                 var d = wait(seconds); 
    133                 d.addBoth(partial(function (value){throw value;}, value)); 
     130                var d = MochiKit.Async.wait(seconds); 
     131                d.addBoth(MochiKit.Base.partial( 
     132                    function (value){throw value;}, value)); 
    134133                return d; 
    135134            } 
     
    342341streamservice.XMLHttpRequestProtocol = function (servicepath,  
    343342     dispatchparametername, names, values, sdpp){ 
    344     bindMethods(this); 
     343    MochiKit.Base.bindMethods(this); 
    345344    streamservice.prepare_protocol( 
    346345        this, servicepath,  
    347346        dispatchparametername, names, values, sdpp); 
    348     this.req = getXMLHttpRequest(); 
     347    this.req = MochiKit.Async.getXMLHttpRequest(); 
    349348} 
    350349streamservice.XMLHttpRequestProtocol.prototype = { 
     
    371370                method="POST"; 
    372371            this.queryparameters[this.dispatchparametername][0]=data 
    373             var url = this.baseurl + "?" + queryString(this.queryparameters); 
    374  
    375             log("###: POLLING = " +  
    376                 this.queryparameters[this.dispatchparametername][0]); 
    377          
    378             /*log("###: queryitems = " + serializeJSON(queryitems)); 
    379               log("###: url = " + url);*/ 
     372            var url = this.baseurl + "?" + MochiKit.Base.queryString( 
     373                this.queryparameters); 
     374 
    380375            this.queryparameters[this.dispatchparametername][0]="[[][]]"; 
    381376 
     
    384379 
    385380            var getresult = function(req){ 
    386                 log("***: req.responseText = " + req.responseText); 
    387                 /* 
    388                 log("***: evalJSONRequest(req) = " + evalJSONRequest(req)); 
    389                 log("***: split_json(req.responseText) = " + split_json( 
    390                     req.responseText));*/ 
    391381                /*return split_json(req.responseText);*/ 
    392                 return evalJSONRequest(req); 
    393             } 
    394             return sendXMLHttpRequest(this.req).addCallbacks( 
     382                return MochiKit.Base.evalJSONRequest(req); 
     383            } 
     384            return MochiKit.Async.sendXMLHttpRequest(this.req).addCallbacks( 
    395385                            getresult, this.response_error); 
    396386        } catch (e){ 
    397             log("***: error polling " + repr(e)); 
     387            log("***: error polling " + MochiKit.Base.repr(e)); 
    398388            return fail(e).addBoth(this.response_error); 
    399389        } 
     
    402392 
    403393streamservice.Dispatcher = function () { 
    404     bindMethods(this); 
     394    MochiKit.Base.bindMethods(this); 
    405395    this.initialize.apply(this, arguments); 
    406396}; 
     
    424414 
    425415        if( typeof(d)=="undefined" || d == null){ 
    426             d = new Deferred(); 
     416            d = new MochiKit.Async.Deferred(); 
    427417        } 
    428418        tag = [this.nextresponsetag, tag].join(this.TAG_SEPERATOR); 
     
    443433 
    444434    dispatch_result : function (result) { 
    445         /*log("result: " + result); 
    446          log("typeof(result): " + typeof(result)); 
    447          log("serializeJSON(result): " + serializeJSON(result));*/ 
    448435        try{ 
    449             forEach(iter(result[1]), 
     436            MochiKit.Iter.forEach(iter(result[1]), 
    450437                function(item){ 
    451438                 
    452                     /*log("query/reply: " + repr(item));*/ 
    453                        
    454439                    /* each item is [tag, body] */ 
    455440                    dresponse=this.replypending[item[0]];                
     
    461446 
    462447                    } else { 
    463                         log("unexpected response:" + serializeJSON(item)); 
     448                        log("*** unexpected response:" +  
     449                            MochiKit.Base.serializeJSON(item)); 
    464450                    } 
    465451                }, this);      
    466452            /* returns the new queries from the backend to the client. */ 
    467453            return result[0];  
    468         } catch(e){ log("dispatch_result exception:" + repr(e)); throw e;} 
     454        } catch(e){ log("dispatch_result exception:" +  
     455            MochiKit.Base.repr(e)); throw e;} 
    469456    }, 
    470457 
     
    496483        this.responsepending.splice(0, this.responsepending.length); 
    497484        d.addCallbacks( 
    498             bind(this.dispatch_result, this), 
    499             bind(this.dispatch_err, this)); 
     485            MochiKit.Base.bind(this.dispatch_result, this), 
     486            MochiKit.Base.bind(this.dispatch_err, this)); 
    500487        return d; 
    501488    }, 
     
    546533         
    547534        if(this.dpolling==null || this.dpolling.fired != -1){ 
    548             callLater(this.polling_interval,  
    549                 bind(function(){ 
     535            MochiKit.Async.callLater(this.polling_interval,  
     536                MochiKit.Base.bind(function(){ 
    550537                    this.dpolling = this.poll().addBoth( 
    551538                        this._continue_polling) 
     
    562549                this.dpolling.cancel(); 
    563550        } catch (e){ 
    564             if(!(e instanceof AlreadyCalledError)) 
     551            if(!(e instanceof MochiKit.Async.AlreadyCalledError)) 
    565552                throw e; 
    566553        } 
     
    577564    ***/ 
    578565     
    579     bindMethods(this); 
     566    MochiKit.Base.bindMethods(this); 
    580567    this.id = streamservice.Service.prototype.NEXT_SERVICE_ID; 
    581568    streamservice.Service.prototype.NEXT_SERVICE_ID += 1; 
     
    594581        this.observers[idinservice] = observer; 
    595582    }, 
    596     strip_tag_inplace: function(item){ 
     583    strip_tag_inplace : function(item){ 
    597584        return streamservice.strip_tag_inplace(this.TAG_SEPERATOR,  
    598585            this.dispatcher.strip_tag_inplace(item)); 
     
    609596 
    610597    handle_query : function(item){ 
    611         log("*** serverquery ***" + repr(item)); 
    612598 
    613599        observertag = this.dispatcher.strip_tag(item[0]); 
     
    624610            observer.handle_query.call(observer, item[1], tag, responseback); 
    625611        } else { 
    626             log("UNTARGETED SERVER QUERY:" + item); 
     612            log("*** UNTARGETED SERVER QUERY:" + item); 
    627613        } 
    628614    }, 
    629615 
    630616    handle_queryitems : function(dispatcher, queryitems){ 
    631         /*log("***!: Observer.handle_queryitems");*/ 
    632         /*log("***!: queryitems = " + serializeJSON(queryitems));*/ 
    633         forEach(iter(queryitems), partial(this.handle_query)); 
     617        MochiKit.Iter.forEach(iter(queryitems), MochiKit.Base.partial( 
     618            this.handle_query)); 
    634619    }, 
    635620 
     
    638623            '' + observerid :  
    639624            [observerid, tag].join(this.TAG_SEPERATOR); 
    640         d = (typeof(d)=='undefined' || !d) ? new Deferred() : d; 
     625        d = (typeof(d)=='undefined' || !d) ?  
     626            new MochiKit.Async.Deferred() : d; 
    641627        d.addCallback(this.strip_tag_inplace);  
    642628        return this.dispatcher.query(body, id, d); 
     
    645631 
    646632streamservice.Observer = function(service, idinservice, client_dispatcher){ 
    647     bindMethods(this); 
     633    MochiKit.Base.bindMethods(this); 
    648634    this.service = service; 
    649635    this.idinservice = idinservice; 
     
    659645     
    660646    handle_query : function(body, tag, responseback){ 
    661         /*log("*** Observer.handle_query ***" + repr(body) + ' ' + repr(tag));*/ 
    662647        if (this.client_dispatcher){ 
    663648            this.client_dispatcher(body, tag).addBoth(responseback); 
  • streamservice/trunk/lib/streamservice/Loopback.js

    r98 r100  
    66 
    77***/ 
    8 if (typeof(streamservice) == 'undefined') { 
    9     streamservice = {}; 
    10 } 
    11 if (typeof(streamservice.Loopback) == 'undefined') { 
    12     streamservice.Loopback = {}; 
    13 } 
    14  
    15 streamservice.Loopback.VERSION = "0.9.0"; 
    16 streamservice.Loopback.NAME = "Loopback"; 
    17 streamservice.Loopback.EXPORT = [ 
    18     "Protocol", 
    19     "Observer" 
    20 ]; 
    21 streamservice.Loopback.EXPORT_OK = []; 
    228 
    239streamservice.Loopback.Protocol = function ( 
  • streamservice/trunk/tests/test-Dispatch.html

    r98 r100  
    88    src="../lib/SimpleTest/SimpleTest.js"></script> 
    99    <script type="text/javascript"  
    10     src="../lib/streamservice/Loopback.js"></script> 
     10    src="../lib/streamservice/Dispatch.include.js"></script> 
    1111    <script type="text/javascript"  
    1212    src="../lib/streamservice/Dispatch.js"></script> 
     13    <script type="text/javascript"  
     14    src="../lib/streamservice/Loopback.include.js"></script> 
     15    <script type="text/javascript"  
     16    src="../lib/streamservice/Loopback.js"></script> 
    1317    <script type="text/javascript"  
    1418    src="test_Dispatch.js"></script>