SocketIOAdapter class
SocketIOAdapter is a class that wraps the socket.io client. It provides a simple interface to connect, disconnect, emit events and listen to events. It also provides a way to intercept requests and responses. The options is the options for the socket. The interceptors is a list of SocketInterceptors to intercept requests and responses. The checkResponse is a function that checks if the response from the server is valid. It takes a dynamic data as an argument and returns a boolean. By default, it checks if the status.ok field is true.
Constructors
Properties
- checkResponse ↔ bool Function(dynamic data)
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
interceptors
↔ List<
SocketInterceptor> -
getter/setter pair
- options ↔ SocketIOOptions
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- socket → Socket
-
no setter
Methods
-
connect(
[Map< String, dynamic> ? auth]) → dynamic -
connect connects to the server using the given
auth
parameters. If theauth
is null, it uses the options to connect. If theauth
is not null, it uses the options and theauth
to connect. If the socket is already connected, it does nothing. -
disconnect(
) → dynamic -
emit(
String event, [dynamic data]) → Future< SocketResponse> -
emit emits an event to the server with the given
event
anddata
. It returns a Future of SocketResponse. It uses the interceptors to intercept the request and response. It uses the checkResponse to check if the response is valid. If the response is valid, it returns the response. If the response is not valid, it throws a SocketException. If an error occurs, it throws the error. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
on(
String event, dynamic callback(dynamic)) → dynamic -
on listens to the
event
and calls thecallback
when the event occurs. It takes a String event and a Function callback as arguments. The Function callback takes a dynamic data as an argument. It uses the interceptors to intercept the event data. -
onAll(
EventCallback callbacks) → dynamic -
onAll listens to all the events in the
callbacks
. It takes a EventCallback as an argument. The EventCallback is a map of event names and their respective callback functions. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited