1. Eugene Veretennikov
  2. as3snapi

Commits

nitrobin  committed 7ac5ff2 Draft

refactoring

  • Participants
  • Parent commits 2f2be80
  • Branches development

Comments (0)

Files changed (20)

File as3snapi-core/src/as3snapi/ConnectionFactory.as

View file
  • Ignore whitespace
 package as3snapi {
+
 import as3snapi.api.INetworkConnectHandler;
 import as3snapi.api.feautures.IFeatureEventDispatcher;
 import as3snapi.api.feautures.social.IFeatureUserId;
 import as3snapi.utils.bus.IMutableBus;
 
 import flash.utils.clearTimeout;
+import flash.utils.getQualifiedClassName;
 import flash.utils.setTimeout;
 
 public class ConnectionFactory implements IConnectionFactory {
      * @param networkModules спсиок модулей для используемых соцсетей
      * @param busModules список модулей для навешивания дополнительных возможностей на шину
      */
-    public function ConnectionFactory(flashVars:* = null, networkConfigs:Vector.<INetworkConfig> = null, networkModules:Vector.<INetworkModule> = null, busFactory:IBusFactory = null) {
+    public function ConnectionFactory(flashVars:* = null, networkConfigs:Vector.<INetworkConfig> = null,
+                                      networkModules:Vector.<INetworkModule> = null, busFactory:IBusFactory = null) {
         if (flashVars != null) {
             setFlashVars(flashVars);
         }
         bus.dispatchEvent(new BusFactoryEvent(BusFactoryEvent.BASIC_FEATURES_ADDED));
         // log
         logFlashVars(bus);
+        var log:IFeatureLog = bus.getFeature(IFeatureLog);
         // Detect
         for each(var networkModule:INetworkModule in networkModules) {
             for each(var config:INetworkConfig in networkConfigs) {
                 var context:INetworkModuleContext = new NetworkModuleContext(bus, config);
                 if (networkModule.isAvailable(context)) {
+                    log.log("Available module: " + getQualifiedClassName(networkModule) + ", config:" + getQualifiedClassName(config));
                     bus.addFeatureIfNotExist(IFeatureConfigGetter, new FeatureConfig(config));
                     doConnect(networkModule, context, handler);
                     return;
                 }
             }
         }
+        log.log("Detection fail");
         handler.onFail("Detection fail");
     }
 
-    private function doConnect(networkModule:INetworkModule, context:INetworkModuleContext, handler:INetworkConnectHandler):void {
+    private function doConnect(networkModule:INetworkModule, context:INetworkModuleContext,
+                               handler:INetworkConnectHandler):void {
         var bus:IMutableBus = context.getBus();
 
         // Configure network
         var timerId:uint = setTimeout(onTimeout, CRITICAL_TIMEOUT);
 
         function onTimeout():void {
-            handler.onFail("Connection timeout");
+            log.log("SNAPI Connection timeout");
+            handler.onFail("SNAPI Connection timeout");
             handler = null;
         }
 
         var log:IFeatureLog = bus.getFeature(IFeatureLog);
         if (bus.hasFeature(IFeatureAsyncInit)) {
-            log.log("IFeatureAsyncInit#init()...");
-            var feature:IFeatureAsyncInit = bus.getFeature(IFeatureAsyncInit);
-            feature.init(new AsyncInitHandler(onReady, onFail));
-            bus.disable(IFeatureAsyncInit);
+            try {
+                log.log("IFeatureAsyncInit#init()...");
+                var feature:IFeatureAsyncInit = bus.getFeature(IFeatureAsyncInit);
+                feature.init(new AsyncInitHandler(onReady, onFail));
+                bus.disable(IFeatureAsyncInit);
+            } catch(e:Error) {
+                log.log("IFeatureAsyncInit ERROR: " + e.toString());
+                onFail(e);
+            }
         } else {
             onReady();
         }
             features.push(EnumUtils.getShortClassName(featureClass));
         }
         features.sort();
-        log.log("Features: ");
-        log.log(features.join("\n"));
+        log.log("Features:\n" + features.join("\n"));
     }
 
 
 import as3snapi.base.features.flashvars.IFeatureFlashVarsGetter;
 import as3snapi.base.features.javascript.IFeatureJavaScript;
 import as3snapi.base.features.javascript.JavaScriptUtils;
-import as3snapi.base.features.log.FeatureLogTrace;
 import as3snapi.base.features.log.IFeatureLog;
 import as3snapi.base.features.requester.IFeatureHttpRequester;
+import as3snapi.utils.JsonUtils;
 import as3snapi.utils.bus.IBus;
 import as3snapi.utils.bus.IMutableBus;
 
         return fEventDispatcher;
     }
 
-    public function log(msg:*):void {
-        fLog.log(msg);
+    public function log(msg:String):void {
+        fLog.log("LOG: " + msg);
     }
 
-    public function apiLog(msg:*):void {
-        fLog.apiLog("API: " + FeatureLogTrace.universalDump(msg));
+    public function apiLog(msg:String):void {
+        fLog.apiLog("API: " + JsonUtils.universalDump(msg));
     }
 
-    public function eventLog(msg:*):void {
-        fLog.eventLog("EVENT: " + FeatureLogTrace.universalDump(msg));
+    public function eventLog(msg:String):void {
+        fLog.eventLog("EVENT: " + JsonUtils.universalDump(msg));
     }
 
     public function getJavaScriptUtils():JavaScriptUtils {

File as3snapi-core/src/as3snapi/base/INetworkModuleContext.as

View file
  • Ignore whitespace
 package as3snapi.base {
+
 import as3snapi.base.features.flashvars.FlashVars;
 import as3snapi.base.features.javascript.IFeatureJavaScript;
 import as3snapi.base.features.javascript.JavaScriptUtils;
 
     function getJavaScript():IFeatureJavaScript;
 
-    function log(msg:*):void;
+    function log(msg:String):void;
 
     function getEventDispatcher():IEventDispatcher;
 
-    function apiLog(msg:*):void;
+    function apiLog(msg:String):void;
 
-    function eventLog(msg:*):void;
+    function eventLog(msg:String):void;
 
     function getJavaScriptUtils():JavaScriptUtils;
 }

File as3snapi-core/src/as3snapi/base/features/javascript/FeatureJavaScript.as

View file
  • Ignore whitespace
 package as3snapi.base.features.javascript {
+
+import as3snapi.base.features.log.IFeatureLog;
 import as3snapi.utils.bus.IMutableBus;
 
 import flash.external.ExternalInterface;
                 throw new Error("Function is not valid parameter type. Use 'JavascriptUtils.callSmart' instead.")
             }
         }
-        ///var log:IFeatureLog = plugins.getFeature(IFeatureLog)
-        //log.log("call:" + functionName)
+        var log:IFeatureLog = bus.getFeature(IFeatureLog)
+        log.log("call:" + functionName + ": " + rest.join(", "))
         var params:Array = rest.slice();
         params.unshift(functionName);
         return ExternalInterface.call.apply(null, params);

File as3snapi-core/src/as3snapi/base/features/log/FeatureLogHook.as

  • Ignore whitespace
-package as3snapi.base.features.log {
-public class FeatureLogHook implements IFeatureLog {
-    private var logHook:Function;
-    private var apiLogHook:Function;
-    private var eventLogHook:Function;
-
-    public function FeatureLogHook(logHook:Function, apiLogHook:Function, eventLogHook:Function) {
-        this.logHook = logHook;
-        this.apiLogHook = apiLogHook;
-        this.eventLogHook = eventLogHook;
-    }
-
-    public function log(msg:*):void {
-        logHook(msg);
-    }
-
-    public function apiLog(msg:*):void {
-        apiLogHook(msg);
-    }
-
-    public function eventLog(msg:*):void {
-        eventLogHook(msg);
-    }
-}
-}

File as3snapi-core/src/as3snapi/base/features/log/FeatureLogNULL.as

View file
  • Ignore whitespace
 package as3snapi.base.features.log {
+
 public class FeatureLogNULL implements IFeatureLog {
     public function FeatureLogNULL() {
     }
 
-    public function log(msg:*):void {
+    public function log(msg:String):void {
     }
 
-    public function apiLog(msg:*):void {
+    public function apiLog(msg:String):void {
     }
 
-    public function eventLog(msg:*):void {
+    public function eventLog(msg:String):void {
     }
 }
 }

File as3snapi-core/src/as3snapi/base/features/log/FeatureLogTrace.as

View file
  • Ignore whitespace
 package as3snapi.base.features.log {
-import as3snapi.utils.JsonUtils;
 
 import flash.external.ExternalInterface;
 
 public class FeatureLogTrace implements IFeatureLog {
     private static var useJs:Boolean = true;
+    private var traceMsgFn:Function;
 
-    public function FeatureLogTrace() {
+    public function FeatureLogTrace(traceMsgFn:Function = null) {
+        this.traceMsgFn = traceMsgFn;
     }
 
-    public function log(msg:*):void {
+    public function log(msg:String):void {
         universalTrace(msg);
     }
 
-    public function apiLog(msg:*):void {
+    public function apiLog(msg:String):void {
         universalTrace(msg);
     }
 
-    public function eventLog(msg:*):void {
+    public function eventLog(msg:String):void {
         universalTrace(msg);
     }
 
-    public static function universalTrace(msg:*):void {
-        msg = universalDump(msg);
-        trace(msg);
+    public function universalTrace(msg:String):void {
+        if (traceMsgFn != null) {
+            traceMsgFn(msg);
+        } else {
+            trace(msg);
+        }
         try {
             if (useJs && ExternalInterface.available) {
                 ExternalInterface.call("window.console.log", msg);
             useJs = false;
         }
     }
-
-    public static function universalDump(msg:*):String {
-        return msg is String ? msg : JsonUtils.encode(msg);
-    }
 }
 }

File as3snapi-core/src/as3snapi/base/features/log/IFeatureLog.as

View file
  • Ignore whitespace
 package as3snapi.base.features.log {
+
 public interface IFeatureLog {
-    function log(msg:*):void;
+    function log(msg:String):void;
 
-    function apiLog(msg:*):void
+    function apiLog(msg:String):void
 
-    function eventLog(msg:*):void
+    function eventLog(msg:String):void
 }
 }

File as3snapi-core/src/as3snapi/base/plugins/logs/BusModuleLogHook.as

  • Ignore whitespace
-package as3snapi.base.plugins.logs {
-import as3snapi.base.features.log.*;
-import as3snapi.base.plugins.IBusModule;
-import as3snapi.utils.bus.IMutableBus;
-
-public class BusModuleLogHook implements IBusModule {
-    private var logHook:Function;
-    private var apiLogHook:Function;
-    private var eventLogHook:Function;
-
-    public function BusModuleLogHook(logHook:Function, apiLogHook:Function, eventLogHook:Function) {
-        this.logHook = logHook;
-        this.apiLogHook = apiLogHook;
-        this.eventLogHook = eventLogHook;
-    }
-
-    public function install(bus:IMutableBus):void {
-        bus.addFeature(IFeatureLog, new FeatureLogHook(logHook, apiLogHook, eventLogHook));
-    }
-
-}
-}

File as3snapi-core/src/as3snapi/base/plugins/logs/BusModuleLogTrace.as

View file
  • Ignore whitespace
 package as3snapi.base.plugins.logs {
+
 import as3snapi.base.features.log.FeatureLogTrace;
 import as3snapi.base.features.log.IFeatureLog;
 import as3snapi.base.plugins.IBusModule;
 import as3snapi.utils.bus.IMutableBus;
 
 public class BusModuleLogTrace implements IBusModule {
-    public function BusModuleLogTrace() {
+    private var traceMsgFn:Function;
+
+    public function BusModuleLogTrace(traceMsgFn:Function = null) {
+        this.traceMsgFn = traceMsgFn;
     }
 
     public function install(bus:IMutableBus):void {
-        bus.addFeature(IFeatureLog, new FeatureLogTrace())
+        bus.addFeature(IFeatureLog, new FeatureLogTrace(traceMsgFn));
     }
 
 

File as3snapi-core/src/as3snapi/networks/mailru/impl/MailruApiImpl.as

View file
  • Ignore whitespace
 package as3snapi.networks.mailru.impl {
+
 import as3snapi.api.feautures.social.IFeatureAppId;
 import as3snapi.api.feautures.social.IFeatureNetworkId;
 import as3snapi.api.feautures.social.IFeatureRefererId;
 import as3snapi.networks.mailru.features.EventMailru;
 import as3snapi.networks.mailru.features.IFeatureMailruApiCore;
 import as3snapi.networks.mailru.features.IFeatureMailruApiUi;
+import as3snapi.utils.JsonUtils;
 
 import flash.events.IEventDispatcher;
 import flash.utils.clearTimeout;
     }
 
     private function onEvent(name:String, data:Object, ...rest):void {
-        state.context.eventLog({name:name, data:data});
+        state.context.eventLog(JsonUtils.universalDump({name: name, data: data}));
         events.dispatchEvent(new EventMailru(name, data));
     }
 
     }
 
     public function showInvitePopup():void {
-        js.call("mailru.app.friends.invite", {text:""});
+        js.call("mailru.app.friends.invite", {text: ""});
     }
 
 
         }
     }
 
-    private static const GENDERS:Object = {0:"m", 1:"f"};
+    private static const GENDERS:Object = {0: "m", 1: "f"};
 
     private function parseProfile(u:Object, ...rest):IProfile {
         var profile:Profile = new Profile();
 
     public function paymentsShowDialog(service_id:int, service_name:String, mailiki_price:int):void {
         js.call("mailru.app.payments.showDialog", {
-            service_id:service_id,
-            service_name:service_name,
-            mailiki_price:mailiki_price
+            service_id: service_id,
+            service_name: service_name,
+            mailiki_price: mailiki_price
         });
     }
 }

File as3snapi-core/src/as3snapi/networks/odnoklassnikiru/ConfigOdnoklassnikiru.as

View file
  • Ignore whitespace
 package as3snapi.networks.odnoklassnikiru {
+
 import as3snapi.base.INetworkConfig;
 import as3snapi.base.NetworkConfigBase;
 
 public class ConfigOdnoklassnikiru extends NetworkConfigBase implements INetworkConfig {
-    private var secretKey:String;
+    private var application_key:String;
 
-    public function ConfigOdnoklassnikiru(secretKey:String) {
-        this.secretKey = secretKey;
+    public function ConfigOdnoklassnikiru(application_key:String) {
+        this.application_key = application_key;
     }
 
-    public function getSecretKey():String {
-        return secretKey;
+    public function getApplicationKey():String {
+        return application_key;
     }
 }
 }

File as3snapi-core/src/as3snapi/networks/odnoklassnikiru/ModuleOdnoklassnikiru.as

View file
  • Ignore whitespace
 package as3snapi.networks.odnoklassnikiru {
+
 import as3snapi.api.feautures.social.SocialFeaturesInstallHelper;
 import as3snapi.base.INetworkModule;
 import as3snapi.base.INetworkModuleContext;
         if (config == null) {
             return false;
         }
-        if (!config.getSecretKey()) {
-            context.log("WARNING Odnoklassniki.ru Config : empty secretKey");
+        var applicationKeyFromConfig:String = config.getApplicationKey();
+        if (!applicationKeyFromConfig) {
+            context.log("WARNING Odnoklassniki.ru Config : empty application_key");
             return false;
         }
 
         if (apiServer != null && apiServer.match(/(odnoklassniki\.ru)/)) {
             return true;
         }
-
-        return false;
+        var application_key:String = flashVars.getString('application_key');
+        return (application_key != null && application_key == applicationKeyFromConfig);
     }
 
     public function install(context:INetworkModuleContext):void {

File as3snapi-core/src/as3snapi/networks/odnoklassnikiru/features/IFeatureOdnoklassnikiApi.as

View file
  • Ignore whitespace
 package as3snapi.networks.odnoklassnikiru.features {
 public interface IFeatureOdnoklassnikiApi {
     function apiRequest(method:String, params:Object, onSuccess:Function, onFail:Function, exeption:Boolean = false):void ;
+
+    /**
+     * http://apiok.ru/wiki/display/api/%D0%9E%D0%B1%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%BA%D0%B0%20%D0%BF%D0%BB%D0%B0%D1%82%D0%B5%D0%B6%D0%B5%D0%B9
+     name     Нет     String     Наименование продукта, например: 1 яблоня. Может быть пустым, если приложение дает варианты.
+     description     Да     String     Описание продукта, например: Золото позволяет покупать полезные вещи в игре.
+     code     Да     String     Идентификатор продукта, кодирующий продукты, сумму и т. п. в свободном формате.
+     price     Да     int     Общая стоимость в виртуальной валюте портала.
+     options     Нет     String     Кодированный JSON список вариантов продуктов. Каждый вариант содержит: Name (наименование), Price (стоимость), Code (идентификатор)
+     attributes     Нет     String     Кодированные JSON пары ключей/значений, содержащие дополнительные параметры транзакции, которые будут переданы на сервер.
+     currency     Нет     String     Валюта платежа, на данный момент поддерживается только «ok» (по умолчанию)
+     callback     Нет     String     «false» (по умолчанию) - обновить приложение после успешного выполнения транзакции, «true» - не обновлять приложение, а уведомить с помощью обратной связи
+     uiConf     Нет     String     Кодированные JSON пары ключей/значений, содержащие конфигурацию для отображения UI диалога оплаты. См. раздел «Возможные значения атрибута uiConf» ниже.
+     */
+    function showPayment(name:String, description:String, code:String, price:int, options:String = null, attributes:String = null, currency:String = "ok", callback:String = "true", uiConf:String = null):void;
 }
 }

File as3snapi-core/src/as3snapi/networks/odnoklassnikiru/impl/OdnoklassnikiruApiImpl.as

View file
  • Ignore whitespace
 package as3snapi.networks.odnoklassnikiru.impl {
+
 import as3snapi.api.feautures.social.IFeatureNetworkId;
 import as3snapi.api.feautures.social.IFeatureRefererId;
 import as3snapi.api.feautures.social.IFeatureUserId;
 import as3snapi.base.INetworkModuleContext;
 import as3snapi.base.features.asyncinit.IAsyncInitHandler;
 import as3snapi.base.features.asyncinit.IFeatureAsyncInit;
+import as3snapi.base.features.javascript.IFeatureJavaScript;
+import as3snapi.base.features.javascript.JavaScriptUtils;
 import as3snapi.base.features.requester.IFeatureHttpRequester;
 import as3snapi.networks.odnoklassnikiru.features.IFeatureOdnoklassnikiApi;
 import as3snapi.utils.Md5Utils;
 
-import com.api.forticom.ForticomAPI;
-
 import flash.net.URLRequestMethod;
 
 public class OdnoklassnikiruApiImpl implements IFeatureOdnoklassnikiApi,
     private var requester:IFeatureHttpRequester;
     private var shortNetworkId:String;
 
-    public function OdnoklassnikiruApiImpl(state:OdnoklassnikiruState, context:INetworkModuleContext, shortNetworkId:String) {
+    private var jsUtils:JavaScriptUtils;
+    private var js:IFeatureJavaScript;
+
+    public function OdnoklassnikiruApiImpl(state:OdnoklassnikiruState, context:INetworkModuleContext,
+                                           shortNetworkId:String) {
         this.state = state;
         this.context = context;
         this.shortNetworkId = shortNetworkId;
         this.requester = context.getHttpRequester();
+        jsUtils = context.getJavaScriptUtils();
+        js = context.getJavaScript();
     }
 
     public function init(handler:IAsyncInitHandler):void {
-        ForticomAPI.connection = state.apiconnection;
-        ForticomAPI.addEventListener(ForticomAPI.CONNECTED, function (...rest):void {
-            handler.onSuccess("ok");
-        });
+        jsUtils.callSmart("FAPI.init",
+                state.api_server, state.apiconnection,
+                function (...rest):void {
+                    context.apiLog("FAPI.init OK");
+                    handler.onSuccess("ok");
+                },
+                function (error:*, ...rest):void {
+                    context.apiLog("FAPI.init ERROR " + error);
+                    handler.onFail("" + error);
+                });
     }
 
     public function getShortNetworkId():String {
     }
 
     public function showInvitePopup():void {
-        ForticomAPI.showInvite();
+        js.call("FAPI.UI.showInvite");
     }
 
 
 
     public function getProfilesBase(uids:Array, handler:IProfilesHandler):void {
         apiRequest("/users/getInfo", {
-                    uids:uids.join(','),
-                    fields:"uid,first_name,last_name,gender,pic_1,pic_2,pic_3,pic_4,url_profile"
+                    uids: uids.join(','),
+                    fields: "uid,first_name,last_name,gender,pic_1,pic_2,pic_3,pic_4,url_profile"
                 },
                 function (r:Object):void {
                     if (handler) {
     }
 
 
-    private static const GENDERS:Object = {"male":"m", "female":"f"};
+    private static const GENDERS:Object = {"male": "m", "female": "f"};
 
     private function parseProfile(u:Object, ...rest):IProfile {
         var profile:Profile = new Profile();
                 }, false);
     }
 
-    public function apiRequest(method:String, params:Object, onSuccess:Function, onFail:Function, exeption:Boolean = false):void {
+    public function apiRequest(method:String, params:Object, onSuccess:Function, onFail:Function,
+                               exeption:Boolean = false):void {
         var url:String = state.api_server + "api" + method;
         requester.doRequestJson(url, signRequest(params, exeption), URLRequestMethod.GET, onSuccess, onFail);
     }
         for (i; i < l; i++) {
             sig += keys[i] + "=" + data[keys[i]];
         }
-        sig += (data['uid'] != undefined && !exeption) ? state.config.getSecretKey() : state.session_secret_key;
+        sig += (data['uid'] != undefined && !exeption) ? state.config.getApplicationKey() : state.session_secret_key;
 
         data["sig"] = Md5Utils.hash(sig).toLowerCase();
         return data;
     }
+
+
+    public function showPayment(name:String, description:String, code:String, price:int, options:String = null,
+                                attributes:String = null, currency:String = "ok", callback:String = "true",
+                                uiConf:String = null):void {
+        js.call("FAPI.UI.showPayment", name, description, code, price, options, attributes, currency, callback);
+    }
 }
 }

File as3snapi-core/src/as3snapi/networks/vkcom/features/IFeatureVkcomApiUi.as

View file
  • Ignore whitespace
     function showOrderBoxOffers(offer_id:int):void ;
 
     function showOrderBoxItem(item:String):void ;
-
-    function showSettingsBox(settings:int):void;
 }
 }

File as3snapi-core/src/as3snapi/networks/vkcom/impl/VkcomApiUi.as

View file
  • Ignore whitespace
     }
 
     public function showOrderBoxVotes(votes:int):void {
-        showOrderBox({"type": "votes", "votes": votes});
+        showOrderBox({"type":"votes", "votes":votes});
     }
 
     public function showOrderBoxOffers(offer_id:int):void {
-        showOrderBox({"type": "offers", "offer_id": offer_id});
+        showOrderBox({"type":"offers", "offer_id":offer_id});
     }
 
     public function showOrderBoxItem(item:String):void {
-        showOrderBox({"type": "item", "item": item});
-    }
-
-    public function showSettingsBox(settings:int):void {
-        methods.callMethod("showSettingsBox", settings);
+        showOrderBox({"type":"item", "item":item});
     }
 }
 }

File as3snapi-core/src/as3snapi/networks/vkcom/impl/VkcomDriverLC.as

View file
  • Ignore whitespace
 package as3snapi.networks.vkcom.impl {
+
 import as3snapi.base.INetworkModuleContext;
 import as3snapi.networks.vkcom.features.*;
+import as3snapi.utils.JsonUtils;
 
 import flash.events.IEventDispatcher;
 import flash.events.StatusEvent;
         receivingLC = new LocalConnection();
         receivingLC.allowDomain('*');
         receivingLC.client = {
-            initConnection:initConnection,
-            apiCallback:apiCallback,
-            customEvent:customEvent
+            initConnection: initConnection,
+            apiCallback: apiCallback,
+            customEvent: customEvent
         };
 
         event("onBalanceChanged");
 
         function event(event:String):void {
             receivingLC.client[event] = function (...params):void {
-                context.eventLog({event:event, params:params});
+                context.eventLog(JsonUtils.universalDump({event: event, params: params}));
                 dispatcher.dispatchEvent(new EventVkcom(event, params));
             }
         }
                 setTimeout(apiCall, 500, method, params, onSuccess, onFail);
                 return;
             }
-            context.apiLog({method:method, params:params, result:result});
+            context.apiLog(JsonUtils.universalDump({method: method, params: params, result: result}));
             if (result.error) {
                 onFail(result);
             } else {
 
 
     private function customEvent(event:String, ...params):void {
-        context.eventLog({event:event, params:params});
+        context.eventLog(JsonUtils.universalDump({event: event, params: params}));
         dispatcher.dispatchEvent(new EventVkcom(event, params));
     }
 

File as3snapi-core/src/as3snapi/networks/vkcom/impl/VkcomMethodsJs.as

View file
  • Ignore whitespace
 package as3snapi.networks.vkcom.impl {
+
 import as3snapi.base.INetworkModuleContext;
 import as3snapi.base.features.javascript.IFeatureJavaScript;
 import as3snapi.base.features.javascript.JavaScriptUtils;
 import as3snapi.networks.vkcom.features.*;
+import as3snapi.utils.JsonUtils;
 
 import flash.events.IEventDispatcher;
 
             jsUtils.callSmart("VK.addCallback", event, jsUtils.permanent(eventProxy));
             function eventProxy(...rest):void {
                 var params:Object = rest ? rest[0] : null;
-                context.eventLog({event:event, params:params});
+                context.eventLog(JsonUtils.universalDump({event: event, params: params}));
                 dispatcher.dispatchEvent(new EventVkcom(event, params));
             }
         }

File as3snapi-core/src/as3snapi/networks/vkcom/impl/VkcomRequesterJs.as

View file
  • Ignore whitespace
 package as3snapi.networks.vkcom.impl {
+
 import as3snapi.base.INetworkModuleContext;
 import as3snapi.base.features.javascript.JavaScriptUtils;
 import as3snapi.networks.vkcom.features.IFeatureVkcomRequester;
+import as3snapi.utils.JsonUtils;
 
 import flash.utils.setTimeout;
 
                 setTimeout(apiCall, 500, method, params, onSuccess, onFail);
                 return;
             }
-            context.apiLog({method:method, params:params, result:result});
+            context.apiLog(JsonUtils.universalDump({method: method, params: params, result: result}));
             if ("response" in result) {
                 onSuccess(result);
             } else {

File as3snapi-core/src/as3snapi/utils/JsonUtils.as

View file
  • Ignore whitespace
 package as3snapi.utils {
+
 import com.adobe.serialization.json.JSON;
 
 /**
     public static function decode(s:String):* {
         return com.adobe.serialization.json.JSON.decode(s);
     }
+
+    public static function universalDump(msg:*):String {
+        return msg is String ? msg : JsonUtils.encode(msg);
+    }
+
 }
 }