Package com.caucho.json

Examples of com.caucho.json.JsonInput


  }

  public void init(InputStream is)
  {
    _is = is;
    _in = new JsonInput(is);
  }
View Full Code Here


    throws IOException
  {
    if (actorStream == null)
      throw new IllegalStateException("HmtpReader.readPacket requires a valid ActorStream for callbacks");

    JsonInput in = _in;

    if (in == null)
      return false;

    String type = readString();
    String to = readString();
    String from = readString();
    String payloadType = readString();
    Class payloadClass = getPayloadClass(payloadType);

    HmtpPacketType packetType = _typeMap.get(type);

    if (packetType == null) {
      throw new IllegalStateException("'" + type + "' is an unknown packet type");
    }

    switch (packetType) {
    case MESSAGE:
      {
        Serializable value = (Serializable) in.readObject(payloadClass);
        in.endPacket();

        if (log.isLoggable(Level.FINER)) {
          log.finer(this + " message " + value
                    + " {to:" + to + ", from:" + from + "}");
        }

        actorStream.message(to, from, value);

        break;
      }

    case MESSAGE_ERROR:
      {
        Serializable value = (Serializable) in.readObject();
        BamError error = (BamError) in.readObject(BamError.class);
        in.endPacket();

        if (log.isLoggable(Level.FINER)) {
          log.finer(this + " messageError " + error + " " + value
                    + " {to:" + to + ", from:" + from + "}");
        }

        actorStream.messageError(to, from, value, error);

        break;
      }

    case QUERY:
      {
        long id = in.readLong();
        Serializable value = (Serializable) in.readObject();
        in.endPacket();

        if (log.isLoggable(Level.FINER)) {
          log.finer(this + " query " + value
                    + " {id:" + id + ", to:" + to + ", from:" + from + "}");
        }

        actorStream.query(id, to, from, value);

        break;
      }

    case QUERY_RESULT:
      {
        long id = in.readLong();
        Serializable value = (Serializable) in.readObject();
        in.endPacket();

        if (log.isLoggable(Level.FINER)) {
          log.finer(this + " queryResult " + value
                    + " {id:" + id + ", to:" + to + ", from:" + from + "}");
        }

        actorStream.queryResult(id, to, from, value);

        break;
      }

    case QUERY_ERROR:
      {
        long id = in.readLong();
        Serializable value = (Serializable) in.readObject();
        BamError error = (BamError) in.readObject(BamError.class);
        in.endPacket();

        if (log.isLoggable(Level.FINER)) {
          log.finer(this + " queryError " + error + " " + value
                    + " {id:" + id + ", to:" + to + ", from:" + from + "}");
        }
View Full Code Here

  }

  public void close()
  {
    try {
      JsonInput in = _in;
      _in = null;

      if (in != null)
        in.close();
    } catch (IOException e) {
      log.log(Level.FINE, e.toString(), e);
    }

    // _client.close();
View Full Code Here

TOP

Related Classes of com.caucho.json.JsonInput

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.