private final void writeDebugInfo(int classId, int tag) {
    if (!Debug.COMMUNICATIONS || !getCheckCommunications()) throw new IllegalStateException();

    if (Debug.COMMUNICATIONS_LOG_ALL) {
      String name = ImmutableClass.ALL.get(classId).toString();
      Log.write(
          PlatformClass.getSimpleName(getClass())
              + ", "
              + ThreadAssert.getOrCreateCurrent().getWriterDebugCounter(this)
              + ", class: "
              + name
              + ", tag: "
              + tag);
    }

    Debug.assertion(classId == Helper.getInstance().getExpectedClass());
    long debugCounter = ThreadAssert.getOrCreateCurrent().getAndIncrementWriterDebugCounter(this);
    writeLongToBuffer(debugCounter);
    writeByteToBuffer((byte) classId);
    writeIntegerToBuffer(tag);
    writeIntegerToBuffer(getCustomDebugInfo1());
    writeIntegerToBuffer(getCustomDebugInfo2());
  }
Exemple #2
0
  @SuppressWarnings("unchecked")
  public void onModuleLoad() {
    /*
     * Redirect log to web page.
     */
    Log.add(
        new Log() {

          @Override
          protected void onWrite(String message) {
            RootPanel.get("log").add(new HTML(message));
          }
        });

    /*
     * Like Java applications, GWT object models must be registered.
     */
    MyObjectModel.register();

    final HTTPClient client = new HTTPClient("http://localhost:8080");

    client.setCallback(
        new Callback() {

          public void onReceived(Object object) {
            Log.write("Received: " + object);

            if (object instanceof String) Debug.assertAlways("Blah".equals(object));

            if (object instanceof Integer) Debug.assertAlways(42 == (Integer) object);

            if (object instanceof Car) {
              car = (Car) object;
              Debug.assertAlways("Joe".equals(car.getDriver().getName()));
            }

            if (object instanceof Driver) {
              Driver friend = (Driver) object;
              Debug.assertAlways(5 == car.getSettings().get(friend).getSeatHeight());
            }

            if (object instanceof LazyMap) {
              final LazyMap<String, Car> map = (LazyMap) object;

              /*
               * Fetched only entry with key A.
               */
              map.getAsync(
                  "A",
                  new AsyncCallback<Car>() {

                    public void onSuccess(final Car a) {
                      Debug.assertAlways("Brand A".equals(a.getBrand()));

                      Log.write("Done!");
                      client.send("Done!");
                    }

                    public void onFailure(Throwable caught) {}
                  });
            }
          }

          public void onDisconnected(Exception e) {}
        });

    Log.write("Connecting...");
    client.connectAsync();
  }