Example #1
0
 public bool isSubscribed(Subscriber s, int channelNumber)
 {
     using (ReadLocker wl = new ReadLocker(ref mSubscribersLock))
     {
         if (channelNumber > mSubscribers.Count)
             return false;
         return mSubscribers[channelNumber - 1].Contains(s);
     }
 }
 public void onDataCame(int channelNumber, byte[] data)
 {
     List<IDataReceiver> receivers;
     using (ReadLocker wl = new ReadLocker(ref mReceiversLock))
     {
         receivers = mReceivers.ConvertAll<IDataReceiver>(p => p);
     }
     foreach (IDataReceiver receiver in receivers)
     {
         receiver.onDataCame(channelNumber, data);
     }
 }
Example #3
0
 public List<int> channels(Subscriber s)
 {
     List<int> ret = new List<int>();
     using (ReadLocker rl = new ReadLocker(ref mSubscribersLock))
     {
         for (int i = 0; i < mSubscribers.Count; ++i)
         {
             if (mSubscribers[i].Contains(s))
             {
                 ret.Add(i + 1);
             }
         }
     }
     return ret;
 }
Example #4
0
 public void onDataCame(int channelNumber, byte[] data)
 {
     ByteArrayDataPackage package = new ByteArrayDataPackage(channelNumber, data);
     LatencyCounter.receivedPackage(package.id);
     Subscriber[] mReveiverSubscribers;
     using (ReadLocker rl = new ReadLocker(ref mSubscribersLock))
     {
         mReveiverSubscribers = new Subscriber[mSubscribers[package.channelNumber - 1].Count];
         mSubscribers[package.channelNumber - 1].CopyTo(mReveiverSubscribers);
     }
     foreach (Subscriber s in mReveiverSubscribers)
     {
         s.onDataCame(package);
     }
     LatencyCounter.gavePackage(package.id);
 }