BurtSocket class abstract
A UdpSocket that follows the BURT protocols.
Instead of raw bytes, we send Protobuf messages. This class transforms stream into messages, a stream of WrappedMessages. Instead of using send, you may want to use sendMessage or sendWrapper to send Messages or WrappedMessages, respectively.
This class also filters incoming messages to handle special types of messages:
- Override onHeartbeat to handle Heartbeat messages
- Override onSettings to handle NetworkSettings messages
To ensure connectedness, even over UDP, we send Heartbeat messages periodically. Override checkHeartbeats and heartbeatInterval to send or wait for heartbeats, and set isConnected accordingly. When the value changes, call onConnect or onDisconnect as needed.
This class is meant to be used by all BURT devices, both on-rover and at the base station. For example, the rover might override checkHeartbeats to ensure a heartbeat has been sent, while the Dashboard might use it to send a heartbeat and await a response.
- Inheritance
- Implementers
Constructors
- BurtSocket({required int? port, required Device device, SocketInfo? destination, bool quiet = false, Service? collection})
- Creates a UdpSocket that follows BURT protocols.
Properties
- collection ↔ Service?
-
The main service, or collection of services, of the program, if any.
getter/setter pair
- destination ↔ SocketInfo?
-
The destination port to send to.
getter/setter pairinherited
- device → Device
-
The device this socket will be used on.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- heartbeatInterval → Duration
-
How often to check for new heartbeats.
no setter
- isConnected → bool
-
Whether the device on the other end is connected.
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 setteroverride
- 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(
) → void - Sends or waits for heartbeats to or from the other device.
-
dispose(
) → Future< void> -
Closes the connection to the device.
override
-
init(
) → Future< bool> -
Initializes the connection to the device.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onConnect(
SocketInfo source) → void -
Sets destination to the incoming
source
. -
onDisconnect(
) → Future< void> -
Sends a Disconnect message to the dashboard and sets destination to
null
.override -
onHeartbeat(
Heartbeat heartbeat, SocketInfo source) → void - Handle an incoming heartbeat coming from a given source.
-
onSettings(
NetworkSettings settings) → 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.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited