Example #1
0
 /// <summary>Sends an object on <see cref="channelId"/> to many clients in an efficient manner.</summary>
 /// <param name="o">The object to send</param>
 /// <param name="channelId">The channel to be sent on</param>
 /// <param name="list">The list of clients; if null then all clients</param>
 /// <param name="mdr">How to send it (can be null)</param>
 public virtual void Send(object o, byte channelId, ICollection<IConnexion> list, MessageDeliveryRequirements mdr)
 {
     Send(new SingleItem<Message>(new ObjectMessage(channelId, o)), list, mdr);
 }
Example #2
0
 /// <summary>Sends a byte array on <see cref="channelId"/> to many clients in an efficient manner.</summary>
 /// <param name="buffer">The byte array to send</param>
 /// <param name="channelId">The channel to be sent on</param>
 /// <param name="list">The list of clients; if null then all clients</param>
 /// <param name="mdr">How to send it (can be null)</param>
 public virtual void Send(byte[] buffer, byte channelId, ICollection<IConnexion> list, MessageDeliveryRequirements mdr)
 {
     Send(new SingleItem<Message>(new BinaryMessage(channelId, buffer)),
     list, mdr);
 }
Example #3
0
 /// <summary>Sends a string on <see cref="channelId"/> to many clients in an efficient manner.</summary>
 /// <param name="s">The string to send</param>
 /// <param name="channelId">The channel to be sent on</param>
 /// <param name="list">The list of clients; if null then all clients</param>
 /// <param name="mdr">How to send it (can be null)</param>
 public virtual void Send(string s, byte channelId, ICollection<IConnexion> list, MessageDeliveryRequirements mdr)
 {
     Send(new SingleItem<Message>(new StringMessage(channelId, s)), list, mdr);
 }
Example #4
0
 public void Send(object o, byte channelId, MessageDeliveryRequirements mdr, ChannelDeliveryRequirements cdr)
 {
     Send(new ObjectMessage(channelId, o), mdr, cdr);
 }
Example #5
0
 /// <summary>Send notice of some session action.</summary>
 /// <param name="clientId">The subject of the action.</param>
 /// <param name="e">The session action.</param>
 /// <param name="channelId">Channel on which to send the notice.</param>
 /// <param name="mdr">How to send the session message (can be null)</param>
 /// <param name="cdr">Requirements for the message's channel.</param>
 public void Send(int clientId, SessionAction e, byte channelId, MessageDeliveryRequirements mdr,
     ChannelDeliveryRequirements cdr)
 {
     Send(new SessionMessage(channelId, clientId, e), mdr, cdr);
 }
Example #6
0
 public NoMatchingTransport(IConnexion connexion, MessageDeliveryRequirements mdr,
     ChannelDeliveryRequirements cdr)
     : base(Severity.Warning, String.Format("Could not find capable transport (mdr={0}, cdr={1})", mdr, cdr))
 {
     SourceComponent = connexion;
     this.mdr = mdr;
     this.cdr = cdr;
 }
Example #7
0
 public void Send(string s, byte channelId, MessageDeliveryRequirements mdr, ChannelDeliveryRequirements cdr)
 {
     Send(new StringMessage(channelId, s), mdr, cdr);
 }
Example #8
0
 public void Send(Message msg, MessageDeliveryRequirements mdr, ChannelDeliveryRequirements cdr)
 {
     Scheduler.Schedule(msg, mdr, cdr);
 }
Example #9
0
 public void Send(IList<Message> msgs, MessageDeliveryRequirements mdr, ChannelDeliveryRequirements cdr)
 {
     foreach (Message m in msgs)
     {
         Scheduler.Schedule(m, mdr, cdr);
     }
 }
Example #10
0
        /// <summary>Adds the message to a list, waiting to be sent out.</summary>
        /// <param name="newMsg">The message to be aggregated</param>
        /// <param name="mdr">How it should be sent out (potentially null)</param>
        /// <param name="cdr">General delivery instructions for this message's channel.</param>
        private void Aggregate(Message newMsg, MessageDeliveryRequirements mdr, ChannelDeliveryRequirements cdr)
        {
            Debug.Assert(mdr != null || cdr != null);
            if (newMsg.MessageType != MessageType.System && cdr != null
                && cdr.Freshness == Freshness.IncludeLatestOnly)
            {
                pending.RemoveAll(pendingMsg => pendingMsg.Message.ChannelId == newMsg.ChannelId
                    && pendingMsg.Message.MessageType != MessageType.System);
            }

            if (!channelIndices.ContainsKey(newMsg.ChannelId))
            {
                channelIndices[newMsg.ChannelId] = channels.Count;
                channels.Add(newMsg.ChannelId);
            }

            PendingMessage pm = pmPool.Obtain();
            pm.Message = newMsg;
            pm.MDR = mdr;
            pm.CDR = cdr;

            MessageAggregation aggr = mdr == null ? cdr.Aggregation : mdr.Aggregation;
            if (aggr == MessageAggregation.Immediate)
            {
                pending.Insert(0, pm);
                nextChannelIndex = channelIndices[newMsg.ChannelId];
            }
            else
            {
                pending.Add(pm);
            }
        }
Example #11
0
 public ITransport FindTransport(MessageDeliveryRequirements mdr, ChannelDeliveryRequirements cdr)
 {
     ITransport t = null;
     if (mdr != null) { t = mdr.SelectTransport(Transports); }
     if (t != null) { return t; }
     if (t == null && cdr != null) { t = cdr.SelectTransport(Transports); }
     if (t != null) { return t; }
     throw new NoMatchingTransport(this, mdr, cdr);
 }
Example #12
0
        public override void Schedule(Message msg, MessageDeliveryRequirements mdr,
            ChannelDeliveryRequirements cdr)
        {
            MessageAggregation aggr = mdr == null ? cdr.Aggregation : mdr.Aggregation;

            // Place the message, performing any channel-compaction if so specified
            // by cdr.Freshness
            Aggregate(msg, mdr, cdr);

            if (aggr == MessageAggregation.FlushChannel)
            {
                // make sure ALL other messages on this CHANNEL are sent, and then send <c>msg</c>.
                FlushChannelMessages(msg.ChannelId);
            }
            else if (aggr == MessageAggregation.FlushAll)
            {
                // make sure ALL messages are sent, then send <c>msg</c>.
                Flush();
            }
            else if (aggr == MessageAggregation.Immediate)
            {
                // bundle <c>msg</c> first and then cram on whatever other messages are waiting.
                Flush();
            }
        }
Example #13
0
 public override void Schedule(Message m, MessageDeliveryRequirements mdr,
     ChannelDeliveryRequirements cdr)
 {
     try
     {
         ITransport t = cnx.FindTransport(mdr, cdr);
         FastpathSendMessage(t, m);
     }
     catch (NoMatchingTransport e)
     {
         NotifyError(new ErrorSummary(Severity.Warning, SummaryErrorCode.MessagesCannotBeSent,
             e.Message, new PendingMessage(m, mdr, cdr), e));
     }
 }
Example #14
0
 public abstract void Schedule(Message m, MessageDeliveryRequirements mdr,
     ChannelDeliveryRequirements cdr);
Example #15
0
 /// <summary>Send a message to many clients in an efficient manner.</summary>
 /// <param name="message">The message to send</param>
 /// <param name="list">The list of clients; if null then all clients</param>
 /// <param name="mdr">How to send it (can be null)</param>
 public virtual void Send(Message message, ICollection<IConnexion> list, MessageDeliveryRequirements mdr)
 {
     Send(new SingleItem<Message>(message), list, mdr);
 }
Example #16
0
 public void Send(byte[] buffer, byte channelId, MessageDeliveryRequirements mdr, ChannelDeliveryRequirements cdr)
 {
     Send(new BinaryMessage(channelId, buffer), mdr, cdr);
 }
Example #17
0
        /// <summary>Sends a collection of messages in an efficient way to a list of clients.</summary>
        /// <param name="messages">The list of messages to send</param>
        /// <param name="list">The list of clients; if null then all clients</param>
        /// <param name="mdr">How to send it (can be null)</param>
        public virtual void Send(IList<Message> messages, ICollection<IConnexion> list, MessageDeliveryRequirements mdr)
        {
            InvalidStateException.Assert(Active, "Cannot send on a stopped server", this);
            if (list == null)
            {
                list = Connexions;
            }
            foreach (IConnexion c in list)
            {
                if (!c.Active) { continue; }
                //Console.WriteLine("{0}: sending to {1}", this, c);
                try
                {
                    c.Send(messages, mdr, GetChannelDeliveryRequirements(messages[0].ChannelId));
                }
                catch (GTException e)
                {
                    NotifyError(new ErrorSummary(Severity.Warning, SummaryErrorCode.MessagesCannotBeSent,
                        "Exception when sending messages", e));
                }
            }

            if (MessagesSent != null) { MessagesSent(messages, list, mdr); }
        }
Example #18
0
 public PendingMessage(Message m, MessageDeliveryRequirements mdr, ChannelDeliveryRequirements cdr)
 {
     Message = m;
     MDR = mdr;
     CDR = cdr;
 }