Package nl.justobjects.pushlet.core

Examples of nl.justobjects.pushlet.core.Event


        }
      }
    }

    private void publishStock(int index, String name, String rate) {
      Event event = Event.createDataEvent("/stocks/aex");
      event.setField("number", index + "");
      event.setField("name", name);
      event.setField("rate", rate);
      p("publish: nr=" + index + " name=" + name + " rate=" + rate);
      Dispatcher.getInstance().multicast(event);
    }
View Full Code Here


  /**
   * Unsubscribes with subscription id.
   */
  public void unsubscribe(String aSubscriptionId) throws PushletException {
    throwOnInvalidSession();
    Event event = new Event(E_UNSUBSCRIBE);
    event.setField(P_ID, id);

    // Optional subscription id
    if (aSubscriptionId != null) {
      event.setField(P_SUBSCRIPTION_ID, aSubscriptionId);
    }

    Event response = doControl(event);
    throwOnNack(response);
  }
View Full Code Here

    // Open URL connection with server
    Reader reader = openURL(controlURL);

    // Get Pushlet event from stream
    Event event = null;
    try {
      p("Getting event...");
      // Get next event from server
      event = EventParser.parse(reader);
      p("Event received " + event);
View Full Code Here

            this.notify();
          }

          // Get events while we're alive.
          while (receiveThread != null && receiveThread.isAlive()) {
            Event event = null;
            try {
              // p("Getting event...");
              // Get next event from server
              event = EventParser.parse(reader);
              p("Event received " + event);
            } catch (Throwable t) {

              // Stop and report error.
              // warn("Stop run() on exception", t);
              if (listener != null) {
                listener.onError("exception during receive: " + t);
              }

              break;
            }

            // Handle event by calling listener
            if (event != null && listener != null) {
              // p("received: " + event.toXML());
              String eventType = event.getEventType();
              if (eventType.equals(E_HEARTBEAT)) {
                listener.onHeartbeat(event);
              } else if (eventType.equals(E_DATA)) {
                listener.onData(event);
              } else if (eventType.equals(E_JOIN_LISTEN_ACK)) {
                id = event.getField(P_ID);
              } else if (eventType.equals(E_LISTEN_ACK)) {
                p("Listen ack ok");
              } else if (eventType.equals(E_REFRESH_ACK)) {
                // ignore
              } else if (eventType.equals(E_ABORT)) {
View Full Code Here

         
          if(list.size()==0){
            //DatabaseAccess.endConnectionToDB();
            return null;
          }else{
            Event event =Event.createDataEvent("/chat");
            for(int i=0,len=list.size();i<len;i++){
              msgT=list.get(i);
              event.setField("M"+i+"IDF",msgT.getpFrom());
              event.setField("M"+i+"MSG",msgT.getContent());
              event.setField("M"+i+"Time",msgT.getsTime().toString());
              event.setField("M"+i+"To", msgT.getpTo());
              event.setField("M"+i+"From", efrei.ngo.util.DatabaseAccess.dbGetNameViaID(msgT.getpFrom()));
            }
              //DatabaseAccess.endConnectionToDB();
              return event;
          }
        }
View Full Code Here

TOP

Related Classes of nl.justobjects.pushlet.core.Event

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.