MCPcopy Create free account
hub / github.com/e2wugui/zeze / Send

Method Send

ZezeJava/ZezeJava/src/main/java/Zeze/Net/TcpSocket.java:485–518  ·  view source on GitHub ↗

可能直接加到发送缓冲区,返回true则bytes不能再修改了。

(byte @NotNull [] bytes, int offset, int length)

Source from the content-addressed store, hash-verified

483 * 可能直接加到发送缓冲区,返回true则bytes不能再修改了。
484 */
485 @Override
486 public boolean Send(byte @NotNull [] bytes, int offset, int length) {
487 ByteBuffer.VerifyArrayIndex(bytes, offset, length);
488
489 var newSize = (long)outputBufferSizeHandle.getAndAdd(this, (long)length) + length;
490 try {
491 if (!getService().checkOverflow(this, newSize, bytes, offset, length)) {
492 outputBufferSizeHandle.getAndAdd(this, (long)-length);
493 return false;
494 }
495 if (submitAction(() -> { // 进selector线程调用
496 var codec = outputCodecChain;
497 if (codec != null) {
498 sendRawSize += length;
499 // 压缩加密等 codec 链操作。
500 int oldSize = outputBuffer.size();
501 codec.update(bytes, offset, length);
502 int deltaLen = outputBuffer.size() - oldSize - length;
503 if (deltaLen != 0)
504 outputBufferSizeHandle.getAndAdd(this, (long)deltaLen);
505 } else
506 outputBuffer.put(bytes, offset, length);
507 if (ZezeCounter.instance != null)
508 ZezeCounter.instance.addSendSize(bytes, offset, length);
509 })) {
510 setActiveSendTime();
511 return true;
512 }
513 } catch (Exception ex) {
514 outputBufferSizeHandle.getAndAdd(this, (long)-length);
515 close(ex);
516 }
517 return false;
518 }
519
520 public boolean SendShared(@NotNull Protocol<?> p) {
521 if (ENABLE_PROTOCOL_LOG && canLogProtocol(p.getTypeId()))

Callers

nothing calls this directly

Calls 10

VerifyArrayIndexMethod · 0.95
submitActionMethod · 0.95
closeMethod · 0.95
checkOverflowMethod · 0.80
setActiveSendTimeMethod · 0.80
sizeMethod · 0.65
updateMethod · 0.65
putMethod · 0.65
addSendSizeMethod · 0.65
getServiceMethod · 0.45

Tested by

no test coverage detected