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

Method close

ZezeJava/ZezeJava/src/main/java/Zeze/Net/Websocket.java:55–81  ·  view source on GitHub ↗
(@Nullable Throwable ex, boolean gracefully)

Source from the content-addressed store, hash-verified

53 }
54
55 @Override
56 public boolean close(@Nullable Throwable ex, boolean gracefully) {
57 if (!closedHandle.compareAndSet(this, (byte)0, (byte)1)) // 阻止递归关闭
58 return false;
59
60 if (ex != null) {
61 if (ex instanceof IOException)
62 logger.info("close: {} {}", this, ex);
63 else
64 logger.warn("close: {} exception:", this, ex);
65 } else
66 logger.info("close: {}{}", this, gracefully ? " gracefully" : "");
67
68 try {
69 getService().OnSocketClose(this, ex);
70 } catch (Exception e) {
71 logger.error("Service.OnSocketClose exception:", e);
72 }
73 if (null == ex)
74 x.closeConnectionOnFlush(null); // 总是gracefully
75 else
76 x.closeConnectionNow();
77
78 if (timeThrottle != null)
79 timeThrottle.close();
80 return true;
81 }
82
83 void processInput(ByteBuf buf) throws Exception {
84 int n = buf.readableBytes();

Callers

nothing calls this directly

Calls 5

closeConnectionNowMethod · 0.80
closeMethod · 0.65
OnSocketCloseMethod · 0.45
getServiceMethod · 0.45

Tested by

no test coverage detected