Esempio n. 1
0
        protected void handleInteractStatus(Command command)
        {
            Logger.d("handleGetCurrentScene " + command.recvObj);
            List <String> buttonTypes = null;

            try
            {
                buttonTypes = JsonParser.Deserialization <List <String> >(command);
            }
            catch (System.Exception ex)
            {
                buttonTypes = new List <string>();
            }


            try
            {
                InteractStatus status = new InteractStatus();

                List <InteractElement> elements = uiHelper.GetInteractElements(buttonTypes);

                status.elements = elements;

                status.scenename = U3DManager.GetSceneName();

                command.sendObj = status;
            }
            catch (System.Exception ex)
            {
                Logger.w(ex.Message + " " + ex.StackTrace);
                command.status  = ResponseStatus.UN_KNOW_ERROR;
                command.sendObj = ex.Message + " " + ex.StackTrace;
            }
            CommandDispatcher.SendCommand(command);
        }
Esempio n. 2
0
        protected void handleCallRegisteredHandler(Command command)
        {
            Logger.d("handleCallRegisteredHandler");

            try
            {
                CustomCaller caller = JsonParser.Deserialization <CustomCaller>(command);
                string       result;
                bool         r = CustomHandler.Call(caller.name, caller.args, out result);
                if (r)
                {
                    command.sendObj = result;
                }
                else
                {
                    command.status  = ResponseStatus.NO_SUCH_HANDLER;
                    command.sendObj = "No such handler: " + caller.name;
                }
            }
            catch (System.Exception ex)
            {
                Logger.w(ex.Message + " " + ex.StackTrace);
                command.status  = ResponseStatus.UN_KNOW_ERROR;
                command.sendObj = ex.Message + " " + ex.StackTrace;
            }
            CommandDispatcher.SendCommand(command);
        }
Esempio n. 3
0
 protected void handleGetElementByPos(Command command)
 {
     Logger.d("handleGetElementByPos");
     try
     {
         List <double>     pos          = JsonParser.Deserialization <List <double> >(command);
         float             x            = (float)pos[0];
         float             y            = (float)pos[1];
         List <GameObject> selectedObjs = uiHelper.FindGameObjectsByPoint(new Point(x, y));
         if (selectedObjs == null || selectedObjs.Count == 0)
         {
             command.status  = ResponseStatus.GAMEOBJ_NOT_EXIST;
             command.sendObj = "";
             CommandDispatcher.SendCommand(command);
             return;
         }
         ElementInfo element  = new ElementInfo();
         GameObject  obj      = selectedObjs[0];
         string      name     = GameObjectTool.GenerateNamePath(obj);
         int         instance = GameObjectManager.INSTANCE.AddGameObject(obj);
         element = new ElementInfo(name, instance);
         Logger.d("Element name = " + element.name + " ,instance =" + element.instance);
         command.sendObj = element;
     }
     catch (System.Exception ex)
     {
         Logger.w(ex.Message + " " + ex.StackTrace);
         command.status  = ResponseStatus.UN_KNOW_ERROR;
         command.sendObj = ex.Message + " " + ex.StackTrace;
     }
     CommandDispatcher.SendCommand(command);
 }
Esempio n. 4
0
 protected void handleGetNodeText(Command command)
 {
     Logger.d("handleGetNodeText +" + command.recvObj);
     try
     {
         int        instance   = int.Parse(command.recvObj);
         GameObject gameObject = GameObjectManager.INSTANCE.FindGameObjectGlobal(instance);
         if (null == gameObject)
         {
             //返回无该gameobject
             command.status  = ResponseStatus.GAMEOBJ_NOT_EXIST;
             command.sendObj = "GameObject " + instance + " is not exists";
             return;
         }
         string text = uiHelper.GetText(gameObject);
         if (text == null)
         {
             command.sendObj = "No Component with text";
             command.status  = ResponseStatus.NO_SUCH_RESOURCE;
         }
         else
         {
             command.sendObj = text;
         }
     }
     catch (System.Exception ex)
     {
         Logger.w(ex.Message + " " + ex.StackTrace);
         command.status  = ResponseStatus.UN_KNOW_ERROR;
         command.sendObj = ex.Message + " " + ex.StackTrace;
     }
     CommandDispatcher.SendCommand(command);
 }
Esempio n. 5
0
        protected void handleSetCamera(Command command)
        {
            Logger.d("handleSetCamera");

            try
            {
                List <String> camerName = JsonParser.Deserialization <List <String> >(command);
                if (camerName.Count > 0)
                {
                    String oldCamera = NGUIHelper.setCamera(camerName[0]);
                }
                else
                {
                    command.status  = ResponseStatus.UN_KNOW_ERROR;
                    command.sendObj = "need camera name ";
                }
            }
            catch (System.Exception ex)
            {
                Logger.w(ex.Message + " " + ex.StackTrace);
                Logger.e("***************************" + ex.Message + " " + ex.StackTrace);
                command.status  = ResponseStatus.UN_KNOW_ERROR;
                command.sendObj = ex.Message + " " + ex.StackTrace;
            }
            CommandDispatcher.SendCommand(command);
        }
Esempio n. 6
0
 protected void handleEnterRecord(Command command)
 {
     Logger.d("handleEnterRecord");
     recordSocket = command.socket;
     CommandDispatcher.SendCommand(command);
     RecordMode = true;
 }
Esempio n. 7
0
        protected void handleGetElementsByComponent(Command command)
        {
            Logger.d("handleGetElementsByComponent " + command.recvObj);
            List <string> componentNames = JsonParser.Deserialization <List <string> >(command);

            string componentName = componentNames[0];

            List <GameObject>  objs;
            List <ElementInfo> elements = new List <ElementInfo>();

            command.sendObj = elements;
            try
            {
                objs = GameObjectManager.INSTANCE.FindByComponent(componentName);
                foreach (GameObject obj in objs)
                {
                    string      name     = GameObjectTool.GenerateNamePath(obj);
                    int         instance = GameObjectManager.INSTANCE.AddGameObject(obj);
                    ElementInfo e        = new ElementInfo(name, instance);
                    elements.Add(e);
                    Logger.d("Element name = " + e.name + " ,instance =" + e.instance);
                }
            }
            catch (System.Exception ex)
            {
                Logger.w(ex.Message + " " + ex.StackTrace);
                command.status = ResponseStatus.UN_KNOW_ERROR;
            }
            CommandDispatcher.SendCommand(command);
        }
Esempio n. 8
0
        protected void handleGetObjectField(Command command)
        {
            Logger.d("handleGetElementsBound" + command.recvObj);

            ComponentField componentField = JsonParser.Deserialization <ComponentField>(command);

            GameObject obj = GameObjectManager.INSTANCE.FindGameObjectGlobal(componentField.instance);

            if (obj == null)
            {
                command.status = ResponseStatus.GAMEOBJ_NOT_EXIST;
            }
            else
            {
                try
                {
                    object value = ReflectionTools.GetComponentAttribute(obj, componentField.comopentName, componentField.attributeName);
                    if (value != null)
                    {
                        command.sendObj = value.ToString();
                    }
                }
                catch (System.Exception ex)
                {
                    command.status  = ResponseStatus.REFLECTION_ERROR;
                    command.sendObj = ex.Message;
                }
            }

            CommandDispatcher.SendCommand(command);
        }
Esempio n. 9
0
        /// <summary>
        /// 根据名称查找控件。控件不存在则返回instance=-1
        /// </summary>
        /// <param name="command"></param>
        protected void handleGetElements(Command command)
        {
            Logger.d("handleGetElements +" + command.recvObj);
            List <string>      elementNames = JsonParser.Deserialization <List <string> >(command);
            List <ElementInfo> elements     = new List <ElementInfo>();

            foreach (string s in elementNames)
            {
                Logger.d("element name = " + s);
                ElementInfo e = new ElementInfo();
                elements.Add(e);
                try
                {
                    GameObject obj = GameObjectManager.INSTANCE.FindGameObject(s);
                    if (obj != null)
                    {
                        e.instance = GameObjectManager.INSTANCE.AddGameObject(obj);
                        e.name     = s;
                    }
                    else
                    {
                        e.instance = -1;
                        e.name     = s;
                    }
                }
                catch (System.Exception ex)
                {
                    Logger.w(ex.Message + " " + ex.StackTrace);
                    e.instance = -1;
                }
            }
            command.sendObj = elements;
            CommandDispatcher.SendCommand(command);
        }
Esempio n. 10
0
        protected void handleGetObjectMethods(Command command)
        {
            Logger.d("handleGetObjectMethods" + command.recvObj);
            try
            {
                ComponentMethod componentField = JsonParser.Deserialization <ComponentMethod>(command);

                GameObject obj = GameObjectManager.INSTANCE.FindGameObjectGlobal(componentField.instance);

                if (obj == null)
                {
                    command.status = ResponseStatus.GAMEOBJ_NOT_EXIST;
                }
                else
                {
                    MethodDetail[] methods = ReflectionTools.GetComponentMethods(obj, componentField.comopentName);
                    Logger.d("Methods Count: " + methods.Length);
                    command.sendObj = methods;
                }
            }
            catch (System.Exception ex)
            {
                command.status  = ResponseStatus.REFLECTION_ERROR;
                command.sendObj = ex.Message;
            }

            CommandDispatcher.SendCommand(command);
        }
Esempio n. 11
0
        private void PushTouchAction()
        {
            while (run)
            {
                try
                {
                    TouchActions actions = actionsQueue.Dequeue();

                    if (actions.events != null)
                    {
                        for (int i = 0; i < actions.events.Length; ++i)
                        {
                            TouchEvent touchEvent = actions.events[i];
                            AddEvent(touchEvent);
                            if (touchEvent.sleeptime > 0)
                            {
                                Thread.Sleep(touchEvent.sleeptime);
                            }
                        }
                    }

                    if (actions.cmd != null)
                    {
                        CommandDispatcher.SendCommand(actions.cmd);
                    }
                }
                catch (System.Exception ex)
                {
                    Logger.w(ex.Message + "\n" + ex.StackTrace);
                }
            }
        }
Esempio n. 12
0
        protected void handleSetInputText(Command command)
        {
            Logger.d("handleSetInputText +" + command.recvObj);
            TextSetter textSetter = JsonParser.Deserialization <TextSetter>(command);

            try
            {
                GameObject gameObject = GameObjectManager.INSTANCE.FindGameObjectGlobal(textSetter.instance);
                if (null == gameObject)
                {
                    //返回无该gameobject
                    command.status  = ResponseStatus.GAMEOBJ_NOT_EXIST;
                    command.sendObj = "GameObject " + instance + " is not exists";
                    CommandDispatcher.SendCommand(command);
                    return;
                }
                else
                {
                    string oldContent = uiHelper.SetInputText(gameObject, textSetter.content);
                    command.sendObj = oldContent;
                }
            }
            catch (System.Exception ex)
            {
                Logger.w(ex.Message + " " + ex.StackTrace);
                command.status  = ResponseStatus.UN_KNOW_ERROR;
                command.sendObj = ex.Message + " " + ex.StackTrace;
            }

            CommandDispatcher.SendCommand(command);
        }
Esempio n. 13
0
        protected void handleCallObjectMethod(Command command)
        {
            //Logger.d("handleCallObjectMethod" + command.recvObj);
            Logger.d("handleCallObjectMethod" + command.recvObj);
            try
            {
                ComponentMethodCall componentCall = JsonParser.Deserialization <ComponentMethodCall>(command);
                GameObject          obj           = GameObjectManager.INSTANCE.FindGameObjectGlobal(componentCall.instance);

                if (obj == null)
                {
                    command.status = ResponseStatus.GAMEOBJ_NOT_EXIST;
                }
                else
                {
                    object result = ReflectionTools.CallComponentMethod(obj, componentCall.comopentName, componentCall.methodName, componentCall.parameters);
                    Logger.d("Result is " + result.ToString());
                    command.sendObj = result.ToString();
                }
            }
            catch (System.Exception ex)
            {
                command.status  = ResponseStatus.REFLECTION_ERROR;
                command.sendObj = ex.Message;
            }
            CommandDispatcher.SendCommand(command);
        }
Esempio n. 14
0
        protected void handleGetVersion(Command command)
        {
            VersionData version = new VersionData();

            version.engineVersion = Application.unityVersion;
            command.sendObj       = version;
            Logger.d("Engine=" + version.engine + "; Version=" + version.sdkVersion + "; UnityVersion=" + version.engineVersion + "; UI=" + version.sdkUIType);
            CommandDispatcher.SendCommand(command);
        }
Esempio n. 15
0
        protected void handleGetStreamData(Command command)
        {
            Logger.d("handleGetStreamData");
            AppNetTrafficRes appNetTrafficRes = new AppNetTrafficRes();

            if (!netReadInvaild)
            {
                command.status  = ResponseStatus.UN_KNOW_ERROR;
                command.sendObj = "";
            }
            else
            {
                try
                {
                    AppNetReq req = JsonParser.Deserialization <AppNetReq>(command);
                    int       uid = req.uid;
                    Debug.Log("----------------" + uid + "----------------");
                    string recvPath = "/proc/uid_stat/" + uid + "/tcp_rcv";
                    string sendPath = "/proc/uid_stat/" + uid + "/tcp_snd";

                    int appRecv = 0;
                    int appSend = 0;
                    lock (netlocker)
                    {
                        int systemRecv = getNetData(recvPath);
                        int systemSend = getNetData(sendPath);
                        if (systemRecv == -1 || systemSend == -1)
                        {
                            //读取流量失败的,后面也一定会继续失败
                            netReadInvaild = false;
                        }
                        appRecv = systemRecv - recvByte;
                        appSend = systemSend - sendByte;
                    }

                    Logger.v("App(uid:" + uid + ") recv size:" + appRecv + " send size:" + appSend);

                    appNetTrafficRes.input  = appRecv;
                    appNetTrafficRes.output = appSend;
                    command.sendObj         = appNetTrafficRes;
                }
                catch (System.Exception ex)
                {
                    Logger.w(ex.Message + " " + ex.StackTrace);
                    command.status  = ResponseStatus.UN_KNOW_ERROR;
                    command.sendObj = ex.Message + " " + ex.StackTrace;
                }
            }

            CommandDispatcher.SendCommand(command);
        }
Esempio n. 16
0
        /// <summary>
        /// 获取GameObject在屏幕上的位置信息
        /// </summary>
        /// <param name="command"></param>
        protected void handleGetElementsBound(Command command)
        {
            Logger.d("handleGetElementsBound" + command.recvObj);
            List <int>       instances  = JsonParser.Deserialization <List <int> >(command);
            List <BoundInfo> boundInfos = new List <BoundInfo>();


            foreach (int instance in instances)
            {
                GameObject obj   = GameObjectManager.INSTANCE.FindGameObjectGlobal(instance);
                BoundInfo  bound = new BoundInfo();
                bound.instance = instance;
                boundInfos.Add(bound);
                try
                {
                    if (obj != null)
                    {
                        Rectangle rc = uiHelper.GetBound(obj);
                        if (rc == null)
                        {
                            bound.visible = false;
                        }
                        else
                        {
                            bound.x       = rc.x;
                            bound.y       = rc.y;
                            bound.width   = rc.width;
                            bound.height  = rc.height;
                            bound.visible = obj.activeInHierarchy;
                        }
                        bound.path = GameObjectTool.GenerateNamePath(obj);
                    }
                    else
                    {
                        bound.existed = false;
                    }
                }
                catch (System.Exception ex)
                {
                    Logger.w(ex.Message + " " + ex.StackTrace);
                    bound.visible = false;
                }
            }

            foreach (BoundInfo b in boundInfos)
            {
                Logger.d("Bound width = " + b.width + " height = " + b.height + " x = " + b.x + " y=" + b.y + " existed = " + b.existed + " visible = " + b.visible);
            }
            command.sendObj = boundInfos;
            CommandDispatcher.SendCommand(command);
        }
Esempio n. 17
0
 protected void handleGetCurrentScene(Command command)
 {
     Logger.d("handleGetCurrentScene");
     try
     {
         command.sendObj = Application.loadedLevelName;
     }
     catch (System.Exception ex)
     {
         Logger.w(ex.Message + " " + ex.StackTrace);
         command.status  = ResponseStatus.UN_KNOW_ERROR;
         command.sendObj = ex.Message + " " + ex.StackTrace;
     }
     CommandDispatcher.SendCommand(command);
 }
Esempio n. 18
0
 protected void handleGetFPS(Command command)
 {
     Logger.d("handleGetFPS");
     try
     {
         command.sendObj = (uint)fps;
     }
     catch (System.Exception ex)
     {
         Logger.w(ex.Message + " " + ex.StackTrace);
         command.status  = ResponseStatus.UN_KNOW_ERROR;
         command.sendObj = ex.Message + " " + ex.StackTrace;
     }
     CommandDispatcher.SendCommand(command);
 }
Esempio n. 19
0
 protected void handleLoadTestLib(Command command)
 {
     try
     {
         Logger.d("handleLoadTestLib");
         ReflectionTools.testLibInit();
         command.sendObj = "OK";
     }
     catch (System.Exception ex)
     {
         Logger.w(ex.Message + " " + ex.StackTrace);
         command.status  = ResponseStatus.UN_KNOW_ERROR;
         command.sendObj = ex.Message;
     }
     CommandDispatcher.SendCommand(command);
 }
Esempio n. 20
0
 public IEnumerator HandleCommand()
 {
     while (true)
     {
         Command command = CommandDispatcher.GetCommand();
         if (command == null)
         {
             yield return(null);
         }
         else
         {
             Logger.v("Find command : " + command.cmd + " value :" + command.recvObj);
             try
             {
                 CmdHandler handler = null;
                 if (handlers.TryGetValue(command.cmd, out handler))
                 {
                     long beg = DateTime.Now.Ticks / 10000;
                     handler(command);
                     StringBuilder sb = new StringBuilder();
                     sb.Append("[");
                     sb.Append(command.socket);
                     sb.Append("] Cmd: ");
                     sb.Append(command.cmd);
                     sb.Append(" costs: ");
                     sb.Append(DateTime.Now.Ticks / 10000 - beg);
                     sb.Append("ms");
                     Debug.Log(sb.ToString());
                     sdkUseTime += (DateTime.Now.Ticks / 10000 - beg) / 1000;
                 }
                 else
                 {
                     //没法找到
                     command.status = ResponseStatus.NO_SUCH_CMD;
                     CommandDispatcher.SendCommand(command);
                 }
             }
             catch (System.Exception ex)
             {
                 Logger.d("Handle Command expection =>" + ex.Message + " \n" + ex.StackTrace);
                 command.status = ResponseStatus.UN_KNOW_ERROR;
                 CommandDispatcher.SendCommand(command);
             }
         }
         yield return(null);
     }
 }
Esempio n. 21
0
        protected void handleGetRegisterHandlers(Command command)
        {
            Logger.d("handleGetRegisterHandlers");

            try
            {
                List <string> lists = CustomHandler.GetRegistered();
                command.sendObj = lists;
            }
            catch (System.Exception ex)
            {
                Logger.w(ex.Message + " " + ex.StackTrace);
                command.status  = ResponseStatus.UN_KNOW_ERROR;
                command.sendObj = ex.Message + " " + ex.StackTrace;
            }
            CommandDispatcher.SendCommand(command);
        }
Esempio n. 22
0
        private static int seq = 0;//回调递增

        public static void SetRpcMethod(Command command)
        {
            String name = command.recvObj;

            socket = command.socket;
            if (!functions.ContainsKey(name))
            {
                functions.Add(name, null);
                Logger.d("Add RPC name = " + name);
            }
            else
            {
                Logger.w("name = " + name + " has registered");
            }
            command.sendObj = "OK";
            CommandDispatcher.SendCommand(command);
        }
Esempio n. 23
0
        public static void Invoke(string name, string value, CustomHandler.PcCallBack callback)
        {
            if (functions.ContainsKey(name) || socket == null)
            {
                throw new Exception("Not Register Callback");
            }
            Command command = new Command();

            command.cmd    = Cmd.RPC_METHOD;
            command.socket = socket;
            RPCRequestBody rpcBody = new RPCRequestBody();

            rpcBody.name    = name;
            rpcBody.value   = value;
            rpcBody.seq     = ++seq;
            command.sendObj = rpcBody;
            AddCallBack(rpcBody.seq, callback);
            CommandDispatcher.SendCommand(command);
        }
Esempio n. 24
0
 protected void handleDumpTree(Command command)
 {
     Logger.d("handleDumpTree ");
     try
     {
         string   xml      = GameObjectTool.DumpTree();
         string   scene    = Application.loadedLevelName;
         DumpTree dumpTree = new DumpTree();
         dumpTree.scene  = scene;
         dumpTree.xml    = xml;
         command.sendObj = dumpTree;
     }
     catch (System.Exception ex)
     {
         Logger.w(ex.Message + " " + ex.StackTrace);
         command.status  = ResponseStatus.UN_KNOW_ERROR;
         command.sendObj = ex.Message + " " + ex.StackTrace;
     }
     CommandDispatcher.SendCommand(command);
 }
Esempio n. 25
0
        protected void handleGetNodeImage(Command command)
        {
            Logger.d("handleGetNodeImage +" + command.recvObj);
            int instance = int.Parse(command.recvObj);

            try
            {
                GameObject gameObject = GameObjectManager.INSTANCE.FindGameObjectGlobal(instance);
                if (null == gameObject)
                {
                    //返回无该gameobject
                    command.status  = ResponseStatus.GAMEOBJ_NOT_EXIST;
                    command.sendObj = "GameObject " + instance + " is not exists";
                    return;
                }
                string image = uiHelper.GetImage(gameObject);
                if (image == null)
                {
                    //command.status = ResponseStatus.COMPONENT_NOT_EXIST;
                    //command.sendObj = "Component Image/RawImage/SpriteRender " + instance + " is not exists";
                    command.sendObj = "No Component with image";
                    command.status  = ResponseStatus.NO_SUCH_RESOURCE;
                }
                else
                {
                    command.sendObj = image;
                }
            }
            catch (System.Exception ex)
            {
                Logger.w(ex.Message + " " + ex.StackTrace);
                command.status  = ResponseStatus.UN_KNOW_ERROR;
                command.sendObj = ex.Message + " " + ex.StackTrace;
            }

            CommandDispatcher.SendCommand(command);
        }
Esempio n. 26
0
        protected void handleGetWorldBound(Command command)
        {
            Logger.d("handleGetWorldBound");

            List <int>        instances   = JsonParser.Deserialization <List <int> >(command);
            List <WorldBound> worldBounds = new List <WorldBound>();

            for (int i = 0; i < instances.Count; ++i)
            {
                int        instance   = instances[i];
                GameObject obj        = GameObjectManager.INSTANCE.FindGameObjectGlobal(instance);
                WorldBound worldBound = null;
                try
                {
                    if (obj != null)
                    {
                        worldBound = uiHelper.GetWorldBound(obj);
                    }
                    else
                    {
                        worldBound         = new WorldBound();
                        worldBound.existed = false;
                    }
                }
                catch (System.Exception ex)
                {
                    Logger.w(ex.Message + " " + ex.StackTrace);
                    worldBound         = new WorldBound();
                    worldBound.existed = false;
                }
                worldBound.id = instance;
                worldBounds.Add(worldBound);
            }

            command.sendObj = worldBounds;
            CommandDispatcher.SendCommand(command);
        }
Esempio n. 27
0
        protected void NotifyTouchElement()
        {
            try
            {
                Cmd     cmd       = Cmd.TOUCH_NOTIFY;
                Command command   = new Command(cmd, recordSocket);
                Touch[] touchs    = Input.touches;
                int     fingerNum = touchs.Length;
                if (fingerNum == 0)
                {
                    return;
                }
                bool        finded      = false;
                TouchNotify touchNotify = new TouchNotify();
                string      scene       = Application.loadedLevelName;
                touchNotify.scene = scene;
                for (int i = 0; i < fingerNum && i < 5; ++i)
                {
                    Touch t = touchs[i];
                    Logger.d("Touch delta time = {0},x = {1},y={2} ,fingerId = {3},phase = {4}", t.deltaTime * Time.timeScale, t.position.x, t.position.y, t.fingerId, t.phase);
                    //只考虑,一个点的情况,Begin的时候
                    if (t.phase == TouchPhase.Began && !finded)
                    {
                        GameObject selectedObj = null;
                        try
                        {
                            selectedObj = NGUITools.FindElementByUnityPos(new Point(t.position.x, t.position.y));
                        }
                        catch (System.Exception ex)
                        {
                            Logger.v(ex.StackTrace);
                        }
                        if (selectedObj != null && NGUITools.IsInteraction(selectedObj))
                        {
                            finded = true;
                            String name = GameObjectTool.GenerateNamePath(selectedObj);
                            Logger.d("Touch UI = " + name);
                            touchNotify.name = name;
                        }
                    }
                    if (t.phase == TouchPhase.Canceled || t.phase == TouchPhase.Stationary || t.phase == TouchPhase.Moved)
                    {
                        continue;
                    }
                    TouchData td = new TouchData();
                    td.deltatime = DateTime.Now.Ticks / 10000 - startTime;
                    td.fingerId  = (short)t.fingerId;
                    Point point = CoordinateTool.ConvertUnity2Mobile(t.position);
                    td.x         = point.X;
                    td.y         = point.Y;
                    td.relativeX = t.position.x / Screen.width;
                    td.relativeY = (Screen.height - t.position.y) / Screen.height;
                    switch (t.phase)
                    {
                    case TouchPhase.Began:
                        td.phase = (byte)TouchType.TOUCH_DOWN;
                        break;

                    //case TouchPhase.Moved:
                    //    td.bPhase = (byte)ATTouchType.AT_TOUCH_MOVE;
                    //    break;
                    case TouchPhase.Ended:
                        td.phase = (byte)TouchType.TOUCH_UP;
                        break;
                    }
                    touchNotify.touches.Add(td);
                }
                if (touchNotify.touches.Count > 0)
                {
                    command.sendObj = touchNotify;
                    CommandDispatcher.SendCommand(command);
                }
            }
            catch (System.Exception ex)
            {
                Logger.w(ex.Message + "\n" + ex.StackTrace);
                Cmd     cmd     = Cmd.TOUCH_NOTIFY;
                Command command = new Command(cmd, recordSocket);
                command.sendObj = ex.Message + "\n" + ex.StackTrace;
                command.status  = ResponseStatus.UN_KNOW_ERROR;
                CommandDispatcher.SendCommand(command);
            }
        }
Esempio n. 28
0
 protected void handleLeaveRecord(Command command)
 {
     Logger.d("handleLeaveRecord");
     RecordMode = false;
     CommandDispatcher.SendCommand(command);
 }