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

Method SendShared

ZezeJava/ZezeJava/src/main/java/Zeze/Net/TcpSocket.java:520–552  ·  view source on GitHub ↗
(@NotNull Protocol<?> p)

Source from the content-addressed store, hash-verified

518 }
519
520 public boolean SendShared(@NotNull Protocol<?> p) {
521 if (ENABLE_PROTOCOL_LOG && canLogProtocol(p.getTypeId()))
522 log("SEND", getSessionId(), p);
523
524 var result = submitAction(() -> { // 进selector线程调用
525 var bb = p.encodeShared();
526 var bytes = bb.Bytes;
527 var offset = bb.ReadIndex;
528 var length = bb.size();
529
530 var newSize = (long)outputBufferSizeHandle.getAndAdd(this, (long)length) + length;
531 if (!getService().checkOverflow(this, newSize, bytes, offset, length)) {
532 outputBufferSizeHandle.getAndAdd(this, (long)-length);
533 return;
534 }
535 var codec = outputCodecChain;
536 if (codec != null) {
537 sendRawSize += length;
538 // 压缩加密等 codec 链操作。
539 int oldSize = outputBuffer.size();
540 codec.update(bytes, offset, length);
541 int deltaLen = outputBuffer.size() - oldSize - length;
542 if (deltaLen != 0)
543 outputBufferSizeHandle.getAndAdd(this, (long)deltaLen);
544 } else
545 outputBuffer.put(bytes, offset, length);
546 if (ZezeCounter.instance != null)
547 ZezeCounter.instance.addSendSize(bytes, offset, length);
548 });
549 if (result)
550 setActiveSendTime();
551 return result;
552 }
553
554 private void processReceive(@NotNull SocketChannel sc) throws Exception { // 只在selector线程调用
555 recvCount++;

Callers

nothing calls this directly

Calls 13

submitActionMethod · 0.95
canLogProtocolMethod · 0.80
encodeSharedMethod · 0.80
checkOverflowMethod · 0.80
setActiveSendTimeMethod · 0.80
getTypeIdMethod · 0.65
getSessionIdMethod · 0.65
sizeMethod · 0.65
updateMethod · 0.65
putMethod · 0.65
addSendSizeMethod · 0.65
logMethod · 0.45

Tested by

no test coverage detected