X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F06_net%2F00_XNet.js;h=90693963a7b992dd65e4e0d73dccea361c80d8ee;hb=4e4ab3be10850546063d4a4b93250ed142bb8cd2;hp=469669d72a9379741bf6c633122c85376294a02e;hpb=3c54df5e0d4f20eb32cfd73480cbc9ae8358ebbf;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/06_net/00_XNet.js b/0.6.x/js/06_net/00_XNet.js index 469669d..9069396 100644 --- a/0.6.x/js/06_net/00_XNet.js +++ b/0.6.x/js/06_net/00_XNet.js @@ -176,7 +176,7 @@ X[ 'Net' ] = X_EventDispatcher[ 'inherits' ]( }; opt.netType = type; - opt[ 'url' ] = url; + opt[ 'url' ] = url; X_Pair_create( this, opt ); @@ -242,13 +242,13 @@ function X_NET_proxyDispatch( e ){ this[ 'unlisten' ]( X_EVENT_COMPLETE, X_NET_proxyDispatch ) [ 'dispatch' ]( X_EVENT_COMPLETE ); }; - X_NET_shiftQueue(); + X_NET_shiftQueue( true ); X_Pair_release( this ); X_NET_completePhase = 0; } else if( this === X_NET_currentQueue ){ X_NET_currentWrapper.cancel(); - X_NET_shiftQueue(); + X_NET_shiftQueue( true ); flag = true; } else if( ( i = X_NET_QUEUE_LIST.indexOf( this ) ) !== -1 ){ @@ -289,11 +289,12 @@ function X_NET_proxyDispatch( e ){ }; }; -function X_NET_shiftQueue(){ - var auth, authSettings; +// TODO _busy は X.Net で触る. +function X_NET_shiftQueue( currentKilled ){ + var q, auth, authSettings; if( X_NET_currentQueue ){ - if( X_NET_currentWrapper._busy ) return; + if( !currentKilled ) return; X_NET_currentWrapper [ 'unlisten' ]( [ X_EVENT_PROGRESS, X_EVENT_SUCCESS, X_EVENT_ERROR ], X_NET_currentQueue, X_NET_proxyDispatch ) @@ -307,7 +308,7 @@ function X_NET_shiftQueue(){ if( !X_NET_QUEUE_LIST.length ) return; - X_NET_currentQueue = X_NET_QUEUE_LIST.shift(); + X_NET_currentQueue = q = X_NET_QUEUE_LIST.shift(); X_NET_currentData = X_Pair_get( X_NET_currentQueue ); switch( X_NET_currentData.netType ){ @@ -335,12 +336,17 @@ function X_NET_shiftQueue(){ case 1 : case 2 : if( !( auth[ 'dispatch' ]( X_EVENT_NEED_AUTH ) & X_CALLBACK_PREVENT_DEFAULT ) ){ - authSettings.lazyRequests = authSettings.lazyRequests || []; - authSettings.lazyRequests.indexOf( X_NET_currentQueue ) === -1 && authSettings.lazyRequests.push( X_NET_currentQueue ); + // event 内で kill されていないことを確認 + if( X_NET_currentQueue === q ){ + authSettings.lazyRequests = authSettings.lazyRequests || []; + authSettings.lazyRequests.indexOf( q ) === -1 && authSettings.lazyRequests.push( q ); + X_NET_currentQueue = null; + X_NET_shiftQueue(); + }; + } else { + X_NET_currentQueue === q && q[ 'kill' ](); }; - X_NET_currentQueue = null; - X_NET_shiftQueue(); - break; + return; case 3 : // refresh token X_NET_QUEUE_LIST.push( X_NET_currentQueue ); X_NET_currentQueue = null;