OSDN Git Service

Version 0.6.209, bug fixes X.Net.* & X.URL.
[pettanr/clientJs.git] / 0.6.x / js / 06_net / 00_XNet.js
index 469669d..7d5b26f 100644 (file)
@@ -242,13 +242,13 @@ function X_NET_proxyDispatch( e ){
                                        this[ 'unlisten' ]( X_EVENT_COMPLETE, X_NET_proxyDispatch )\r
                                                [ 'dispatch' ]( X_EVENT_COMPLETE );\r
                                };\r
-                               X_NET_shiftQueue();\r
+                               X_NET_shiftQueue( true );\r
                                X_Pair_release( this );\r
                                X_NET_completePhase = 0;\r
                        } else\r
                        if( this === X_NET_currentQueue ){\r
                                X_NET_currentWrapper.cancel();\r
-                               X_NET_shiftQueue();\r
+                               X_NET_shiftQueue( true );\r
                                flag = true;\r
                        } else\r
                        if( ( i = X_NET_QUEUE_LIST.indexOf( this ) ) !== -1 ){\r
@@ -289,11 +289,12 @@ function X_NET_proxyDispatch( e ){
        };\r
 };\r
 \r
-function X_NET_shiftQueue(){\r
-       var auth, authSettings;\r
+// TODO _busy は X.Net で触る.\r
+function X_NET_shiftQueue( currentKilled ){\r
+       var q, auth, authSettings;\r
 \r
        if( X_NET_currentQueue ){\r
-               if( X_NET_currentWrapper._busy ) return;\r
+               if( !currentKilled ) return;\r
                \r
                X_NET_currentWrapper\r
                        [ 'unlisten' ]( [ X_EVENT_PROGRESS, X_EVENT_SUCCESS, X_EVENT_ERROR ], X_NET_currentQueue, X_NET_proxyDispatch )\r
@@ -307,7 +308,7 @@ function X_NET_shiftQueue(){
        if( !X_NET_QUEUE_LIST.length ) return;\r
 \r
 \r
-       X_NET_currentQueue = X_NET_QUEUE_LIST.shift();\r
+       X_NET_currentQueue = q = X_NET_QUEUE_LIST.shift();\r
        X_NET_currentData  = X_Pair_get( X_NET_currentQueue );\r
        \r
        switch( X_NET_currentData.netType ){\r
@@ -335,12 +336,17 @@ function X_NET_shiftQueue(){
                                        case 1 :\r
                                        case 2 :\r
                                                if( !( auth[ 'dispatch' ]( X_EVENT_NEED_AUTH ) & X_CALLBACK_PREVENT_DEFAULT ) ){\r
-                                                       authSettings.lazyRequests = authSettings.lazyRequests || [];\r
-                                                       authSettings.lazyRequests.indexOf( X_NET_currentQueue ) === -1 && authSettings.lazyRequests.push( X_NET_currentQueue );\r
+                                                       // event 内で kill されていないことを確認\r
+                                                       if( X_NET_currentQueue === q ){\r
+                                                               authSettings.lazyRequests = authSettings.lazyRequests || [];\r
+                                                               authSettings.lazyRequests.indexOf( q ) === -1 && authSettings.lazyRequests.push( q );\r
+                                                               X_NET_currentQueue = null;\r
+                                                               X_NET_shiftQueue();                                                                     \r
+                                                       };\r
+                                               } else {\r
+                                                       X_NET_currentQueue === q && q[ 'kill' ]();\r
                                                };\r
-                                               X_NET_currentQueue = null;\r
-                                               X_NET_shiftQueue();\r
-                                               break;\r
+                                               return;\r
                                        case 3 : // refresh token\r
                                                X_NET_QUEUE_LIST.push( X_NET_currentQueue );\r
                                                X_NET_currentQueue = null;\r