DashboardSocket class
A service to send and receive Protobuf messages over a UDP socket, using BurtSocket
.
This class monitors its connection to the given device
by sending heartbeats periodically and
logging the response (or lack thereof). To be notified of connection events, add a listener to connectionStatus.
To be notified of incoming messages, listen to the messages
stream that streams incoming WrappedMessage.
To use this class:
- Call
init
to open the socket. - Check connectionStrength or isConnected for the connection to the given
device
. - To send a message, call
sendMessage
. - Call
dispose
to close the socket.
- Inheritance
-
- Object
- Service
- DashboardSocket
Constructors
- DashboardSocket({required Device device})
-
Listens for incoming messages on a UDP socket and sends heartbeats to the
device
.
Properties
- collection ↔ Service?
-
The main service, or collection of services, of the program, if any.
getter/setter pairinherited
- connectionIncrement → double
-
How much each successful/missed handshake is worth, as a percent.
no setter
-
connectionStatus
→ ValueNotifier<
bool> -
Notifier for when the socket connects or disconnects
final
-
connectionStrength
→ ValueNotifier<
double> -
The connection strength, as a percentage to this
device
.final - destination ↔ SocketInfo?
-
The destination port to send to.
getter/setter pairinherited
- device → Device
-
The device this socket will be used on.
finalinherited
- frequency → double
-
Number of times to check heart beat per seconds based on
settings.network.connectionTimeout
.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- heartbeatInterval → Duration
-
How often to check for new heartbeats.
no setter
- heartbeatWaitDelay → Duration
-
How long to wait for incoming heartbeats after sending them out.
no setter
- isConnected → bool
-
Whether this socket has a stable connection to the
device
.no setter - logger → BurtLogger
-
A logger to capture important events during operation.
finalinherited
-
messages
→ Stream<
WrappedMessage> -
A stream of WrappedMessages as they arrive in the UDP socket.
no setterinherited
- port → int?
-
The port this socket is listening on. See
RawDatagramSocket.bind
.no setterinherited - quiet → bool
-
Whether to silence "normal" output, like opening/closing and resetting sockets.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
Datagram> -
A stream containing all the data coming out of the socket.
no setterinherited
Methods
-
checkHeartbeats(
) → Future< void> - Sends or waits for heartbeats to or from the other device.
-
dispose(
) → Future< void> -
Closes the connection to the device.
inherited
-
init(
) → Future< bool> -
Initializes the connection to the device.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onConnect(
SocketInfo source) → void -
Sets
destination
to the incomingsource
.inherited -
onDisconnect(
) → Future< void> -
Sends a Disconnect message to the dashboard and sets
destination
tonull
.inherited -
onHeartbeat(
Connect heartbeat, SocketInfo source) → void - Handle an incoming heartbeat coming from a given source.
-
onSettings(
NetworkSettings settings) → Future< void> - Handle an incoming request to change network settings.
-
send(
List< int> data, {SocketInfo? destination}) → void -
Sends data to the given destination.
inherited
-
sendMessage(
Message message, {SocketInfo? destination}) → void -
Sends a Message over the socket (in a WrappedMessage).
inherited
-
sendWrapper(
WrappedMessage wrapper, {SocketInfo? destination}) → void -
Sends a WrappedMessage over the socket.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
waitForConnection(
) → Future< void> -
Waits for a connection to be established.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited