示例#1
0
 public override void Push(IMessage message, MessageClient messageClient)
 {
     if (this.ChannelDefinition.Properties.IsPollingEnabled)
     {
         IEndpointPushHandler handler = messageClient.Client.GetEndpointPushHandler(this.Id);
         if (handler != null)
         {
             IMessage messageClone = message.Copy() as IMessage;
             messageClone.SetHeader(MessageBase.DestinationClientIdHeader, messageClient.ClientId);
             messageClone.clientId = messageClient.ClientId;
             handler.PushMessage(messageClone);
         }
         /*
         IMessage messageClone = message.Clone() as IMessage;
         messageClone.SetHeader(MessageBase.DestinationClientIdHeader, messageClient.ClientId);
         messageClone.clientId = messageClient.ClientId;
         messageClient.AddMessage(messageClone);
         */
     }
     else
     {
         if (log.IsWarnEnabled)
             log.Warn("Push request received for the non-polling AMF endpoint '" + this.Id + "'");
     }
 }
示例#2
0
		public override void Push(IMessage message, MessageClient messageClient)
		{
            /*
            IMessageConnection messageConnection = messageClient.MessageConnection;
            Debug.Assert(messageConnection != null);
            if (messageConnection != null)
                messageConnection.Push(message, messageClient);
            */
            ISession session = messageClient.Session;
            System.Diagnostics.Debug.Assert(session != null);
            session.Push(message, messageClient);
		}
 public override void Push(IMessage message, MessageClient messageClient)
 {
     IEndpointPushHandler handler = messageClient.Client.GetEndpointPushHandler(this.Id);
     if (handler != null)
     {
         IMessage messageClone = message.Copy() as IMessage;
         messageClone.SetHeader(MessageBase.DestinationClientIdHeader, messageClient.ClientId);
         messageClone.clientId = messageClient.ClientId;
         handler.PushMessage(messageClone);
     }
     /*
     IMessage messageClone = message.Clone() as IMessage;
     messageClone.SetHeader(MessageBase.DestinationClientIdHeader, messageClient.ClientId);
     messageClone.clientId = messageClient.ClientId;
     messageClient.AddMessage(messageClone);
     */
 }
        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;
                }
			}
		}
 public void CancelTimeout(MessageClient messageClient)
 {
     lock (_objLock)
     {
         HttpRuntime.Cache.Remove(messageClient.ClientId);
     }
 }
		public MessageClient RemoveSubscriber(MessageClient messageClient)
		{
			if( log.IsDebugEnabled )
				log.Debug(__Res.GetString(__Res.SubscriptionManager_Remove, messageClient.ClientId));

			lock(_objLock)
			{
				RemoveSubscriber(messageClient.ClientId);
				return messageClient;
			}
		}
		private void AddSubscriber(MessageClient messageClient)
		{
            lock (_objLock)
            {
                if (!_subscribers.Contains(messageClient.ClientId))
                {
                    _subscribers[messageClient.ClientId] = messageClient;
                    // Add the MessageClient to the Cache with the expiration item
                    int timeOutMinutes = 20;
                    if (_messageDestination.DestinationDefinition.Properties.Network != null)
                        timeOutMinutes = _messageDestination.DestinationDefinition.Properties.Network.SessionTimeout;


                    HttpRuntime.Cache.Insert(messageClient.ClientId, messageClient, null,
                        Cache.NoAbsoluteExpiration,
                        new TimeSpan(0, timeOutMinutes, 0),
                        CacheItemPriority.NotRemovable, new CacheItemRemovedCallback(this.RemovedCallback));

                    /*
                    HttpRuntime.Cache.Insert( messageClient.ClientId, messageClient, null, 
                        DateTime.Now.AddSeconds(timeOutMinutes),
                        TimeSpan.Zero,
                        CacheItemPriority.Default, new CacheItemRemovedCallback(this.RemovedCallback) );
                    */
                }
            }
		}
示例#8
0
		public virtual void Push(IMessage message, MessageClient messageClient)
		{
			throw new NotSupportedException();
		}