Peer class

Inheritance

Constructors

Peer(InternetAddress address, int port)
Peer.byIp(String ip, int port)
connect to a node by its ip address and port
factory
Peer.fromSocket(Socket socket)
Peer.local(int port)
connect to a local node using the port only

Properties

address InternetAddress
peer's address
final
hashCode int
The hash code for this object.
no setteroverride
ip String
peer's ip address
no setter
isConnected bool
check if peer is connected
no setter
port int
peer's port
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
socket Socket
the peer's socket, check isConnected to see if peer is connected
no setter
stream Stream<PeerEvent>
events stream
no setterinherited

Methods

clearHandlers() Future<void>
clear all handlers of any event type and clear theme from memory
inherited
completeCompleters() → void
complete all onNextEmit completers and clear them from memory
inherited
connect() Future<void>
start connection to the peer and handle events
destroy() Future<void>
destroy the current peer connection
override
disconnect() → void
flush data, disconnect peer and close socket then clear memory
emit<E extends T>(E event) → void
emit event
inherited
filteredStream<E extends T>() Stream<E>
filter events stream for specific sub event type E
inherited
handle<E extends T>(EventHandler<E> handler) → HandlerCanceler
handle events of type E with handler
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
on({void connect()?, void disconnect()?, void data(Uint8List data)?, void message(Message message)?, void sendData(Uint8List data)?, void sendMessage(Message message)?, void error(String message, Object error, StackTrace stackTrace)?}) → void
handle all events emitted by the peer
onMessage<T extends Message>(void handler(T message)) → void
handle messages with specific type T
onNextEmit<E extends T>() Future<void>
return Future that completes on the next event emitted of type E
inherited
send(Uint8List data) bool
send data to the peer and returns true if succeeded
sendBytes(List<int> bytes) bool
send bytes to the peer and returns true if succeeded
sendMessage(Message message) bool
send message to the peer and returns true if succeeded
sendText(String text) bool
send text to the peer and returns true if succeeded
toString() String
returns peer's info with ~ at the end if peer is connected as a String
override

Operators

operator ==(Object other) bool
The equality operator.
override