LCM.LCM.LCM.ReceiveMessage C# (CSharp) Method

ReceiveMessage() private method

Not for use by end users. Provider back ends call this method when they receive a message. The subscribers that match the channel name are synchronously notified.
private ReceiveMessage ( string channel, byte data, int offset, int length ) : void
channel string
data byte
offset int
length int
return void
		internal void ReceiveMessage(string channel, byte[] data, int offset, int length)
		{
            if (this.closed)
            {
                throw new SystemException();
            }

			lock (subscriptions)
            {
                List<SubscriptionRecord> srecs;
                subscriptionsMap.TryGetValue(channel, out srecs);

				if (srecs == null)
				{
					// must build this list!
					srecs = new List<SubscriptionRecord>();
					subscriptionsMap.Add(channel, srecs);
					
					foreach (SubscriptionRecord srec in subscriptions)
					{
                        if (srec.pat.IsMatch(channel))
                        {
                            srecs.Add(srec);
                        }
					}
				}
				
				foreach (SubscriptionRecord srec in srecs)
				{
					srec.lcsub.MessageReceived(this, channel, new LCMDataInputStream(data, offset, length));
				}
			}
		}
	}

Usage Example

        private void HandleShortMessage(byte[] packetData, IPEndPoint from, LCMDataInputStream ins)
        {
            int    msgSeqNumber = ins.ReadInt32();
            string channel      = ins.ReadStringZ();

            lcm.ReceiveMessage(channel, ins.Buffer, ins.BufferOffset, ins.Available);
        }