MCPcopy
hub / github.com/mayswind/AriaNg / buildRequestContext

Function buildRequestContext

src/scripts/services/aria2RpcService.js:134–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

132 };
133
134 var buildRequestContext = function () {
135 var methodName = arguments[0];
136 var requestInPage = $location.path();
137 var isSystemMethod = checkIsSystemMethod(methodName);
138 var finalParams = [];
139
140 var context = {
141 methodName: (!isSystemMethod ? getAria2MethodFullName(methodName) : methodName)
142 };
143
144 context.connectionSuccessCallback = function () {
145 fireCustomEvent(onConnectionSuccessCallbacks);
146 };
147
148 context.connectionFailedCallback = function () {
149 fireCustomEvent(onConnectionFailedCallbacks);
150 };
151
152 context.connectionReconnectingCallback = function () {
153 fireCustomEvent(onConnectionReconnectingCallbacks);
154 };
155
156 context.connectionWaitingToReconnectCallback = function () {
157 fireCustomEvent(onConnectionWaitingToReconnectCallbacks);
158 };
159
160 if (secret && !isSystemMethod) {
161 finalParams.push(aria2RpcConstants.rpcTokenPrefix + secret);
162 }
163
164 if (arguments.length > 1) {
165 var innerContext = arguments[1];
166
167 context.successCallback = function (id, result) {
168 if (innerContext.callback) {
169 innerContext.callback({
170 id: id,
171 success: true,
172 data: result,
173 context: innerContext
174 });
175 }
176
177 fireCustomEvent(onOperationSuccessCallbacks);
178
179 if (!isConnected) {
180 isConnected = true;
181 var firstSuccessContext = {
182 rpcName: ariaNgSettingService.getCurrentRpcDisplayName()
183 };
184 fireCustomEvent(onFirstSuccessCallbacks, firstSuccessContext);
185 }
186 };
187
188 context.errorCallback = function (id, error) {
189 var errorProcessed = false;
190 var currentPage = $location.path();
191

Callers 1

aria2RpcService.jsFile · 0.85

Calls 4

checkIsSystemMethodFunction · 0.85
getAria2MethodFullNameFunction · 0.85
fireCustomEventFunction · 0.85
processErrorFunction · 0.70

Tested by

no test coverage detected