public void Run() { logger.Log("ChatRoom Server Started"); while (true) { Parallel.Invoke( //This thread is always listening for new clients (users) async() => { await AcceptClient(); }, //This thread is always listening for new messages async() => { await GetAllMessages(); }, //This thread is always sending new messages async() => { await SendAllMessages(); }, //This thread is always checking for new connections and checking for disconnections async() => { await CheckIfConnected(); } ); } }
public virtual void Hide() { OnHide(); gameObject.SetActive(false); mLogger.Log(string.Format("On Hide:{0}", name)); }
public string RecieveUsername() { byte[] RecievedUsername = new byte[256]; stream.Read(RecievedUsername, 0, RecievedUsername.Length); username = Encoding.ASCII.GetString(RecievedUsername).Replace("\0", string.Empty); Console.WriteLine(username + " entered the room"); logger.Log(username + " entered the room"); return(username); }
//建立遮罩 protected IEnumerator IBuildMask() { TObject obj = new TObject(); string path = Application.streamingAssetsPath + "/" + TinyContext.Instance.LanguagePath + "/Main/Common/UIs/Panels/"; AssetBundle bundle = mMgr.GetStandardAtlas("Panel_Mask-Atlas"); if (bundle == null) { yield return(CoroutineMgr.Instance.StartCoroutine(DataMgr.Instance.ILoadBundle(path, "Panel_Mask-Atlas", obj))); if (obj.Err != null) { mLogger.Log(obj.Err); } else { GameObject mask = obj.Bundle.assetBundle.mainAsset as GameObject; UIAtlas atlas = mask.GetComponent <UIAtlas>(); mMgr.PushStandardAtlas("Panel_Mask-Atlas", obj.Bundle.assetBundle); } } yield return(CoroutineMgr.Instance.StartCoroutine(DataMgr.Instance.ILoadBundle(path, "Panel_Mask", obj))); if (obj.Err != null) { mLogger.Log(obj.Err); } else { mMask = GameObject.Instantiate(obj.Bundle.assetBundle.mainAsset) as GameObject; mMask.name = "Panel_Mask"; //掛載 if (mMask != null) { AddToBone(mMask); } obj.Bundle.assetBundle.Unload(false); } obj.Free(); }
private void OnCreated(object sender, FileSystemEventArgs e) { string path = e.FullPath; try { FileInfo fileInfo = new FileInfo(path); DateTime dateTime = fileInfo.LastWriteTime; string year = dateTime.ToString("yyyy"); string month = dateTime.ToString("MM"); string day = dateTime.ToString("dd"); byte[] key, iv; (key, iv) = Encryptor.CreateKeyAndIV(); string name = Path.GetFileNameWithoutExtension(path); string extension = Path.GetExtension(path); string fileName = Path.GetFileName(path); string gzPath = Path.Combine(targetDir, name + ".gz"); string newPath = Path.Combine(targetDir, name + extension); //encrypting byte [] content = File.ReadAllBytes(path); content = Encryptor.Encrypt(content, key, iv); File.WriteAllBytes(path, content); //compressing and copying to targetDir Archive.Compress(path, gzPath); if (File.Exists(path)) { File.Delete(path); } if (enableArchiveDirectory) { //copying to additional archive char sep = Path.DirectorySeparatorChar; string archiveDir = Path.Combine(targetDir, $"archive{sep}year {year}{sep}month {month}{sep}day {day}"); string archiveName = name + '_' + dateTime.ToString("yyyy_MM_dd_HH_mm_ss") + ".gz"; string archivePath = Path.Combine(archiveDir, archiveName); Directory.CreateDirectory(archiveDir); File.Copy(gzPath, archivePath); } //decompressing Archive.Decompress(gzPath, newPath); if (File.Exists(gzPath)) { File.Delete(gzPath); } //decrypting content = File.ReadAllBytes(newPath); string decrypted = Encryptor.Decrypt(content, key, iv); File.WriteAllText(newPath, decrypted); report += $"File \"{name}\" is moved from \"{sourceDir}\" to \"{targetDir}\" successfully!"; dbLogger.Log(report); } catch (Exception exception) { report += $"A following problem occured: {exception}"; dbLogger.Log(report); } }