Ejemplo n.º 1
0
 public Object writeString(Context cx, String s, Charset cs) {
   clearErrno();
   QueuedWrite qw = (QueuedWrite) cx.newObject(this, QueuedWrite.CLASS_NAME);
   ByteBuffer bbuf = Utils.stringToBuffer(s, cs);
   qw.initialize(bbuf);
   byteCount += bbuf.remaining();
   offerWrite(qw, cx);
   return qw;
 }
Ejemplo n.º 2
0
    @JSFunction
    public static Object writeBuffer(Context cx, Scriptable thisObj, Object[] args, Function func) {
      ensureArg(args, 0);
      Buffer.BufferImpl buf = (Buffer.BufferImpl) args[0];
      TCPImpl tcp = (TCPImpl) thisObj;

      clearErrno();
      QueuedWrite qw = (QueuedWrite) cx.newObject(thisObj, QueuedWrite.CLASS_NAME);
      ByteBuffer bbuf = buf.getBuffer();
      qw.initialize(bbuf);
      tcp.byteCount += bbuf.remaining();
      tcp.offerWrite(qw, cx);
      return qw;
    }