public void SelfUpdate(StatusJson status) { int newStatus = int.Parse(status.GetType().GetField(statusKey).GetValue(status).ToString()); Debug.Log(gameObject.name + " SelfUpdate: new status -> " + newStatus); led.SetActive(newStatus == 1); }
public async Task <HeleusClientResponse> SendMessage(string message, string link, byte[] imageData) { var response = await SetSubmitAccount(_submitAccount); if (response != null) { goto end; } if (string.IsNullOrWhiteSpace(message) || message.Length < 2) { response = new HeleusClientResponse(HeleusClientResultTypes.Ok, (long)ServiceUserCodes.InvalidStatusMessageLength); goto end; } if (!link.IsValdiUrl()) { response = new HeleusClientResponse(HeleusClientResultTypes.Ok, (long)ServiceUserCodes.InvalidStatusLink); goto end; } var attachements = _client.NewAttachements(StatusServiceInfo.StatusDataChainIndex); var realName = (await ProfileManager.Current.GetProfileInfo(_submitAccount.AccountId, ProfileDownloadType.DownloadIfNotAvailable, false))?.Profile?.RealName; var json = new StatusJson { m = message, l = link }.ToJson(); attachements.AddStringAttachement(StatusServiceInfo.StatusJsonFileName, json); if (imageData != null) { attachements.AddBinaryAttachement(StatusServiceInfo.ImageFileName, imageData); } response = await _client.UploadAttachements(attachements, (transaction) => { transaction.PrivacyType = DataTransactionPrivacyType.PublicData; transaction.EnableFeature <AccountIndex>(AccountIndex.FeatureId).Index = StatusServiceInfo.MessageIndex; if (realName != null) { transaction.EnableFeature <Payload>(Payload.FeatureId).PayloadData = Encoding.UTF8.GetBytes(realName); } }); end: await UIApp.PubSub.PublishAsync(new MessageSentEvent(response)); return(response); }
public IEnumerator PingSensors(Action <StatusJson> finished) { Debug.Log("Pinging " + IP_ADDRESS); using (UnityWebRequest www = UnityWebRequest.Get(IP_ADDRESS)) { yield return(www.SendWebRequest()); lastServerStatus = StatusJson.CreateFromJSON(www.downloadHandler.text); Debug.Log(www.downloadHandler.text); if (finished != null) { finished(lastServerStatus); } } Debug.Log("Ping finished"); }
void UpdateText(StatusJson data) { if (textMesh == null) { return; } float tempInt = data.Temperature; if (tempInt > 25) { textMesh.color = Color.red; } else if (tempInt < 16) { textMesh.color = Color.blue; } else { textMesh.color = Color.white; } textMesh.text = data.Temperature.ToString(); }
public StandardResponse() { Status = new StatusJson(); }