Extract handshake logic into `Worker.handshake()`.

Ensure `handshake()` resets unknown device IDs if channel IDs are
specified.