WebSocketClient class
A WebSocket client for connecting to a WebSocket server, sending messages, and handling incoming messages.
This class provides methods to connect to a WebSocket server, send messages, and receive messages using Dart's WebSocket API. It includes callbacks for handling received messages and errors.
Constructors
- WebSocketClient({required String serverUrl, required void onMessageReceived(String message), required void fileCallBackFunction(Uint8List data), void onError(Object error)?})
- Constructor for WebSocketClient.
Properties
- fileCallBackFunction → void Function(Uint8List data)
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- onError → void Function(Object error)?
-
final
- onMessageReceived → void Function(String message)
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- serverUrl → String
-
final
Methods
-
connect(
) → Future< void> - Connects to the WebSocket server.
-
disconnect(
) → Future< void> - Closes the WebSocket connection.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
sendFileToServer(
String filePath) → Future< bool> - Sends a file over the WebSocket connection in chunks.
-
sendMessage(
String message) → void - Sends a message to the WebSocket server.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited