summaryrefslogtreecommitdiff
path: root/native/android/avatar/src/main/java/com/ford/avarsdl/jsoncontroller/JSONAVAController.java
diff options
context:
space:
mode:
Diffstat (limited to 'native/android/avatar/src/main/java/com/ford/avarsdl/jsoncontroller/JSONAVAController.java')
-rw-r--r--native/android/avatar/src/main/java/com/ford/avarsdl/jsoncontroller/JSONAVAController.java141
1 files changed, 62 insertions, 79 deletions
diff --git a/native/android/avatar/src/main/java/com/ford/avarsdl/jsoncontroller/JSONAVAController.java b/native/android/avatar/src/main/java/com/ford/avarsdl/jsoncontroller/JSONAVAController.java
index f3185ce582..e7f75dd6df 100644
--- a/native/android/avatar/src/main/java/com/ford/avarsdl/jsoncontroller/JSONAVAController.java
+++ b/native/android/avatar/src/main/java/com/ford/avarsdl/jsoncontroller/JSONAVAController.java
@@ -1,84 +1,67 @@
package com.ford.avarsdl.jsoncontroller;
-import android.util.Log;
-
-import com.ford.avarsdl.activity.AvatarActivity;
-import com.ford.avarsdl.util.Const;
+import com.ford.avarsdl.views.AvatarActivity;
+import com.ford.avarsdl.util.Logger;
import com.ford.avarsdl.util.RPCConst;
-public class JSONAVAController extends JSONController{
-
- private final boolean DEBUG = true;
- private String mJSComponentName = null;
- private final String TAG_NAME = "AVAController";
- private AvatarActivity mActivity;
-
- public JSONAVAController(AvatarActivity activity, String cname) {
- super(RPCConst.CN_AVATAR);
- mActivity = activity;
- mJSComponentName = cname;
- }
-
- public JSONAVAController(String cname, ITcpClient client) {
- super(RPCConst.CN_AVATAR,client);
- mJSComponentName = cname;
- }
-
-
- protected void processRequest(String request){
- processNotification(request);
- }
-
- protected String processNotification(String notification){
- logMsg("Process notification");
- mJSONParser.putJSONObject(notification);
- final String func = "FFW.WebSocketSimulator.receive('" + mJSComponentName
- + "','" + notification + "')";
- //LogMsg(func);
- logMsg("Send notification to JS");
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mActivity.getWebView().loadUrl("javascript:" + func);
- }
- });
- return null;
- }
-
- protected void processResponse(String response){
- if (!processRegistrationResponse(response)){
- final String func = "FFW.WebSocketSimulator.receive('" + mJSComponentName
- + "','" + response + "')";
- logMsg(func);
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mActivity.getWebView().loadUrl("javascript:" + func);
- }
- });
- }
-
-
- }
-
- public void sendJSMessage(String cName, String jsonMsg){
- logMsg("SendJSMessage : " + jsonMsg);
- mJSONParser.putJSONObject(jsonMsg);
- if(mJSONParser.getId()>=0 &&
- mJSONParser.getResult() == null &&
- mJSONParser.getError() == null){
- mJSComponentName = cName;
- }
- jsonMsg += System.getProperty("line.separator");
- sendJSONMsg(jsonMsg);
-
- }
-
- private void logMsg(String msg){
- if (DEBUG && Const.DEBUG){
- Log.i(TAG_NAME, msg);
- }
- }
+public class JSONAVAController extends JSONController {
+
+ private String mJSComponentName = null;
+ private AvatarActivity mActivity;
+
+ public JSONAVAController(AvatarActivity activity, String cname) {
+ super(RPCConst.CN_AVATAR);
+ mActivity = activity;
+ mJSComponentName = cname;
+ }
+
+ public JSONAVAController(String cname, ITcpClient client) {
+ super(RPCConst.CN_AVATAR, client);
+ mJSComponentName = cname;
+ }
+
+ protected void processRequest(String request) {
+ processNotification(request);
+ }
+
+ protected String processNotification(String notification) {
+ Logger.d(getClass().getSimpleName() + " Process notification: " + notification);
+ mJSONParser.putJSONObject(notification);
+ final String func = "FFW.WebSocketSimulator.receive('" + mJSComponentName
+ + "','" + notification + "')";
+ Logger.d(getClass().getSimpleName() + " Send notification to JS");
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mActivity.getWebView().loadUrl("javascript:" + func);
+ }
+ });
+ return null;
+ }
+
+ protected void processResponse(String response) {
+ if (!processRegistrationResponse(response)) {
+ final String func = "FFW.WebSocketSimulator.receive('" + mJSComponentName
+ + "','" + response + "')";
+ Logger.d(getClass().getSimpleName() + " : " + func);
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mActivity.getWebView().loadUrl("javascript:" + func);
+ }
+ });
+ }
+ }
-
-}
+ public void sendJSMessage(String cName, String jsonMsg) {
+ //Logger.d(getClass().getSimpleName() + " SendJSMessage : " + jsonMsg);
+ mJSONParser.putJSONObject(jsonMsg);
+ if (mJSONParser.getId() >= 0 &&
+ mJSONParser.getResult() == null &&
+ mJSONParser.getError() == null) {
+ mJSComponentName = cName;
+ }
+ jsonMsg += System.getProperty("line.separator");
+ sendJSONMsg(jsonMsg);
+ }
+} \ No newline at end of file