コード例 #1
0
ファイル: Server.cs プロジェクト: briandealwis/gt
 /// <summary>
 /// Set the delivery requirements for a particular channel.
 /// </summary>
 /// <param name="channelId">the channel</param>
 /// <param name="cdr">the delivery requirements to be configured; null to remove</param>
 public virtual void SetChannelDeliveryRequirements(byte channelId, ChannelDeliveryRequirements cdr)
 {
     if (cdr == null)
     {
         channelRequirements.Remove(channelId);
     }
     else
     {
         channelRequirements[channelId] = cdr;
     }
 }
コード例 #2
0
 public void Send(object o, byte channelId, MessageDeliveryRequirements mdr, ChannelDeliveryRequirements cdr)
 {
     Send(new ObjectMessage(channelId, o), mdr, cdr);
 }
コード例 #3
0
ファイル: Server.cs プロジェクト: briandealwis/gt
 /// <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);
 }
コード例 #4
0
 public void Send(byte[] buffer, byte channelId, MessageDeliveryRequirements mdr, ChannelDeliveryRequirements cdr)
 {
     Send(new BinaryMessage(channelId, buffer), mdr, cdr);
 }
コード例 #5
0
 public void Send(string s, byte channelId, MessageDeliveryRequirements mdr, ChannelDeliveryRequirements cdr)
 {
     Send(new StringMessage(channelId, s), mdr, cdr);
 }
コード例 #6
0
 public void Send(Message msg, MessageDeliveryRequirements mdr, ChannelDeliveryRequirements cdr)
 {
     Scheduler.Schedule(msg, mdr, cdr);
 }
コード例 #7
0
 public void Send(IList<Message> msgs, MessageDeliveryRequirements mdr, ChannelDeliveryRequirements cdr)
 {
     foreach (Message m in msgs)
     {
         Scheduler.Schedule(m, mdr, cdr);
     }
 }
コード例 #8
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);
            }
        }
コード例 #9
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);
 }
コード例 #10
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();
            }
        }
コード例 #11
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));
     }
 }
コード例 #12
0
 public abstract void Schedule(Message m, MessageDeliveryRequirements mdr,
     ChannelDeliveryRequirements cdr);
コード例 #13
0
ファイル: NetExceptions.cs プロジェクト: briandealwis/gt
 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;
 }
コード例 #14
0
ファイル: Messages.cs プロジェクト: briandealwis/gt
 public PendingMessage(Message m, MessageDeliveryRequirements mdr, ChannelDeliveryRequirements cdr)
 {
     Message = m;
     MDR = mdr;
     CDR = cdr;
 }