onSubscribe() — netty Function Reference
Architecture documentation for the onSubscribe() function in StompChatHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 91529c34_98b8_0877_0e3c_4566c29cc41c["onSubscribe()"] f937e446_8aba_2036_93fc_8020adb1953f["StompChatHandler"] 91529c34_98b8_0877_0e3c_4566c29cc41c -->|defined in| f937e446_8aba_2036_93fc_8020adb1953f 5ef12430_b789_c7f8_301d_8283d302e997["channelRead0()"] 5ef12430_b789_c7f8_301d_8283d302e997 -->|calls| 91529c34_98b8_0877_0e3c_4566c29cc41c f5104c6e_035e_0b9d_444a_4cc359d713bf["sendErrorFrame()"] 91529c34_98b8_0877_0e3c_4566c29cc41c -->|calls| f5104c6e_035e_0b9d_444a_4cc359d713bf style 91529c34_98b8_0877_0e3c_4566c29cc41c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
example/src/main/java/io/netty/example/stomp/websocket/StompChatHandler.java lines 76–111
private void onSubscribe(ChannelHandlerContext ctx, StompFrame inboundFrame) {
String destination = inboundFrame.headers().getAsString(DESTINATION);
String subscriptionId = inboundFrame.headers().getAsString(ID);
if (destination == null || subscriptionId == null) {
sendErrorFrame("missed header", "Required 'destination' or 'id' header missed", ctx);
return;
}
Set<StompSubscription> subscriptions = chatDestinations.get(destination);
if (subscriptions == null) {
subscriptions = new HashSet<StompSubscription>();
Set<StompSubscription> previousSubscriptions = chatDestinations.putIfAbsent(destination, subscriptions);
if (previousSubscriptions != null) {
subscriptions = previousSubscriptions;
}
}
final StompSubscription subscription = new StompSubscription(subscriptionId, destination, ctx.channel());
if (subscriptions.contains(subscription)) {
sendErrorFrame("duplicate subscription",
"Received duplicate subscription id=" + subscriptionId, ctx);
return;
}
subscriptions.add(subscription);
ctx.channel().closeFuture().addListener(f ->
chatDestinations.get(subscription.destination()).remove(subscription));
String receiptId = inboundFrame.headers().getAsString(RECEIPT);
if (receiptId != null) {
StompFrame receiptFrame = new DefaultStompFrame(StompCommand.RECEIPT);
receiptFrame.headers().set(RECEIPT_ID, receiptId);
ctx.writeAndFlush(receiptFrame);
}
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does onSubscribe() do?
onSubscribe() is a function in the netty codebase, defined in example/src/main/java/io/netty/example/stomp/websocket/StompChatHandler.java.
Where is onSubscribe() defined?
onSubscribe() is defined in example/src/main/java/io/netty/example/stomp/websocket/StompChatHandler.java at line 76.
What does onSubscribe() call?
onSubscribe() calls 1 function(s): sendErrorFrame.
What calls onSubscribe()?
onSubscribe() is called by 1 function(s): channelRead0.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free