...
This commit is contained in:
@@ -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!);
|
||||
|
||||
Reference in New Issue
Block a user