Esempio n. 1
0
File: ZCM.java Progetto: ZeroCM/zcm
  /**
   * Subscribe to all channels whose name matches the regular expression. Note that to subscribe to
   * all channels, you must specify ".*", not "*".
   */
  public void subscribe(String regex, ZCMSubscriber sub) {
    if (this.closed) throw new IllegalStateException();
    SubscriptionRecord srec = new SubscriptionRecord();
    srec.regex = regex;
    srec.pat = Pattern.compile(regex);
    srec.lcsub = sub;

    synchronized (this) {
      zcmjni.subscribe(regex, this);
    }

    synchronized (subscriptions) {
      subscriptions.add(srec);

      for (String channel : subscriptionsMap.keySet()) {
        if (srec.pat.matcher(channel).matches()) {
          ArrayList<SubscriptionRecord> subs = subscriptionsMap.get(channel);
          subs.add(srec);
        }
      }
    }
  }
Esempio n. 2
0
File: ZCM.java Progetto: ZeroCM/zcm
 /**
  * Publish raw data on a channel, bypassing the ZCM type specification. If more than one URL was
  * specified when the ZCM object was created, the message will be sent on each.
  */
 public synchronized void publish(String channel, byte[] data, int offset, int length)
     throws IOException {
   if (this.closed) throw new IllegalStateException();
   zcmjni.publish(channel, data, offset, length);
 }