public void PublishClientDiscoveryActivity(string tenantId, string clientHostname) { var toIds = GetPeerIds(); if (toIds.Count == 0) { return; } var activityMessage = new MQTTDiscoveryClientActivityMessageContent() { TenantId = tenantId, ClientHostname = clientHostname, LastUpdateTimestamp = DateTime.UtcNow }; var jsonMessage = JsonConvert.SerializeObject(activityMessage); jsonMessage = jsonMessage.Replace("\"", "'"); var mqttMessage = new MQTTMessage() { FromInstanceId = Program.InstanceConfig.ServerInstanceID, ToInstancesIds = toIds, Type = "CLIENT_DISCOVERY_ACTIVITY", Message = jsonMessage }; _mqttService.SendMQTTMessageToMultipleInstances(tenantId, toIds, mqttMessage); }
public void PublishAddedOrUpdatedInstance(Instance instance, string type = "ADD_INSTANCE") { var toIds = GetPeerIds(); if (toIds.Count == 0) { return; } var jsonMessage = JsonConvert.SerializeObject(instance); jsonMessage = jsonMessage.Replace("\"", "'"); var mqttMessage = new MQTTMessage() { FromInstanceId = Program.InstanceConfig.ServerInstanceID, ToInstancesIds = toIds, Type = type, Message = jsonMessage }; _mqttService.SendMQTTMessageToMultipleInstances(instance.TenantId, toIds, mqttMessage); }