/// <summary> /// Takes a IHistoryEntry and binds it to a created HistoryEntryComponent to be used in the history list. /// </summary> /// <param name="entry">History entry to bind</param> /// <param name="expanded">Whether or not to show its list of changed entries.</param> /// <returns>Inflated and bound component.</returns> HistoryEntryComponent CreateHistoryEntry([NotNull] IHistoryEntry entry, bool expanded) { Assert.IsNotNull(m_Presenter, "Invalid state when creating history entry"); var comp = new HistoryEntryComponent(); // Handle expanded vs compact layout if (expanded) { // Hide fields used for compact view comp.showFilesButton.AddToClassList(UiConstants.ussHidden); comp.cloudStatusText.AddToClassList(UiConstants.ussHidden); comp.changedFilesCount.text = $"Changes ( {entry.Changes.Count} )"; var listAdapter = new HistoryEntryChangeListAdapter(m_Presenter, entry.RevisionId, entry.Changes.ToList()); comp.changedFiles.SetAdapter(listAdapter); listAdapter.NotifyDataSetChanged(); // Configure button comp.gotoButton.text = entry.GetGotoText(); comp.gotoButton.clickable.clicked += () => m_Presenter.RequestGoto(entry.RevisionId, entry.Status); } else { // Hide fields used for expanded view comp.changedFilesCount.AddToClassList(UiConstants.ussHidden); comp.changedFiles.AddToClassList(UiConstants.ussHidden); comp.gotoButton.text = string.Empty; comp.gotoButton.AddToClassList(UiConstants.ussHidden); // Setup show button comp.showFilesButton.text = entry.Changes.Count == 1 ? StringAssets.showChange : string.Format(StringAssets.showChanges, entry.Changes.Count); comp.showFilesButton.clickable.clicked += () => m_Presenter.SelectedRevisionId = entry.RevisionId; // TODO: cloud status text } // Trim whitespace on either side and grab initial for profile circle var trimmedAuthorName = entry.AuthorName.Trim(); comp.profileInitial.text = trimmedAuthorName.Substring(0, 1).ToUpper(); comp.authorName.text = trimmedAuthorName; // Display relative or absolute timestamp. If relative, show absolute as a tooltip. comp.timestamp.text = TimeStamp.GetTimeStamp(entry.Time); if (TimeStamp.UseRelativeTimeStamps) { comp.timestamp.tooltip = TimeStamp.GetLocalisedTimeStamp(entry.Time); } // Display revision id and show full length id as a tooltip comp.revisionId.text = $"ID: {entry.RevisionId.Substring(0, 10)}"; comp.revisionId.tooltip = entry.RevisionId; comp.commitMessage.text = entry.Message; return(comp); }
private void _UpdateTimeStamp() { foreach (var timeStamp in _timeStampBoxes) { timeStamp.Key.GetComponent <TextMeshProUGUI>().text = TimeStamp.GetTimeStamp(timeStamp.Value); } }
public void Init(Socket socket) { this.socket = socket; isUse = true; buffCount = 0; // 心跳处理 lastTickTime = TimeStamp.GetTimeStamp(); }
public static ObjectId New() { var timeStamp = TimeStamp.GetTimeStamp(); var machineId = Machine.GetMachineId(); var count = Counter.GetNumber(); return(new ObjectId(timeStamp | machineId | count)); }
private void _LoadInitialDialogue() { _dialogueLabel = _dialogueMessages.Count; if (_currentDialogueMessages.Count != 0) { for (int i = _currentDialogueMessages.Count - 1; i > -1; i--) { var msg = _currentDialogueMessages[i]; switch (msg.messageType) { case MessageBubbleType.Demon: Services.textSequenceTaskRunner.AddTask(delegate { GameObject newTimeBox = GameObject.Instantiate(Resources.Load <GameObject>(_demonTextBox), content.transform); newTimeBox.GetComponentInChildren <TextMeshProUGUI>().text = msg.content; newTimeBox.transform.SetSiblingIndex(0); }, msg.shootTime); break; case MessageBubbleType.Player: Services.textSequenceTaskRunner.AddTask(delegate { GameObject newTimeBox = GameObject.Instantiate(Resources.Load <GameObject>(_playerTextBox), content.transform); newTimeBox.GetComponentInChildren <TextMeshProUGUI>().text = msg.content; newTimeBox.transform.SetSiblingIndex(0); }, msg.shootTime); break; case MessageBubbleType.TimeStamp: Services.textSequenceTaskRunner.AddTask(delegate { GameObject newTimeBox = GameObject.Instantiate(Resources.Load <GameObject>(_timeStampBubble), content.transform); newTimeBox.GetComponentInChildren <TextMeshProUGUI>().text = TimeStamp.GetTimeStamp(msg.shootTime); newTimeBox.transform.SetSiblingIndex(0); }, msg.shootTime); break; case MessageBubbleType.Prefab: Services.textSequenceTaskRunner.AddTask(delegate { var bubblePrefab = Resources.Load <GameObject>("Prefabs/FileBubble/" + msg.fileBubbleName); var bubble = GameObject.Instantiate(bubblePrefab, content.transform); if (bubble.GetComponentInChildren <OpenFileButton>()) { bubble.GetComponentInChildren <OpenFileButton>().fileContentName = msg.fileContentName; } }, msg.shootTime); break; } } } _dialogueLabel--; }
public YopRequest() { this.appKey = YopConfig.getAppKey(); this.secretKey = YopConfig.getSecret(); this.serverRoot = YopConfig.getServerRoot(); if (YopConfig.getAppKey() != null) { paramMap.Add(YopConstants.APP_KEY, YopConfig.getAppKey()); } paramMap.Add(YopConstants.FORMAT, format.ToString()); paramMap.Add(YopConstants.VERSION, version); paramMap.Add(YopConstants.LOCALE, locale); paramMap.Add(YopConstants.TIMESTAMP, TimeStamp.GetTimeStamp().ToString()); }
private void _CreateNewTimeStamp(DateTime time) { MessageContent msg = new MessageContent(); msg.messageType = MessageBubbleType.TimeStamp; msg.content = String.Empty; msg.shootTime = time; _currentDialogueMessages.Add(msg); Services.textSequenceTaskRunner.AddTask(delegate { GameObject newTimeBox = GameObject.Instantiate(Resources.Load <GameObject>(_timeStampBubble), content.transform); newTimeBox.GetComponentInChildren <TextMeshProUGUI>().text = TimeStamp.GetTimeStamp(time); }, time); }
public void TestGetTimeStamp() { TimeStamp.TimeStampFormat[] expFormats = new TimeStamp.TimeStampFormat[] { TimeStamp.TimeStampFormat.MpegAbsoluteTime, TimeStamp.TimeStampFormat.MsAbsoluteTime }; byte[] testBytes = new byte[] { 0x01, 0x02 }; TimeStamp.TimeStampFormat[] test = new TimeStamp.TimeStampFormat[testBytes.Length]; for (int i = 0; i < testBytes.Length; i++) { test[i] = TimeStamp.GetTimeStamp(testBytes[i]); } CollectionAssert.AreEqual(expFormats, test); }
/// <summary> /// 心跳处理 /// </summary> private void HeartBeat() { long timeNow = TimeStamp.GetTimeStamp(); foreach (Conn c in conns) { if (c != null && c.isUse && c.lastTickTime < timeNow - heartBeatTime) { if (c.lastTickTime < timeNow - heartBeatTime) { Console.WriteLine("[心跳超时]。。。"); } Console.WriteLine("[心跳断开]:" + c.GetAddress()); lock (c) { c.Close(); } } } }
/// <summary> /// Create message boxes according to msg data /// </summary> /// <param name="msg"></param> /// <param name="shootTime"></param> /// <param name="isAddedToTop"></param> private void _AddMessageBox(MessageContent msg, bool isAddedToTop = false) { string boxPrefab = string.Empty; if (msg.messageType == MessageBubbleType.Player) { boxPrefab = _playerTextBox; } if (msg.messageType == MessageBubbleType.Demon) { boxPrefab = _demonTextBox; } if (msg.messageType == MessageBubbleType.TimeStamp) { boxPrefab = _timeStampBubble; } if (msg.messageType == MessageBubbleType.End) { boxPrefab = _endChatBubble; } if (msg.messageType == MessageBubbleType.Prefab) { boxPrefab = "Prefabs/FileBubble/" + msg.fileBubbleName; } string textContent = String.Empty; if (msg.messageType == MessageBubbleType.TimeStamp) { textContent = TimeStamp.GetTimeStamp(msg.shootTime); } if (msg.messageType == MessageBubbleType.End) { textContent = "This is the end of the chat"; } else { textContent = msg.content; } Services.textSequenceTaskRunner.AddTask(delegate { GameObject newBox = GameObject.Instantiate(Resources.Load <GameObject>(boxPrefab), content.transform); if (!ReferenceEquals(newBox.GetComponentInChildren <TextMeshProUGUI>(), null)) { newBox.GetComponentInChildren <TextMeshProUGUI>().text = textContent; } if (!ReferenceEquals(newBox.GetComponentInChildren <OpenFileButton>(), null)) { newBox.GetComponentInChildren <OpenFileButton>().fileContentName = msg.fileContentName; } if (isAddedToTop) { newBox.transform.SetSiblingIndex(0); } if (msg.messageType == MessageBubbleType.TimeStamp) { _timeStampBoxes.Add(newBox, msg.shootTime); } }, msg.shootTime); }
/// <summary> /// Returns time stamps format from time stamp byte /// </summary> /// <param name="timeStampByte">Time stamp format byte</param> /// <returns>Time stamp format</returns> protected TimeStamp.TimeStampFormat GetTimeStamp(byte timeStampByte) { return(TimeStamp.GetTimeStamp(timeStampByte)); }
private void _LoadMoreDialogue() { if (_dialogueLabel < 0) { if (!_isEndChatShow) { Services.textSequenceTaskRunner.AddSideTask(delegate { GameObject newTimeBox = GameObject.Instantiate(Resources.Load <GameObject>(_endChatBubble), content.transform); newTimeBox.transform.SetSiblingIndex(0); }, DateTime.Now); _isEndChatShow = true; } return; } MessageContent[] dialogueArray = _dialogueMessages[_dialogueLabel]; for (int i = dialogueArray.Length - 1; i > -1; i--) { var msg = dialogueArray[i]; switch (msg.messageType) { case MessageBubbleType.Demon: Services.textSequenceTaskRunner.AddTask(delegate { GameObject newTimeBox = GameObject.Instantiate(Resources.Load <GameObject>(_demonTextBox), content.transform); newTimeBox.GetComponentInChildren <TextMeshProUGUI>().text = msg.content; newTimeBox.transform.SetSiblingIndex(0); }, msg.shootTime); break; case MessageBubbleType.Player: Services.textSequenceTaskRunner.AddTask(delegate { GameObject newTimeBox = GameObject.Instantiate(Resources.Load <GameObject>(_playerTextBox), content.transform); newTimeBox.GetComponentInChildren <TextMeshProUGUI>().text = msg.content; newTimeBox.transform.SetSiblingIndex(0); }, msg.shootTime); break; case MessageBubbleType.TimeStamp: Services.textSequenceTaskRunner.AddTask(delegate { GameObject newTimeBox = GameObject.Instantiate(Resources.Load <GameObject>(_timeStampBubble), content.transform); newTimeBox.GetComponentInChildren <TextMeshProUGUI>().text = TimeStamp.GetTimeStamp(msg.shootTime); newTimeBox.transform.SetSiblingIndex(0); }, msg.shootTime); break; case MessageBubbleType.Prefab: Services.textSequenceTaskRunner.AddTask(delegate { var bubblePrefab = Resources.Load <GameObject>("Prefabs/FileBubble/" + msg.fileBubbleName); var bubble = GameObject.Instantiate(bubblePrefab, content.transform); if (bubble.GetComponentInChildren <OpenFileButton>()) { bubble.GetComponentInChildren <OpenFileButton>().fileContentName = msg.fileContentName; } }, msg.shootTime); break; } } _dialogueLabel--; }
public void HeartBeat(Conn conn, ProtocolBase protocol) { conn.lastTickTime = TimeStamp.GetTimeStamp(); }