ResponseMessage Receive(SubscribeToOperationalStateChangesMessage message) { bool result = false; lock (this) { if (message.Subscribe) {// Subscribe. TracerHelper.TraceEntry("Subscribing - " + message.TransportInfo.OriginalSenderId.Value.Id.Name); if (_operationStateChangeSubscribers.Contains(message.TransportInfo) == false) { _operationStateChangeSubscribers.Add(message.TransportInfo); result = true; } // Send an initial notification. this.SendResponding(message.TransportInfo, new ChangeOperationalStateMessage(this.OperationalState, false)); } else {// Unsubscribe. TracerHelper.TraceEntry("Unsubscribing - " + message.TransportInfo.OriginalSenderId.Value.Id.Name); result = _operationStateChangeSubscribers.Remove(message.TransportInfo); } } if (message.RequestResponse) { return(new ResponseMessage(result)); } else { return(null); } }
/// <summary> /// Will unsubscribe to previous one. /// </summary> protected bool SetRemoteStatusSynchronizationSource(TransportInfo sourceTransportInfo) { lock (this) { if (_remoteStatusSynchronizationSource != null) { SubscribeToOperationalStateChangesMessage message = new SubscribeToOperationalStateChangesMessage(false); message.RequestResponse = false; SendResponding(_remoteStatusSynchronizationSource, message); } _remoteStatusSynchronizationSource = sourceTransportInfo; } bool result = true; if (sourceTransportInfo != null) { ResponseMessage response = SendAndReceiveResponding <ResponseMessage>(sourceTransportInfo, new SubscribeToOperationalStateChangesMessage(true)); result = response != null && response.OperationResult; } TracerHelper.TraceEntry(this.GetType().Name + ", Remote synchronization source " + sourceTransportInfo.OriginalSenderId.Value.Id.Name + " assinged - " + result.ToString()); return(result); }
ResponseMessage Receive(SubscribeToOperationalStateChangesMessage message) { bool result = false; lock(this) { if (message.Subscribe) {// Subscribe. TracerHelper.TraceEntry("Subscribing - " + message.TransportInfo.OriginalSenderId.Value.Id.Name); if (_operationStateChangeSubscribers.Contains(message.TransportInfo) == false) { _operationStateChangeSubscribers.Add(message.TransportInfo); result = true; } // Send an initial notification. this.SendResponding(message.TransportInfo, new ChangeOperationalStateMessage(this.OperationalState, false)); } else {// Unsubscribe. TracerHelper.TraceEntry("Unsubscribing - " + message.TransportInfo.OriginalSenderId.Value.Id.Name); result = _operationStateChangeSubscribers.Remove(message.TransportInfo); } } if (message.RequestResponse) { return new ResponseMessage(result); } else { return null; } }
/// <summary> /// Will unsubscribe to previous one. /// </summary> protected bool SetRemoteStatusSynchronizationSource(TransportInfo sourceTransportInfo) { lock (this) { if (_remoteStatusSynchronizationSource != null) { SubscribeToOperationalStateChangesMessage message = new SubscribeToOperationalStateChangesMessage(false); message.RequestResponse = false; SendResponding(_remoteStatusSynchronizationSource, message); } _remoteStatusSynchronizationSource = sourceTransportInfo; } bool result = true; if (sourceTransportInfo != null) { ResponseMessage response = SendAndReceiveResponding<ResponseMessage>(sourceTransportInfo, new SubscribeToOperationalStateChangesMessage(true)); result = response != null && response.OperationResult; } TracerHelper.TraceEntry(this.GetType().Name + ", Remote synchronization source " + sourceTransportInfo.OriginalSenderId.Value.Id.Name + " assinged - " + result.ToString()); return result; }