FreeFireSocketService<T> class

Service class for managing WebSocket communication and optional data persistence.

The FreeFireSocketService class connects to a WebSocket server using the provided SocketConfig, manages incoming and outgoing messages, and optionally persists data using SharedPreferences.

Generics:

  • T: Type of data received and sent over the WebSocket.

Constructors

FreeFireSocketService(SocketConfig _socketConfig)
Creates a FreeFireSocketService instance with the specified socketConfig.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stream Stream<T>
Stream of data received from the WebSocket.
no setter

Methods

actOnId(String id, CrudAction action, {String? newValue, String persistKey = 'defaultPersistKey'}) Future<List<String>>
Performs a CRUD action on persisted data.
clearPersistedData([String? persistKey]) Future<void>
Clears persisted data for the specified persistKey.
close() → void
Closes the WebSocket connection.
connect() Future<void>
Connects to the WebSocket server and starts listening for messages.
dispose() → void
Disposes of resources used by the service.
getPersistedData([String? persistKey]) Future<List<String>>
Retrieves persisted data from SharedPreferences.
init() Future<void>
Initializes the service, setting up persistence if configured.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
send(String message, {String persistKey = 'defaultPersistKey'}) Future<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