Exemple #1
0
 public MessageClient AddSubscriber(IClient client, string messageClientId, string endpointId, MessageDestination messageDestination, Subtopic subtopic, Selector selector)
 {
     lock (_objLock)
     {
         if (subtopic != null)
         {
             MessagingAdapter serviceAdapter = this._messageDestination.ServiceAdapter as MessagingAdapter;
             if ((serviceAdapter != null) && !serviceAdapter.AllowSubscribe(subtopic))
             {
                 ASObject extendedData = new ASObject();
                 extendedData["subtopic"] = subtopic.Value;
                 throw new MessageException(extendedData);
             }
         }
         if (!this._subscribers.Contains(messageClientId))
         {
             MessageClient messageClient = new MessageClient(client, messageDestination.SubscriptionManager, messageClientId, endpointId, messageDestination)
             {
                 Subtopic = subtopic,
                 Selector = selector
             };
             client.RegisterMessageClient(messageClient);
             this.AddSubscriber(messageClient);
             return(messageClient);
         }
         return(this._subscribers[messageClientId] as MessageClient);
     }
 }
 public MessageClient AddSubscriber(string clientId, string endpointId, Subtopic subtopic, Selector selector)
 {
     lock (_objLock)
     {
         if (subtopic != null)
         {
             MessagingAdapter messagingAdapter = _messageDestination.ServiceAdapter as MessagingAdapter;
             if (messagingAdapter != null)
             {
                 if (!messagingAdapter.AllowSubscribe(subtopic))
                 {
                     ASObject aso = new ASObject();
                     aso["subtopic"] = subtopic.Value;
                     throw new MessageException(aso);
                 }
             }
         }
         if (!_subscribers.Contains(clientId))
         {
             //Set in RtmpService
             MessageClient messageClient = new MessageClient(clientId, _messageDestination, endpointId);
             messageClient.Subtopic = subtopic;
             messageClient.Selector = selector;
             messageClient.AddSubscription(selector, subtopic);
             AddSubscriber(messageClient);
             messageClient.NotifyCreatedListeners();
             return(messageClient);
         }
         else
         {
             MessageClient messageClient = _subscribers[clientId] as MessageClient;
             IClient       client        = FluorineContext.Current.Client;
             if (client != null && !client.Id.Equals(messageClient.Client.Id))
             {
                 throw new MessageException("Duplicate subscriptions from multiple Flex Clients");
             }
             //Reset the endpoint push state for the subscription to make sure its current because a resubscribe could be arriving over a new endpoint or a new session.
             messageClient.ResetEndpoint(endpointId);
             return(messageClient);
         }
     }
 }