Package com.trendrr.strest.server

Examples of com.trendrr.strest.server.ResponseBuilder


  /**
   * Closes this transaction.
   * @return
   */
  public ChannelFuture close() {
    ResponseBuilder response = new ResponseBuilder();
    response.txnStatusComplete();
    return this.sendMessage(response);
  }
View Full Code Here


  public void run() {
    //Send the firehose messages to all registered connections. 
    long num = 0;
    while (true) {
      //build the response.
      ResponseBuilder res = new ResponseBuilder();
      res.txnStatusContinue();//lets the client know to expect more messages.     
      //set the content message.
      res.contentUTF8("this is message number: " + num++ + "\r\nThere are " + connections.size() + " concurrent connections");
      //send it to all connections
      connections.sendMessage(res.getResponse());
      Sleep.millis(500);
    }   
  }
View Full Code Here

    }
    DynMap mp = new DynMap();
    mp.put("to", to);
    mp.put("from", from);
    mp.put("message", message);
    con.sendMessage(new ResponseBuilder().txnStatusContinue().contentJSON(mp));
  }
View Full Code Here

    String self = (String)con.getChannelStorage().get("username");
   
    //Now that I am registered to recieve connect message, then I
    //tell everyone else that I am online.
    ResponseBuilder response = new ResponseBuilder();
    response.txnStatus(StrestUtil.HEADERS.TXN_STATUS_VALUES.CONTINUE);
    response.contentUTF8(self);
    notifyConnect.sendMessage(response.getResponse());
   
   
    this.notifyConnect.addConnection(con);
    //now we send the user the list of all currently connected users
    for (String username : this.onlineNow.keySet()) {
      if (username.equals(self)) {
        continue; //don't need to notify about self
      }
      response = new ResponseBuilder();
      response.txnStatus(StrestUtil.HEADERS.TXN_STATUS_VALUES.CONTINUE);
      response.contentUTF8(username);
      con.sendMessage(response);
    }
  }
View Full Code Here

    if (username == null)
      return;
    this.onlineNow.remove(username);
    this.notifyMessage.remove(username);
    //now send the username to all who want connect notifications.
    ResponseBuilder response = new ResponseBuilder();
    response.txnStatus(StrestUtil.HEADERS.TXN_STATUS_VALUES.CONTINUE);
    response.contentUTF8(username);
    notifyDisconnect.sendMessage(response.getResponse());
  }
View Full Code Here

TOP

Related Classes of com.trendrr.strest.server.ResponseBuilder

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.