Skip to content

Commit

Permalink
refactor: refactor initialization of CoapUDPChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Mar 28, 2022
1 parent 85808e7 commit 9b656e9
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/src/channel/coap_udp_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ part of coap;
/// Channel via UDP protocol.
class CoapUDPChannel extends CoapIChannel {
/// Initialise with a specific address and port
CoapUDPChannel(this._address, this._port,
{required String namespace, required this.config}) {
_eventBus = CoapEventBus(namespace: namespace);
final socket = CoapNetworkManagement.getNetwork(
address!, _port, CoapConstants.uriScheme,
namespace: namespace, config: config);
_socket = socket;
}
CoapUDPChannel(CoapInternetAddress? address, this._port,
{required String namespace, required this.config})
: _address = address,
_eventBus = CoapEventBus(namespace: namespace),
_socket = CoapNetworkManagement.getNetwork(
address!, _port, CoapConstants.uriScheme,
namespace: namespace, config: config);

final int _port;

Expand All @@ -29,11 +28,11 @@ class CoapUDPChannel extends CoapIChannel {

@override
CoapInternetAddress? get address => _address;
late CoapINetwork _socket;
final CoapINetwork _socket;

final typed.Uint8Buffer _buff = typed.Uint8Buffer();

late final CoapEventBus _eventBus;
final CoapEventBus _eventBus;

@override
Future<void> start() async {
Expand Down

0 comments on commit 9b656e9

Please sign in to comment.