public override void API(string APIMethod, IDictionary <string, string> queryParams, Action <APICallResponse> callback = null) { string callbackId = ""; if (callback != null) { callbackId = callbackManager.RegisterCallback(callback).ToString(); } List <string> paramsList = new List <string>(); foreach (var queryParam in queryParams) { paramsList.Add(queryParam.Key); paramsList.Add(queryParam.Value); } APICallRequest apiCallRequest = new APICallRequest() { callbackId = callbackId, methodName = APIMethod, parameters = paramsList }; string requestData = JsonUtility.ToJson(apiCallRequest); VKLogger.Info("WebVKClient.API methodName = " + APIMethod + ", args = " + requestData); JSBridge.Handler("API", requestData, ResultHandler); }
public void OnAPICallComplete(string responseStr) { VKLogger.Info("VKClientBase.OnAPICallComplete: resultStr = " + responseStr); var apiCallResponse = JsonHelper.FromJson <APICallResponse>(responseStr); callbackManager.HandleResponse(apiCallResponse); }
public static void CallbackHandler(string stringifiedResponse) { VKLogger.Info("WebVKClient.CallbackHandler result = " + stringifiedResponse); APICallResponse acr = new APICallResponse(); acr = JsonUtility.FromJson <APICallResponse>(stringifiedResponse); acr.responseJsonString = WWW.UnEscapeURL(acr.responseJsonString); callbackManager.HandleCallback(acr); }
public virtual void OnInitComplete(string resultStr) { VKLogger.Info("VKClientBase.OnInitComplete: resultStr = " + resultStr); HandleAuthResponse(JsonHelper.FromJson <AuthResponse>(resultStr)); if (_initializedCallback != null) { _initializedCallback(); _initializedCallback = null; } }
public void OnLoginComplete(string resultStr) { VKLogger.Info("VKClientBase.OnLoginComplete: resultStr = " + resultStr); var authResponse = JsonHelper.FromJson <AuthResponse>(resultStr); HandleAuthResponse(authResponse); if (_loggedInCallback != null) { _loggedInCallback(authResponse); _loggedInCallback = null; } }
public override void RemoveCallback(string eventName, string callbackId) { if (!int.TryParse(callbackId, out int id) || id < 1) { throw new ArgumentException("Incorrect callback ID"); } GenericRequest request = new GenericRequest(); request.AddString("callbackId", callbackId); request.AddString("eventName", eventName); string requestData = request.ToJsonString(); VKLogger.Info("WebVKClient.RemoveCallback for " + eventName + ", args = " + requestData); JSBridge.Handler("RemoveCallback", requestData); callbackManager.RemoveCallback(id); }
public static void Init(VKInitParams initParams, Action initializedCallback = null) { if (initParams == null) { throw new ArgumentNullException(nameof(initParams)); } VKLogger.Info("VKSDK.Init: appId = " + initParams.AppId + ", apiVersion = " + initParams.ApiVersion ?? "[none]"); long appId = initParams.AppId; if (Application.platform == RuntimePlatform.WebGLPlayer && appId != ParseApplicationIdFromQueryString()) { throw new ArgumentException("AppId (" + appId + ") doesn't match appId (" + ParseApplicationIdFromQueryString() + ") from the query string."); } if (appId <= 0) { throw new ArgumentException("Incorrect appId"); } AppId = appId; if (!_isInitialized) { _isInitialized = true; VKLoader loader = VKLoaderHelper.GetLoaderForCurrentPlatform(); if (loader == null) { VKLogger.Warn("VK does not yet support this platform."); } else { loader.InitParams = initParams; loader.InitializedCallback = initializedCallback; } } else { VKLogger.Warn("VK.Init() has already been called. You only need to call this once and only once."); } }
public override void AddCallback(string eventName, Action <APICallResponse> callback = null) { string callbackId = ""; if (callback != null) { callbackId = callbackManager.RegisterCallback(callback).ToString(); } GenericRequest request = new GenericRequest(); request.AddString("callbackId", callbackId); request.AddString("eventName", eventName); string requestData = request.ToJsonString(); VKLogger.Info("WebVKClient.AddCallback for " + eventName + ", args = " + requestData); JSBridge.Handler("AddCallback", requestData, CallbackHandler); }
public override void LogIn(IEnumerable <Scope> scope, Action <AuthResponse> callback = null) { VKLogger.Error(MESSAGE_UNSUPPORTED_PLATFORM); }
public override void LogOut() { VKLogger.Error(MESSAGE_UNSUPPORTED_PLATFORM); }
public override void OnInitComplete(string resultStr) { VKLogger.Error(MESSAGE_UNSUPPORTED_PLATFORM); }
public static void CallStatic(string methodName, params object[] args) { VKLogger.Info("AndroidNativeHelper.CallStatic methodName = " + methodName + ", args = " + args.ToList().GetCommaSeparated()); vkJavaClass.CallStatic(methodName, args); }