You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(SIKNet): Introduce WebSocket support and a Netty plugin framework
This commit introduces two major features to the SIKNet module: comprehensive support for WebSocket clients and servers using Netty, and a new plugin system for extending Netty managers.
### 1. WebSocket Client and Server Implementation (Netty)
This addition provides the tools to build high-performance, real-time communication applications.
* **WebSocket Server**:
* `WebSocketServerConfig`: A new configuration class to set up a WebSocket server, defining port, path, and heartbeat intervals.
* `WebSocketServerHandler`: Manages the server-side WebSocket lifecycle, handling text/binary frames, ping/pong, close frames, and idle timeouts to automatically close inactive connections.
* The pipeline is configured with `HttpServerCodec`, `HttpObjectAggregator`, and `WebSocketServerProtocolHandler` for standard WebSocket handshakes and frame aggregation.
* **WebSocket Client**:
* `WebSocketClientConfig`: A new configuration class that takes a WebSocket URL (`ws://` or `wss://`) and manages connection parameters like reconnect intervals.
* `WebSocketClientHandler`: Manages client-side logic, including sending pings on writer idle to keep the connection alive.
* `MessageListener`: A new interface (`onMessage`, `onRawMessage`) is introduced, allowing consumers to receive incoming text and binary data from the client.
### 2. Netty Plugin System
A new "side-channel" plugin framework has been added to allow for observing Netty events without modifying business logic or data streams.
* **`NettyPlugin` Interface**: Defines the core contract for plugins with hooks for manager startup/shutdown (`onStarted`, `onStopping`) and channel installation (`install`).
* **`SimplePlugin` Abstract Class**: A convenience class that simplifies plugin creation by providing simple, overridable hooks for connection events (`onConnect`, `onDisconnect`), idle events, read/write operations (`beforeRead`, `afterRead`, `beforeWrite`, `afterWrite`), and exceptions.
* **Integration**: `NettyConfig` now accepts a list of plugins, which are automatically installed and managed by `NettyClientManager` and `NettyServerManager`.
### Refinements & Fixes
* **`HttpExtension.kt`**:
* The `toMap()` extension function has been improved to safely handle `null` property values, converting them to an empty string instead of causing a crash.
* URL parameter construction now uses `StringBuilder` for minor style and performance improvements.
* **`ConnectionManager.kt`**: Removed the `@JvmStatic` annotation from the singleton instance.
### Version Update
* The project version in `gradle.properties` has been incremented from `1.1.68` to `1.1.69`.