28 lines
810 B
Dart
28 lines
810 B
Dart
/// 같은 네트워크에서 발견한 상대.
|
|
class LanPeer {
|
|
const LanPeer({required this.phone, required this.host, required this.port});
|
|
|
|
final String phone; // 표준 형태 전화번호
|
|
final String host;
|
|
final int port;
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
other is LanPeer && other.phone == phone && other.host == host && other.port == port;
|
|
|
|
@override
|
|
int get hashCode => Object.hash(phone, host, port);
|
|
}
|
|
|
|
/// 같은 네트워크에서 서로 찾기. 구현은 플랫폼 쪽에서 붙인다.
|
|
abstract class LanDiscovery {
|
|
/// 내가 여기 있다고 알린다.
|
|
Future<void> advertise({required String phone, required int port});
|
|
|
|
/// 같은 네트워크에서 발견되는 상대들.
|
|
Stream<LanPeer> get peers;
|
|
|
|
Future<void> start();
|
|
Future<void> stop();
|
|
}
|