Exemplo n.º 1
0
		internal MessageClient(string clientId, MessageDestination messageDestination, string endpointId, bool useSession) {
			SetIsValid(true);
			_clientId = clientId;
			Debug.Assert(messageDestination != null);
			_messageDestination = messageDestination;
			_endpointId = endpointId;
			if (useSession) {
				_session = FluorineContext.Current.Session as Session;
				if (_session != null)
					_session.RegisterMessageClient(this);
				_client = FluorineContext.Current.Client;
				Debug.Assert(_client != null);
				_client.RegisterMessageClient(this);
			} else {
				_session = null;
				_client = null;
			}
			if (log.IsDebugEnabled) {
				string msg = string.Format("MessageClient created with clientId {0} for destination {1}", _clientId, _messageDestination.Id);
				log.Debug(msg);
			}
		}
Exemplo n.º 2
0
		internal void ResetEndpoint(string endpointId) {
			string oldEndpointId = null;
			Session oldSession = null;
			Session newSession = FluorineContext.Current.Session as Session;
			lock (this.SyncRoot) {
				// If anything is null, or nothing has changed, no need for a reset.
				if (_endpointId == null || endpointId == null || _session == null || newSession == null || (_endpointId.Equals(endpointId) && _session.Equals(newSession)))
					return;

				oldEndpointId = _endpointId;
				_endpointId = endpointId;

				oldSession = _session;
				_session = newSession;
			}
			// Unregister in order to reset the proper push settings in the re-registration below once the session association has been patched.
			if (_client != null)
				_client.UnregisterMessageClient(this);
			// Clear out any reference to this subscription that the previously associated session has.
			if (oldSession != null)
				oldSession.UnregisterMessageClient(this);
			// Associate the current session with this subscription.
			if (_session != null)
				_session.RegisterMessageClient(this);
			// Reset proper push settings.
			if (_client != null)
				_client.RegisterMessageClient(this);

			if (log.IsDebugEnabled) {
				string msg = string.Format("MessageClient created with clientId {0} for destination {1} has been reset as a result of a resubscribe.", _clientId, _messageDestination.Id);
				if (oldEndpointId != null && !oldEndpointId.Equals(endpointId))
					msg += " Endpoint changed from " + oldEndpointId + " to " + endpointId;
				if ((oldSession != null) && (newSession != null) && (oldSession != newSession))
					msg += " Session changed from " + oldSession.Id + " to " + newSession.Id;
				log.Debug(msg);
			}
		}