Package org.jwebsocket.token

Examples of org.jwebsocket.token.Token


      // get the server time
      if ("requestServerTime".equals(lType)) {
        // create the response token
        // this includes the unique token-id
        Token lResponse = createResponse(aToken);

        // add the "time" and "started" field
        lResponse.put("time", new Date().toString());
        lResponse.put("started", aConnector.getVar(SAMPLE_VAR));

        // put an array into the token
        lResponse.put("array", new Object[]{1, 2, 3, 'a', 'b', 'c', "ABC", "XYZ", true, false});

        // put a map into the token
        Map lMap = new FastMap();
        lMap.put("MapItem1", 1);
        lMap.put("MapItem2", 2);
        lResponse.put("map", lMap);

        List lList = new FastList();
        lList.add("ListItem1");
        lList.add("ListItem2");
        lResponse.put("list", lList);

        // put a token into a token
        Token lToken = new Token();
        lToken.put("number", 1);
        lToken.put("string", "test");
        lToken.put("float", 1.23456);
        lToken.put("boolean", false);
        lToken.put("array", new Object[]{4, 5, 6, 'd', 'e', 'f', "DEF", "UVW", false, true});

        // insert subtoken, another level in object's hierarchy...
        Token lSubToken = new Token();
        lSubToken.put("number", 2);
        lSubToken.put("string", "demo");
        lSubToken.put("float", 2.34567);
        lSubToken.put("boolean", true);
        lSubToken.put("array", new Object[]{7, 8, 9, 'g', 'h', 'i', "GHI", "RST", true, false});
        lToken.put("subtoken", lSubToken);

        // put the token incl. its subtoken into the response
        lResponse.put("token", lToken);
View Full Code Here


   * @param aConnector
   * @param aPacket
   * @return
   */
  public Token packetToToken(WebSocketPacket aPacket) {
    Token lToken = null;
    if (lSubProt.equals(JWebSocketCommonConstants.SUB_PROT_JSON)) {
      lToken = JSONProcessor.packetToToken(aPacket);
    } else if (lSubProt.equals(JWebSocketCommonConstants.SUB_PROT_CSV)) {
      lToken = CSVProcessor.packetToToken(aPacket);
    } else if (lSubProt.equals(JWebSocketCommonConstants.SUB_PROT_XML)) {
View Full Code Here

  }
  private final static String NS_SYSTEM_PLUGIN = NS_BASE + ".plugins.system";

  @Override
  public void login(String aUsername, String aPassword) throws WebSocketException {
    Token lToken = new Token();
    lToken.put("type", "login");
    lToken.put("ns", NS_SYSTEM_PLUGIN);
    lToken.put("username", aUsername);
    lToken.put("password", aPassword);
    sendToken(lToken);
  }
View Full Code Here

    sendToken(lToken);
  }

  @Override
  public void logout() throws WebSocketException {
    Token lToken = new Token();
    lToken.put("type", "logout");
    lToken.put("ns", NS_SYSTEM_PLUGIN);
    sendToken(lToken);
  }
View Full Code Here

    sendToken(lToken);
  }

  @Override
  public void ping(boolean aEcho) throws WebSocketException {
    Token lToken = new Token();
    lToken.put("ns", NS_SYSTEM_PLUGIN);
    lToken.put("type", "ping");
    lToken.put("echo", aEcho);
    sendToken(lToken);
  }
View Full Code Here

    sendToken(lToken);
  }

  @Override
  public void sendText(String aTarget, String aData) throws WebSocketException {
    Token lToken = new Token();
    lToken.put("ns", NS_SYSTEM_PLUGIN);
    lToken.put("type", "send");
    lToken.put("targetId", aTarget);
    lToken.put("sourceId", getClientId());
    lToken.put("sender", getUsername());
    lToken.put("data", aData);
    sendToken(lToken);
  }
View Full Code Here

    sendToken(lToken);
  }

  @Override
  public void broadcastText(String aData) throws WebSocketException {
    Token lToken = new Token();
    lToken.put("ns", NS_SYSTEM_PLUGIN);
    lToken.put("type", "broadcast");
    lToken.put("sourceId", getClientId());
    lToken.put("sender", getUsername());
    lToken.put("data", aData);
    lToken.put("senderIncluded", false);
    lToken.put("responseRequested", true);
    sendToken(lToken);
  }
View Full Code Here

  }
  private final static String NS_FILESYSTEM_PLUGIN = NS_BASE + ".plugins.filesystem";

  // @Override
  public void saveFile(byte[] aData, String aFilename, String aScope, Boolean aNotify) throws WebSocketException {
    Token lToken = new Token();
    lToken.put("ns", NS_FILESYSTEM_PLUGIN);
    lToken.put("type", "save");
    lToken.put("sourceId", getClientId());
    lToken.put("sender", getUsername());
    lToken.put("filename", aFilename);
    // TODO: set mimetype correctly according to file extension based on configuration in jWebSocket.xml
    lToken.put("mimetype", "image/jpeg");
    lToken.put("scope", aScope);
    lToken.put("notify", aNotify);

    lToken.put("data", new String(Base64.encodeBase64(aData)));
    sendToken(lToken);
  }
View Full Code Here

  @Override
  public void disconnect() throws WebSocketException {
  }

  public void shutdown() throws WebSocketException {
    Token lToken = new Token();
    lToken.put("type", "shutdown");
    lToken.put("ns", NS_ADMIN_PLUGIN);
    sendToken(lToken);
  }
View Full Code Here

    sendToken(lToken);
  }

  @Override
  public void getConnections() throws WebSocketException {
    Token lToken = new Token();
    lToken.put("type", "getConnections");
    lToken.put("ns", NS_ADMIN_PLUGIN);
    sendToken(lToken);
  }
View Full Code Here

TOP

Related Classes of org.jwebsocket.token.Token

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.