Implementation:A616567126 GPT WEB JAVA UserMessageListener
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Event_Dispatch, Discord_Integration |
| Last Updated | 2026-10-13 00:00 GMT |
Overview
Concrete tool for dispatching Discord WSS message events to type-specific handlers after filtering by channel and message type, provided by the application framework.
Description
The UserMessageListener class receives raw Discord WSS dispatch events from UserWebSocketStarter.handleDispatch(). It:
- Parses the event type (
tfield) into aMessageTypeenum - Filters out
DELETEmessages and null types - Checks that the event's
channel_idmatches the account'schannelId - Iterates all registered
MessageHandlerimplementations and callshandle(messageType, data)
A 50ms sleep is added before dispatch to avoid race conditions with the Discord REST API.
Usage
Import this class when you need to:
- Understand how Discord WSS events are routed to handlers
- Register custom message handlers for specific event types
Code Reference
Source Location
- Repository: GPT-WEB-JAVA
- File: src/main/java/com/intelligent/bot/server/wss/user/UserMessageListener.java
Signature
public class UserMessageListener {
public UserMessageListener(DiscordAccount account, List<MessageHandler> messageHandlers);
public void onMessage(DataObject raw) throws WxErrorException;
}
Import
import com.intelligent.bot.server.wss.user.UserMessageListener;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| raw | DataObject | Discord WSS dispatch event with type (t) and data (d) |
Outputs
| Name | Type | Description |
|---|---|---|
| (side effect) | void | Each matching MessageHandler.handle() is called |
Usage Examples
Event Dispatch Flow
// Called by UserWebSocketStarter.handleDispatch()
userMessageListener.onMessage(raw);
// 1. MessageType.of(raw.getString("t")) → e.g. MESSAGE_CREATE
// 2. Filter: channel_id must match account.channelId
// 3. 50ms sleep
// 4. For each handler: handler.handle(messageType, data)
// - ImagineSuccessHandler handles SUCCESS imagine results
// - StartAndProgressHandler handles START/PROGRESS updates
// - ErrorMessageHandler handles error messages
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment