Пример #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;
 }
Пример #2
0
    @JSFunction
    public static Object shutdown(Context cx, Scriptable thisObj, Object[] args, Function func) {
      TCPImpl tcp = (TCPImpl) thisObj;

      clearErrno();
      QueuedWrite qw = (QueuedWrite) cx.newObject(thisObj, QueuedWrite.CLASS_NAME);
      qw.shutdown = true;
      tcp.offerWrite(qw, cx);
      return qw;
    }
Пример #3
0
 @JSGetter("writeQueueSize")
 public int getWriteQueueSize() {
   if (writeQueue == null) {
     return 0;
   }
   int s = 0;
   for (QueuedWrite qw : writeQueue) {
     s += qw.getLength();
   }
   return s;
 }
Пример #4
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;
    }