Examples of TiDict


Examples of org.appcelerator.titanium.TiDict

            Log.e(LCAT, "Runtime Error: " + message);
            return null;
  }
       
        public TiDict processMessage(final TiDict msg) {
            TiDict result = new TiDict();
            boolean timeout = false;
           
            result.put("session-id", msg.getString("session-id"));
            result.put("id", msg.getInt("id"));
            result.put("type", "eval_response");

            FutureTask<Object> future =
                new FutureTask<Object>(new Callable<Object>() {
                        public Object call() {
                            Object result = doEvalJS(msg.getString("src"));
                            //Log.d(LCAT, "ReplSession.processMessage.result: "+result.toString());
                            return result;
                        }});

            try {
                kc.post(future);
                Object futureResult = future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
                if(futureResult instanceof Throwable) {
                    //Log.d(LCAT, "ReplSession.future.get: "+futureResult.toString());
                    result.put("status", "error");
                    result.put("result", futureResult);
                }
                else {
                    //Log.d(LCAT, "ReplSession.future.get: "+futureResult.toString());
                    result.put("status", "ok");
                    result.put("result", futureResult);
                }
            } catch (InterruptedException e) {
                Log.d(LCAT, "InterruptedException executing the task", e);
                e.printStackTrace(out);
                result.put("status", "ERROR");
                result.put("result", e);
            } catch (ExecutionException e) {
                Log.d(LCAT, "ExecutionException executing the task", e);
                Log.d(LCAT, "ExecutionException cause", e.getCause());
                e.getCause().printStackTrace(out);
                result.put("status", "ERROR");
                result.put("result", e);
            } catch (TimeoutException e) {
                Log.d(LCAT, "TimeoutException executing the task", e);
                timeout = true;
                e.printStackTrace(out);
                result.put("status", "ERROR");
                result.put("result", e);
            } catch (CancellationException e) {
                Log.d(LCAT, "CancellationException executing the task", e);
                e.printStackTrace(out);
                result.put("status", "ERROR");
                result.put("result", e);
            } finally {
                if (timeout) {
                    future.cancel(true);
                }
            }
View Full Code Here

Examples of org.appcelerator.titanium.TiDict

                        try {
                            String jsonmsg = new String(Base64.decodeBase64(rawmsg.getBytes()));
                            //Log.d(LCAT, "ReplSession.got jsonmsg: "+jsonmsg);
                            JSONObject json = new JSONObject(jsonmsg);
                            //Log.d(LCAT, "ReplSession.got json: "+json);
                            TiDict msgDict = new TiDict(json);
                            //Log.d(LCAT, "ReplSession.got msgDict: "+msgDict);
                            TiDict respDict = processMessage(msgDict);

                            String respJson = respDict.toString();
                            String resp64 = new String(Base64.encodeBase64(respJson.getBytes()));
                            out.println("/message_response "+resp64);
                            out.flush();
                            prompt();
                        } catch (JSONException jse) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.