| | |
| | | /// </summary> |
| | | static string RandomKey = ""; |
| | | |
| | | /// <summary> |
| | | /// 随机生成字符 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | static string GetRandomKey() |
| | | { |
| | | if (string.IsNullOrEmpty(RandomKey)) |
| | | { |
| | | //随机2位字符串 |
| | | Random random = new Random(Guid.NewGuid().GetHashCode()); |
| | | int num = random.Next(65, 91); |
| | | RandomKey = Convert.ToChar(num).ToString(); |
| | | RandomKey = Utlis.CreateRandomString(2); |
| | | } |
| | | |
| | | return RandomKey; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | packet.Bytes = e.ApplicationMessage.Payload; |
| | | } |
| | | #if DEBUG |
| | | string ddd = ""; |
| | | foreach (var bb in packet.Bytes) |
| | | { |
| | | ddd += bb + ","; |
| | | } |
| | | MainPage.Log($"mqtt bus data:{ddd}"); |
| | | //string ddd = ""; |
| | | //foreach (var bb in packet.Bytes) |
| | | //{ |
| | | // ddd += bb + ","; |
| | | //} |
| | | //MainPage.Log($"mqtt bus data:{ddd}"); |
| | | #endif |
| | | packet.Manager(); |
| | | } |