Beispiel #1
0
 public void RefreshScreen(int newX, int newY)
 {
     Debug.Log("Refresh Screen Size");
     Loom.DispatchToMainThread(() => {
         currentScreenWidth   = newX;
         currentScreenHeight  = newY;
         mainImage            = new Texture2D((int)currentScreenWidth, (int)currentScreenHeight, TextureFormat.RGB24, false);
         mainImage.filterMode = FilterMode.Point;
         gameMat.texture      = mainImage;
         //gameScreen = new byte[currentScreenWidth * currentScreenHeight * 4];
     }, true, true);
 }
Beispiel #2
0
    protected bool isNeedHide;//当获取的currentPointIndex值小于0,等于-1

    /// <summary>
    /// 设置轨迹执行位置,点的索引
    /// </summary>
    public void Set(float value)
    {
        //isSetHistoryPath = true;
        Loom.StartSingleThread(() =>
        {
            SetCurrentIndexByProcess(value);//根据进度条的指设置currentIndex
            Loom.DispatchToMainThread(() =>
            {
                MoveToCurrentIndex();
            });
        });
    }
    private void ContinuesSingleThreadCoroutine()
    {
        Debug.Log("Starting an never ending Coroutine on a seperate Thread!");
        while (true)
        {
            Loom.WaitForNextFrame(10);
            Loom.DispatchToMainThread(() => Debug.Log("I waited atleast 10 frames. Whats the current frameCount? : " + Time.frameCount), true);

            Loom.WaitForSeconds(1);
            Loom.DispatchToMainThread(() => Debug.Log("I waited atleast 1 second. Whats the current frameCount? : " + Time.frameCount), true);
        }
        Debug.Log("It will never get here, but thats oke...");
    }
    /// <summary>
    /// 更新状态改变
    /// </summary>
    /// <param name="data"></param>
    private void OnUpdateChangeStatus(NotiData data)
    {
        switch (data.evName)
        {
        case NotiConst.UPDATE_EXTRACT_FAILED:
        {
            Loom.DispatchToMainThread(() =>
                {
                    var errorMsg = data.extParam.ToString();
                    Debugger.LogError("decompress error: " + errorMsg);
                    if (errorMsg.Contains("disk full", StringComparison.OrdinalIgnoreCase))
                    {
                        MessageBox.Show(string.Format("{0}:{1}", LanguageTips.EXTRACT_ERROR, LanguageTips.DISK_FULL));
                    }
                    else
                    {
                        MessageBox.Show(LanguageTips.EXTRACT_ERROR);
                    }
                });
        }
        break;

        case NotiConst.DOWNLOAD_EXTRACT_FAILED:
        {
            Loom.DispatchToMainThread(() =>
                {
                    packDownloadJumpedCount++;
                    Debugger.LogError("Download extract error! " + data.extParam.ToString());
                });
        }
        break;

        case NotiConst.UPDATE_FAILED:
        {
            Loom.DispatchToMainThread(() =>
                {
                    MessageBox.Show(data.extParam.ToString());
                });
        }
        break;

        case NotiConst.UPDATE_CANCELLED:
        {
            Loom.DispatchToMainThread(() =>
                {
                    MessageBox.Show(data.extParam.ToString());
                });
        }
        break;
        }
    }
 /// <summary>
 /// 显示
 /// </summary>
 public void Show()
 {
     SetContentActive(true);
     //searchInput.text = "";
     //GetMobileInspectionHistoryData();
     Loom.StartSingleThread((System.Threading.ThreadStart)(() =>
     {
         GetMobileInspectionHistoryData();
         Loom.DispatchToMainThread((Frankfort.Threading.ThreadDispatchDelegate)(() =>
         {
             CreateGetMobileInspectionHistoryGrid();
         }));
     }));
 }
Beispiel #6
0
 private void DoCallBack <T>(Action <T> callback, T data)
 {
     Loom.DispatchToMainThread(() =>
     {
         if (callback != null)
         {
             callback(data);
         }
     });
     //if (callback != null)
     //{
     //    callback(data);
     //}
 }
    private static void DeleteArea(GameObject objt)
    {
        //GameObject objt = gs[i];
        MonitorRangeObject monitorRangeObject = objt.GetComponent <MonitorRangeObject>();
        PhysicalTopology   pt = monitorRangeObject.info;

        //if (gs.Count >= 0)
        //{
        //    objt = gs[gs.Count - 1];
        //    monitorRangeObject = objt.GetComponent<MonitorRangeObject>();
        //    pt = monitorRangeObject.info;
        //}

        //if (pt == null)
        //    return;

        Loom.StartSingleThread(() =>
        {
            bool b = CommunicationObject.Instance.DeleteMonitorRange(pt);
            Loom.DispatchToMainThread(() =>
            {
                if (b)
                {
                    Debug.LogError("删除成功!");
                    UGUIMessageBox.Show("删除成功!");
                }
                else
                {
                    Debug.LogError("删除失败!");
                    UGUIMessageBox.Show("删除失败,区域下存在设备!");
                    return;
                }
                if (pt != null)
                {
                    RangeNode node       = monitorRangeObject.rangeNode;
                    RangeNode parentnode = node.parentNode;
                    parentnode.subNodes.Remove(node);

                    DepNode depnode       = monitorRangeObject.depNode;
                    DepNode parentdepnode = depnode.ParentNode;
                    parentdepnode.ChildNodes.Remove(depnode);

                    RoomFactory.Instance.NodeDic_Remove(monitorRangeObject.depNode);
                    EditorObjectSelection.Instance.ClearSelection(false);
                    Destroy(monitorRangeObject.gameObject);
                    PersonnelTreeManage.Instance.areaDivideTree.RemoveAreaChild(pt.Id);
                }
            });
        });
    }
Beispiel #8
0
    public void ExecuteThreadedWork()
    {
        DownloadFile download = new DownloadFile(DownloadUrl, LocalPath);

        byte[] fileBytes = download.DownloadHttp();

        if (fileBytes == null || fileBytes.Length <= 0)
        {
            Loom.DispatchToMainThread(() =>
            {
                NotiData data = new NotiData(NotiConst.UPDATE_FAILED, this.FileName, LanguageTips.UPDATE_FAILED);
                if (OnComplete != null)
                {
                    OnComplete(data);                      //回调逻辑层
                }
                //MessageBox.DisplayMessageBox(string.Format("{0}: {1}", UpdateTips.UPDATE_FAILED, FileName), 0, (go) =>
                //{
                //    AssetsCtrl.downloadFailed = true;
                //});
            });

            return;
        }

        string path = Path.GetDirectoryName(LocalPath);

        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }

        if (LocalPath.CustomEndsWith(".ab"))
        {
            BeginDecompressExtract(LocalPath, fileBytes);
        }
        else
        {
            DownloadFileMD5 = MD5.ComputeHashString(fileBytes);
            if (DownloadFileMD5 != SrcMD5)
            {
                throw new Exception(LanguageTips.UPDATE_MD5_ERROR);
            }
            if (File.Exists(LocalPath))
            {
                File.Delete(LocalPath);
            }
            File.WriteAllBytes(LocalPath, fileBytes);
        }
    }
 private void HeartBeat()
 {
     while (tcpServer.isRunning)
     {
         Loom.WaitForSeconds(beatTime);
         if (tcpServer != null)
         {
             Loom.DispatchToMainThread(() =>
             {
                 //NGUIDebug.Log(Command.HEART_BEAT);
                 tcpServer.HeartBeat();
             }, true);
         }
     }
 }
Beispiel #10
0
 public void SafeExecte_ParamThreadStart(object argument)
 {
     try
     {
         this.paramTargetMethod(argument);
     }
     catch (Exception arg_18_0)
     {
         Exception e2 = arg_18_0;
         Exception e  = e2;
         Loom.DispatchToMainThread(delegate
         {
             Debug.LogError(e.Message + e.StackTrace + "\n\n");
         }, true, true);
     }
 }
Beispiel #11
0
    /// <summary>
    /// 打开人员告警界面
    /// </summary>
    public void StartPerAlarmUI()
    {
        //LoadData();

        //StartPageNum = 0;
        //PageNum = 1;
        //GetPersonnelAlarmPage(PerAlarmList);
        //TotaiLine(PerAlarmList);
        //pegeNumText.text = "1";
        //InputPerAlarm.text = "";
        //DateTime CurrentTime = System.DateTime.Now;
        //string currenttime = CurrentTime.ToString("yyyy年MM月dd日");
        //StartTimeText.text = currenttime;
        //DealTimeText.text = currenttime;
        //promptText.gameObject.SetActive(false);
        //showStartTime.ShowStartTime();
        //perAlarmType.ShowDropdownFirstData();

        Loom.StartSingleThread(() =>
        {
            LoadData();
            Loom.DispatchToMainThread(() =>
            {
                if (PerAlarmList.Count == 0)
                {
                    pegeTotalText.text = "1";
                    pegeNumText.text   = "1";
                }
                else
                {
                    StartPageNum = 0;
                    PageNum      = 1;
                    GetPersonnelAlarmPage(SeachPerItems);
                    pegeNumText.text   = "1";
                    InputPerAlarm.text = "";
                    TotaiLine(SeachPerItems);
                    DateTime CurrentTime = System.DateTime.Now;
                    string currenttime   = CurrentTime.ToString("yyyy年MM月dd日");
                    StartTimeText.text   = currenttime;
                    DealTimeText.text    = currenttime;
                    promptText.gameObject.SetActive(false);
                    showStartTime.ShowStartTime();
                    //  perAlarmType.ShowDropdownFirstData();
                }
            });
        });
    }
    //--------------- Managing a simple single Thread --------------------
    private void EndingSingleThreadCoroutine()
    {
        Debug.Log("Starting an Coroutine on a seperate Thread!");

        Loom.WaitForNextFrame(30);
        Loom.DispatchToMainThread(() => Debug.Log("I waited atleast 30 frames. Whats the current frameCount? : " + Time.frameCount), true);

        Loom.WaitForSeconds(10);
        Loom.DispatchToMainThread(() => Debug.Log("I waited atleast 10 seconds. Whats the current frameCount? : " + Time.frameCount), true);

        //Throw error to show safemode nicely throws errors in the MainThread.

        Debug.LogWarning("About the throw an error...");
        throw new Exception("This is an safe Error and should showup in the Console");

        Debug.Log("It won't get here, but the Thread will die anyways.");
    }
Beispiel #13
0
    /// <summary>
    /// 创建操作票历史路径
    /// </summary>
    public void CreateOperationTicketHistoryPath(OperationTicket operationTicketT)
    {
        GetPersonnels();
        Personnel personnel = personnels.Find((item) => item.Id == operationTicketT.OperatorPersonelId);

        if (personnel != null)
        {
            DateTime   start       = new DateTime(2018, 9, 30, 10, 0, 0);
            DateTime   end         = new DateTime(2018, 9, 30, 11, 0, 0);
            List <int> topoNodeIds = RoomFactory.Instance.GetCurrentDepNodeChildNodeIds(SceneEvents.DepNode);
            //List<Position> ps = new List<Position>();
            //List<Vector3> list = new List<Vector3>();
            //List<DateTime> timelist = new List<DateTime>();

            Loom.StartSingleThread(() =>
            {
                var ps          = GetHistoryData(personnel.Id, topoNodeIds, start, end);
                var posInfoList = new PositionInfoList();
                Loom.DispatchToMainThread(() =>
                {
                    Debug.LogError("点数:" + ps.Count);
                    if (ps.Count < 2)
                    {
                        return;
                    }

                    for (int i = 0; i < ps.Count; i++)
                    {
                        var posInfo = new PositionInfo(ps[i], start);
                        posInfoList.Add(posInfo);
                    }

                    PathInfo pathInfo   = new PathInfo();
                    pathInfo.personnelT = personnel;
                    pathInfo.color      = Color.green;
                    pathInfo.posList    = posInfoList;
                    //pathInfo.timeLength = timeLength;

                    GameObject o = new GameObject(operationTicketT.Operator + "工作票");
                    OperationTicketHistoryPath path = o.AddComponent <OperationTicketHistoryPath>();
                    path.Init(pathInfo, false);
                    operationTicketHistoryPaths.Add(path);
                });
            });
        }
    }
    public void GetDeviceAlarmInfo(AlarmSearchArg arg, PageInfo page)
    {
        SaveSelection();
        page.Size       = 10;
        page.Number     = StartPageNum;
        arg.Level       = AlarmLevel;
        arg.DevTypeName = GetDevType(DevType);
        if (IsGetData)
        {
            return;
        }
        BanClick.SetActive(true);
        Loom.StartSingleThread(() =>
        {
            DateTime start = DateTime.Now;
            IsGetData      = true;
            var devAlarms  = CommunicationObject.Instance.GetDeviceAlarms(arg);
            if (devAlarms == null)
            {
                IsGetData = false;
            }
            Debug.LogError("--------------------GetDeviceAlarms:" + (DateTime.Now - start).TotalMilliseconds + "ms");
            Loom.DispatchToMainThread(() =>
            {
                IsGetData = false;
                BanClick.SetActive(false);

                DevAlarmInfo = new DeviceAlarmInformation();
                DevAlarmInfo = devAlarms;
                if (DevAlarmInfo.Total == 0)
                {
                    pegeTotalText.text = "1";
                }
                else
                {
                    pegeTotalText.text = DevAlarmInfo.Total.ToString();
                }
                if (DevAlarmInfo.devAlarmList != null && DevAlarmInfo.Total != 0)
                {
                    ShowDevAlarmList = new List <DeviceAlarm>();
                    ShowDevAlarmList.AddRange(DevAlarmInfo.devAlarmList);
                    GetDevAlarmData(ShowDevAlarmList);
                }
            });
        });
    }
    /// <summary>
    /// 获取历史轨迹数据
    /// </summary>
    /// <param name="ps"></param>
    /// <param name="startT"></param>
    /// <param name="end"></param>
    /// <param name="intervalMinute">每次获取数据的时间长度,不超过改数值</param>
    public List <Position> GetHistoryData(int personnelID, List <int> topoNodeIdsT, DateTime startT, DateTime endT, float intervalMinute = 10f)
    {
        List <Position> ps      = new List <Position>();
        double          minutes = (endT - startT).TotalMinutes;
        float           counts  = (float)minutes / intervalMinute;
        //float valueT = 0;
        float sum = 0;

        while (sum < counts)
        {
            DateTime startTemp;
            DateTime endTemp;
            if (sum + 1 <= counts)
            {
                startTemp = startT.AddMinutes(intervalMinute * sum);
                endTemp   = startT.AddMinutes(intervalMinute * (sum + 1));
                //List<Position> listT = CommunicationObject.Instance.GetHistoryPositonsByTime(code, startTemp, endTemp);
                List <Position> listT = CommunicationObject.Instance.GetHistoryPositonsByPersonnelID(personnelID, startTemp, endTemp);
                //List<Position> listT = CommunicationObject.Instance.GetHistoryPositonsByPidAndTopoNodeIds(personnelID, topoNodeIdsT, startTemp, endTemp);
                ps.AddRange(listT);
            }
            else
            {
                startTemp = startT.AddMinutes(intervalMinute * sum);
                endTemp   = endT;
                List <Position> listT = CommunicationObject.Instance.GetHistoryPositonsByPersonnelID(personnelID, startTemp, endTemp);
                //List<Position> listT = CommunicationObject.Instance.GetHistoryPositonsByPidAndTopoNodeIds(personnelID, topoNodeIdsT, startTemp, endTemp);
                ps.AddRange(listT);
            }

            sum += 1;
            float valueT = 1f / counts;
            progressbarLoadValue += valueT / currentPersonnels.Count;
            //print("valueT:" + valueT);
            Loom.DispatchToMainThread(() =>
            {
                ProgressbarLoad.Instance.Show(progressbarLoadValue);
            });
        }
        //Loom.DispatchToMainThread(() =>
        //{
        //    ProgressbarLoad.Instance.Hide();
        //});
        return(ps);
    }
Beispiel #16
0
    public void HttpRequestGet(string body, Action <string> callback = null)
    {
        string         newUrl  = string.Concat(url, "?", body);
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(newUrl));

        request.Method           = "GET";
        request.ContentType      = "application/x-www-form-urlencoded";
        request.Timeout          = 5 * 1000;
        request.ReadWriteTimeout = 5 * 1000;

        try
        {
            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                Stream responseStream = response.GetResponseStream();
                if (responseStream == null)
                {
                    Loom.DispatchToMainThread(() =>
                    {
                        if (callback != null)
                        {
                            callback("");
                        }
                    });
                    return;
                }
                StreamReader sr     = new StreamReader(responseStream, Encoding.UTF8);
                string       result = sr.ReadToEnd().Trim();
                Loom.DispatchToMainThread(() =>
                {
                    if (callback != null)
                    {
                        callback(result);
                    }
                });
                sr.Close();
                responseStream.Close();
            }
        }
        catch (Exception e)
        {
            Debug.LogError(e.Message);
        }
    }
Beispiel #17
0
        public Sprite(byte[] abyte0, object component = null)
        {
            //try
            //{
            Texture2D image = null;

            //            Image image = Toolkit.getDefaultToolkit().getImage(signlink.findcachedir()+"mopar.jpg");
            //Image image = Toolkit.getDefaultToolkit().createImage(abyte0);
            Loom.DispatchToMainThread(() => {
                image = new Texture2D(0, 0);       //Image.FromStream(new MemoryStream(abyte0));
                image.LoadImage(abyte0);
                Texture2D newImage = new Texture2D(image.width, image.height);
                int iWidth         = image.width;
                int iHeight        = image.height;


                for (int i = 0; i < iWidth; i++)
                {
                    for (int j = 0; j < iHeight; j++)
                    {
                        newImage.SetPixel(i, iHeight - j - 1, image.GetPixel(i, j));
                    }
                }
                newImage.Apply();

                myWidth   = newImage.width;
                myHeight  = newImage.height;
                anInt1444 = myWidth;
                anInt1445 = myHeight;
                anInt1442 = 0;
                anInt1443 = 0;
                myPixels  = NetDrawingTools.ReadPixels(newImage, myWidth, myHeight);
            }, true, true);
            //MediaTracker mediatracker = new MediaTracker(component);
            //mediatracker.addImage(image, 0);
            //mediatracker.waitForAll();


            //}
            //catch (Exception _ex)
            //{
            //	UnityEngine.Debug.Log("Error converting jpg");
            //}
        }
Beispiel #18
0
    private void StartOSSocket()
    {
        string returnData;

        using (UdpClient udpClient = new UdpClient(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 43592))) {
            IPEndPoint remoteIpEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 43592);
            while (true)
            {
                receiveBytes = udpClient.Receive(ref remoteIpEndPoint);
                if (receiveBytes != null && receiveBytes.Length > 0)
                {
                    if (receiveBytes [0] == 1 && receiveBytes.Length < 10000)                       //Game info
                    {
                        gameInfo = TrimFirst(receiveBytes);
                    }
                    else if (receiveBytes [0] == 2 && receiveBytes.Length < 1000)                         //Base Info
                    {
                        if (signlink.osHDDir == null)
                        {
                            signlink.osHDDir = Encoding.UTF8.GetString(TrimFirst(receiveBytes));
                            Debug.Log("Cache Dir: " + signlink.osHDDir);
                            if (!initialized)
                            {
                                Loom.DispatchToMainThread(() => { InitializeRune(); }, false, true);
                            }
                        }
                    }
                    else
                    {
                        if (RS2Sharp.Graphics.gameScreen == null && ((sbyte)receiveBytes [0] == -119 && (sbyte)receiveBytes [1] == 80 && (sbyte)receiveBytes [2] == 78))
                        {
                            RS2Sharp.Graphics.gameScreen = receiveBytes;
                        }
                        else if (RS2Sharp.Graphics.gameScreen2 == null)
                        {
                            RS2Sharp.Graphics.gameScreen2 = receiveBytes;
                            graphics.dirty = true;
                        }
                    }
                }
            }
        }
    }
    private void Broadcaster_DataReceived(object sender, AsyncSocketEventArgs e)
    {
        LogTool.Log(e.msg);
        //switch (e.msg) {
        //    case Command.EXIT:
        //        broadcaster.Close(e.state);
        //        break;
        //}
        if (e.msg.StartsWith(NetworkCommand.LOGIN) && clientDic.Count <= maxCount)
        {
            string[] result = e.msg.Split(';');
            LogTool.Log("Login……");
            int        id            = int.Parse(result[1].Split(':')[1]);
            string     userName      = result[2].Split(':')[1];
            string     password      = result[3].Split(':')[1];
            IPEndPoint remotePoint   = e.state.remote;
            string     remoteAddress = remotePoint.Address.ToString();

            if (!clientDic.ContainsKey(remoteAddress))
            {
                clientDic.Add(remoteAddress, userName);
            }
            Loom.DispatchToMainThread(() =>
            {
                if (!studentDic.ContainsKey(userName))
                {
                    //StudentItemView item = CreateStudent(studentCopy);
                    //item.IPAddress = remoteAddress;
                    //item.studentState = e.state;
                    //item.UserName = userName;
                    //studentDic.Add(userName, item);
                }
            });
            LogTool.Log("客户端:" + userName + "IP:" + remoteAddress);

            SaveDataController.CreateUser(id, userName, password);
            SaveDataController.SetServerPort(ipAddress, tcpPort);
            udpServer.sendMessage(NetworkCommand.ISCONNECTED);
            StartServer();
        }
    }
    private void Server_DataReceived(object sender, AsyncSocketEventArgs e)
    {
        if (tcpServer.isRunning)
        {
            LogTool.Log(e.msg);
            string remoteIpAddress = ((IPEndPoint)e.state.ClientSocket.RemoteEndPoint).Address.ToString();
            string clientName      = clientDic[remoteIpAddress];

            switch (e.msg)
            {
            case NetworkCommand.HEART_BEAT:
                List <AsyncSocketState> clientList = new List <AsyncSocketState>(tcpServer.clientDic.Values);
                for (int i = 0; i < clientList.Count; i++)
                {
                    if (clientList[i] != null)
                    {
                        if (e.state == clientList[i])
                        {
                            tcpServer.clientDic[clientList[i].ClientSocket.RemoteEndPoint].isHeartBeated = true;
                        }
                    }
                }
                break;

            case NetworkCommand.EXIT:

                Loom.DispatchToMainThread(() =>
                {
                    KickByName(clientName);
                });
                tcpServer.Close(e.state);
                break;

            default:
                LogTool.Log(clientDic[remoteIpAddress] + ":" + e.msg);
                break;
            }
        }
    }
Beispiel #21
0
 public void SafeExecte_ThreadStart()
 {
     try
     {
         this.targetMethod();
     }
     catch (ThreadInterruptedException e)
     {
         Thread.CurrentThread.Interrupt();
         Loom.DispatchToMainThread(delegate
         {
             Debug.LogError(e.Message + e.StackTrace + "\n\n");
         }, true, true);
     }
     catch (Exception e)
     {
         Loom.DispatchToMainThread(delegate
         {
             Debug.LogError(e.Message + e.StackTrace + "\n\n");
         }, true, true);
     }
 }
Beispiel #22
0
 public void ShowEndTimeIno(DateTime dateTime)
 {
     Loom.StartSingleThread((System.Threading.ThreadStart)(() =>
     {
         if (curentState == State.工作票)
         {
             GetWorkTicketHistoryData();
             Loom.DispatchToMainThread((Frankfort.Threading.ThreadDispatchDelegate)(() =>
             {
                 workTicketHistoryGrid.ScreeningSecondTime(dateTime);
             }));
         }
         else if (curentState == State.操作票)
         {
             GetOperationTicketHistoryData();
             Loom.DispatchToMainThread(() =>
             {
                 operationTicketHistoryGrid.ScreeningSecondTime(dateTime);
             });
         }
     }));
 }
Beispiel #23
0
 // Update is called once per frame
 void ClientConnect()
 {
     try
     {
         if (asyncTcpClient != null)
         {
             while (!asyncTcpClient.isConnected && asyncTcpClient.tcpClient.Poll(connectTime, System.Net.Sockets.SelectMode.SelectRead))
             {
                 Loom.DispatchToMainThread(() => asyncTcpClient.Connet());
                 Loom.WaitForSeconds(connectTime);
                 count++;
             }
             if (count > exitTime)
             {
                 count = 0;
                 Loom.DispatchToMainThread(() => closeTCP());
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #24
0
    private void AsyncClientReceived(string msg)
    {
        LogTool.Log(msg);
        switch (msg)
        {
        case NetworkCommand.HEART_BEAT:
            heartBeat = true;
            asyncTcpClient.AsynSend(NetworkCommand.HEART_BEAT);
            break;

        case NetworkCommand.EXIT:
            LogTool.Log("被服务器踢出");
            Loom.DispatchToMainThread(() =>
            {
                CloseClient();
            });

            break;

        default:
            LogTool.Log("server>client:" + msg);
            break;
        }
    }
Beispiel #25
0
        public void StartShow()
        {
            SetContentActive(true);
            searchInput.text = "";

            if (TwoTicketSystemUI_N.Instance.State == TwoTicketState.工作票)
            {
                TitleDropdown_OnValueChanged(0);
                GetWorkTicketHistoryData();
                Loom.DispatchToMainThread((Frankfort.Threading.ThreadDispatchDelegate)(() =>
                {
                    ShowWorkTicketHistoryInfo();
                }));
            }
            else if (TwoTicketSystemUI_N.Instance.State == TwoTicketState.操作票)
            {
                TitleDropdown_OnValueChanged(1);
                GetOperationTicketHistoryData();
                Loom.DispatchToMainThread(() =>
                {
                    ShowOperationTicketInfo();
                });
            }
        }
    public void ExecuteThreadedWork()
    {
        long i = maxIterations;

        while (--i > -1 && !isAborted)
        {
            //This lightweight method checks if Unity is still active.
            //If your app lozes focus or gets pauzed, it will sleep the thread.
            //If the application quits, it will abort the thread.
            Loom.SleepOrAbortIfUnityInactive();

            if (i == (maxIterations / 2))
            {
                Loom.DispatchToMainThread(() =>
                                          Debug.Log("Dispatch: is this the MainThread? " + Loom.CheckIfMainThread()), true);

                Debug.Log("From WorkerThread: is this the MainThread? " + Loom.CheckIfMainThread());

                GameObject cube = (GameObject)Loom.DispatchToMainThreadReturn(TestThreadSafeDispatch, true);
                Loom.DispatchToMainThread(() => cube.name += "_RenamedFrom: " + Thread.CurrentThread.Name);
            }
            result++;
        }
    }
    // Token: 0x06005134 RID: 20788 RVA: 0x001BB5E4 File Offset: 0x001B99E4
    private IEnumerator CreateAsyncCoroutineWithDiskSaving(AssetBundleDownload download)
    {
        if (!download.isSavedOnDisk)
        {
            yield return(base.StartCoroutine(this.AttemptLzmaDecompressionCoroutine(download)));

            yield return(base.StartCoroutine(this.AttemptGZipDecompressionCoroutine(download)));

            if (!download.isLzma && !download.isGZip)
            {
                VRC.Core.Logger.Log("[" + download.downloadId + "] Unity Compressed AssetBundle Detected!", DebugLevel.AssetBundleDownloadManager);
            }
            bool doneSavingFile = false;
            Loom.StartSingleThread(delegate
            {
                this.SaveToDisk(download);
                if (download.isLzma || download.isGZip)
                {
                    Loom.DispatchToMainThread(delegate
                    {
                        download.assetBundle = this.LoadFromDisk(download);
                        doneSavingFile       = true;
                    }, false, true);
                }
                else
                {
                    doneSavingFile = true;
                }
            }, System.Threading.ThreadPriority.Normal, true);
            while (!doneSavingFile)
            {
                yield return(null);
            }
            if (!download.isLzma && !download.isGZip)
            {
                AssetBundleCreateRequest assetBundleCreateRequest = AssetBundle.LoadFromMemoryAsync(download.assetBundleBytes);
                yield return(assetBundleCreateRequest);

                download.assetBundle = assetBundleCreateRequest.assetBundle;
            }
        }
        else
        {
            VRC.Core.Logger.Log(string.Concat(new object[]
            {
                "[",
                download.downloadId,
                "] Attempting to create uncompressed ab from disk - ",
                download.assetUrl
            }), DebugLevel.AssetBundleDownloadManager);
            download.assetBundle = this.LoadFromDisk(download);
            if (download.assetBundle == null)
            {
                VRC.Core.Logger.Log(string.Concat(new object[]
                {
                    "[",
                    download.downloadId,
                    "] Creating unity compressed AB from disk - ",
                    download.assetUrl
                }), DebugLevel.AssetBundleDownloadManager);
                Loom.StartSingleThread(delegate
                {
                    download.assetBundleBytes = File.ReadAllBytes(download.assetBundleFilePath);
                }, System.Threading.ThreadPriority.Normal, true);
                while (download.assetBundleBytes == null)
                {
                    yield return(null);
                }
                AssetBundleCreateRequest assetBundleCreateRequest2 = AssetBundle.LoadFromMemoryAsync(download.assetBundleBytes);
                yield return(assetBundleCreateRequest2);

                download.assetBundle = assetBundleCreateRequest2.assetBundle;
            }
        }
        yield break;
    }
 // 登陆数据获取成功
 private void OnLoginDataSuccess()
 {
     PushManager.Instance.Init();
     PushEventNotifyCenter.Instance.RemoveAllListener();
     Loom.DispatchToMainThread(() => SceneManager.LoadScene("Main"));
 }
Beispiel #29
0
        /// <summary>
        /// 线程完成
        /// </summary>
        /// <param name="data"></param>
        void OnThreadCompleted(NotiData data)
        {
            switch (data.evName)
            {
            case NotiConst.DOWNLOAD_EXTRACT:
            {
                var key = data.evParam.ToString();
                if (downloadCheckDatas.ContainsKey(key) && data.extParam != null)
                {
                    var  fileMd5 = MD5.ComputeHashString(data.extParam.ToString());
                    bool success = false;
                    if (fileMd5 != downloadCheckDatas[key])
                    {
                        if (!downloadErrorFiles.Contains(key))
                        {
                            downloadErrorFiles.Add(key);
                        }
                    }
                    else
                    {
                        if (downloadErrorFiles.Contains(key))
                        {
                            downloadErrorFiles.Remove(key);
                        }
                        downloadCheckDatas.Remove(key);
                        success = true;
                    }
                    Loom.DispatchToMainThread(() =>
                        {
                            if (success)
                            {
                                Debugger.Log("[0]Download Success: {0}", key);
                                if (beginPackDownload)
                                {
                                    Util.CallMethod("Game", "OnOnePackFileDownload", key);
                                }
                                SetMd5(key, fileMd5);
                            }
                        });
                }
                extractFiles.Remove(key);
            }
            break;

            case NotiConst.DOWNLOAD_EXTRACT_FAILED:
            {
                var key = data.evParam.ToString();
                extractFiles.Remove(key);
                var message = data.extParam.ToString();
                Loom.DispatchToMainThread(() =>
                    {
                        packDownloadJumpedCount++;
                        Debugger.LogError("Download extract error! {0}", data.extParam.ToString());
                        if (message.Contains("disk full", StringComparison.OrdinalIgnoreCase))
                        {
                            MessageBox.Show(string.Format("{0},{1}", LanguageTips.BACKGROUND_DOWNLOADING_ERROR, LanguageTips.DISK_FULL));
                        }
                    });
            }
            break;
            }
        }
    Position firstPoint = null;//第一个点的位置 自动移动进度条到该点

    /// <summary>
    /// 显示某个标签的历史数据
    /// </summary>
    /// <param name="code"></param>
    public void ShowHistoryData()
    {
        if (isLoadDataSuccessed)
        {
            return;
        }
        //LocationManager.Instance.ClearHistoryPaths();
        //string code = "0002";

        List <HistoryPersonUIItem> historyPersonUIItems = personsGrid.GetComponentsInChildren <HistoryPersonUIItem>().ToList();

        DateTime end   = GetEndTime();
        DateTime start = GetStartTime();
        List <List <Position> > psList = new List <List <Position> >();

        personnel_Points = new Dictionary <Personnel, List <Position> >();
        //List<Position> ps = new List<Position>();
        List <LocationHistoryPath_M> paths = new List <LocationHistoryPath_M>();

        progressbarLoadValue = 0;

        List <int> topoNodeIds = RoomFactory.Instance.GetCurrentDepNodeChildNodeIds(SceneEvents.DepNode);

        Loom.StartSingleThread(() =>
        {
            firstPoint = null;
            foreach (Personnel p in currentPersonnels)
            {
                List <Position> ps = GetHistoryData(p.Id, topoNodeIds, start, end, 1440f);
                psList.Add(ps);
                if (personnel_Points.ContainsKey(p))
                {
                    personnel_Points[p] = ps;
                }
                else
                {
                    personnel_Points.Add(p, ps);
                }
                if (ps != null && ps.Count > 0)
                {
                    Position fps = ps[0];
                    if (firstPoint == null)
                    {
                        firstPoint = fps;
                    }
                    else
                    {
                        if (fps.Time < firstPoint.Time)
                        {
                            firstPoint = fps;
                        }
                    }
                }
            }
            Debug.Log("StartSingleThread1");
            Loom.DispatchToMainThread(() =>
            {
                ProgressbarLoad.Instance.Show(1);
                ProgressbarLoad.Instance.Hide();
                int k = 0;
                foreach (Personnel p in personnel_Points.Keys)
                {
                    List <Position> ps = personnel_Points[p];
                    Debug.LogError("点数:" + ps.Count);
                    if (ps.Count < 2)
                    {
                        continue;
                    }
                    var posInfoList = new PositionInfoList();
                    for (int i = 0; i < ps.Count; i++)
                    {
                        var posInfo = new PositionInfo(ps[i], start);
                        posInfoList.Add(posInfo);
                    }

                    Color colorT             = colors[k % colors.Count];
                    HistoryPersonUIItem item = historyPersonUIItems.Find((i) => i.personnel.Id == p.Id);
                    if (item != null)
                    {
                        colorT = item.color;
                    }

                    PathInfo pathInfo   = new PathInfo();
                    pathInfo.personnelT = p;
                    pathInfo.color      = colorT;
                    pathInfo.posList    = posInfoList;
                    pathInfo.timeLength = timeLength;

                    LocationHistoryPath_M histoyObj = LocationHistoryManager.Instance.ShowLocationHistoryPath_M(pathInfo);
                    //histoyObj.InitData(timeLength, timelist);
                    HistoryManController historyManController = histoyObj.gameObject.AddComponent <HistoryManController>();
                    histoyObj.historyManController            = historyManController;
                    historyManController.Init(colorT, histoyObj);
                    PersonAnimationController personAnimationController = histoyObj.gameObject.GetComponent <PersonAnimationController>();
                    personAnimationController.DoMove();
                    Debug.Log("StartSingleThread2");
                    k++;
                }
            });

            //Debug.Log("StartSingleThread3");
            Loom.DispatchToMainThread(() =>
            {
                isLoadDataSuccessed = true;
                //timeStart = Time.time;
                timeSum = 0;
                Debug.Log("StartSingleThread3");
                if (firstPoint != null)
                {
                    DateTime t = LocationManager.GetTimestampToDateTime(firstPoint.Time);
                    Debug.Log(firstPoint.Time);
                    timeSum = t.Hour * 3600 + t.Minute * 60 + t.Second - slider.ValueMin * 3600;
                    Debug.Log(timeSum);
                }
            });
        });
    }