public static async void GetServerInfo(string host, int port, StatusCallBack call) { await Task.Run(() => { CubeProtocol protocol = null; try { protocol = new CubeProtocol(host, port, MC1122Version, null); protocol.SetProtocol(SubProtocol.Handshake); protocol.SendPacket(new HandshakePacket(protocol.ProtocolVersion, host, (short)port, 1)); protocol.SetProtocol(SubProtocol.Status); protocol.SendPacket(new StatusQueryPacket()); var packet = protocol.ReadPacket(); if (packet != null && packet.GetType() == typeof(StatusResponsePacket)) { call(((StatusResponsePacket)packet).Info); } protocol.Dispose(); return; } catch (System.Net.Sockets.SocketException e) { Debug.LogError(e.Message); if (protocol != null) { protocol.Dispose(); } } call(null); }); }
public async void Write(string database, InfluxDB.Net.Models.Point point, StatusCallBack statusCallBack) { //基于InfluxData.Net.InfluxDb.Models.Point实体准备数据 //var point = new Point() //{ // Measurement = "logs",//表名 // Tags = new Dictionary<string, object>() // { // { "Id", 158} // }, // Fields = new Dictionary<string, object>() // { // { "Val", "webInfo" } // }, // Timestamp = DateTime.UtcNow //}; InfluxDbApiResponse writeResponse = await _client.WriteAsync(database, point); statusCallBack?.Invoke(writeResponse.Success); }
public async System.Threading.Tasks.Task <string> WriteAsync(string database, InfluxDB.Net.Models.Point point, StatusCallBack statusCallBack) { InfluxDbApiResponse writeResponse = await _client.WriteAsync(database, point); statusCallBack?.Invoke(writeResponse.Success); return(writeResponse.Success ? "入库成功" : "入库失败"); }
public async void DeleteDatabase(string database, StatusCallBack statusCallBack) { InfluxDbApiResponse deleteResponse = await _client.DropDatabaseAsync(database); statusCallBack?.Invoke(deleteResponse.Success); }
public async void CreateDatabase(string database, StatusCallBack statusCallBack) { InfluxDbApiResponse response = await _client.CreateDatabaseAsync(database); statusCallBack?.Invoke(response.Success); }