accept method

void accept(
  1. OmnyShellConnection connection
)

Accepts a newly-connected peer, issues the challenge hello, and begins handling its frames.

Implementation

void accept(OmnyShellConnection connection) {
  final peer = HubPeer(connection: connection, nonce: newSecureToken());
  _peers[peer.id] = peer;
  connection.send(
    ControlFrame(
      Hello(
        role: 'hub',
        protocolVersion: kProtocolVersion,
        minVersion: kMinProtocolVersion,
        nonce: peer.nonce,
        info: hubUid == null ? const {} : {'hubUid': hubUid!},
      ),
    ),
  );
  connection.incoming.listen(
    (frame) => _onFrame(peer, frame),
    onDone: () => _onPeerGone(peer),
    onError: (Object _) => _onPeerGone(peer),
    cancelOnError: false,
  );
}