This commit is contained in:
2025-11-21 18:04:15 +09:00
parent dbf70e01f2
commit e992a5ca5e
4 changed files with 261 additions and 109 deletions
@@ -75,6 +75,15 @@ class NetworkManager extends ChangeNotifier {
int port = _serverSocket!.port;
print('[Host] Server opened on port: $port');
final interfaces = await NetworkInterface.list(type: InternetAddressType.IPv4);
String myIp = '127.0.0.1';
try {
// 보통 wlan0 혹은 en0가 와이파이 인터페이스
myIp = interfaces.firstWhere((i) => i.name != 'lo').addresses.first.address;
} catch (e) {
print('IP search failed: $e');
}
// B. 게스트 접속 대기
_serverSocket!.listen((Socket client) {
_handleNewGuest(client);
@@ -87,6 +96,7 @@ class NetworkManager extends ChangeNotifier {
name: '$roomName#${me.id}',
type: '_playwith._tcp',
port: port,
attributes: {'ip': myIp},
);
_bonsoirBroadcast = BonsoirBroadcast(service: _bonsoirService!);