SocketServer class

WebSocket Server entry point for Khadem framework.

This class manages the WebSocket server lifecycle, including:

  • Starting and stopping the server
  • Handling WebSocket upgrades
  • Managing client connections
  • Routing events to handlers
  • Executing middlewares

Constructors

SocketServer(SocketConfig config, {SocketManager? manager})

Properties

config SocketConfig
The configuration for the socket server.
final
hashCode int
The hash code for this object.
no setterinherited
manager SocketManager
no setter
port int
no setter
router SocketRouter
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
on(String event, SocketEventHandler handler) → void
Register a global event handler.
onConnect(FutureOr<void> callback(SocketClient client)) → void
Set callback for when a client connects.
onDisconnect(FutureOr<void> callback(SocketClient client)) → void
Set callback for when a client disconnects.
registerController(SocketController controller) → void
Register a socket controller.
routes(void callback(SocketRouter router)) → void
Define socket routes and their events.
start() Future<void>
Start the WebSocket server.
stop() Future<void>
toString() String
A string representation of this object.
inherited
useHandshakeMiddleware(List<Middleware> middlewares) → void
Add a middleware to run during the handshake phase (before upgrade). This is useful for authentication, CORS, etc.

Operators

operator ==(Object other) bool
The equality operator.
inherited