Пример #1
0
  @ProtocoderScript
  @APIMethod(description = "change the text", example = "")
  @APIParam(params = {"text"})
  public void setText(String text) throws UnknownHostException, JSONException {

    JSONObject values = new JSONObject().put("id", id).put("type", "label").put("val", text);

    JSONObject msg =
        new JSONObject().put("type", "widget").put("action", "setLabelText").put("values", values);

    CustomWebsocketServer.getInstance(a.get()).send(msg);
  }
Пример #2
0
  public void add(String name, int x, int y, int width, int height, int size, String color)
      throws UnknownHostException, JSONException {
    this.id = StrUtils.generateRandomString();

    JSONObject values =
        new JSONObject()
            .put("id", id)
            .put("name", name)
            .put("type", "label")
            .put("x", x)
            .put("y", y)
            .put("w", width)
            .put("h", height)
            .put("size", size)
            .put("color", color);

    JSONObject msg =
        new JSONObject().put("type", "widget").put("action", "add").put("values", values);

    CustomWebsocketServer.getInstance(a.get()).send(msg);
  }