Connecting to the ip and port received in the last broadcast message.
This commit is contained in:
parent
5fe89f1d8f
commit
bf07ef5f5f
|
@ -37,6 +37,9 @@ struct LanMenuState::MyData
|
||||||
|
|
||||||
TextField<LanMenuState*> *connectIP;
|
TextField<LanMenuState*> *connectIP;
|
||||||
unsigned short connectPort;
|
unsigned short connectPort;
|
||||||
|
|
||||||
|
std::string ip;
|
||||||
|
|
||||||
} privData;
|
} privData;
|
||||||
|
|
||||||
void OnButtonInteract_Connect( Oyster::Event::ButtonEvent<LanMenuState*>& e );
|
void OnButtonInteract_Connect( Oyster::Event::ButtonEvent<LanMenuState*>& e );
|
||||||
|
@ -139,7 +142,7 @@ void LanMenuState::ChangeState( ClientState next )
|
||||||
{
|
{
|
||||||
case GameClientState::ClientState_Lobby:
|
case GameClientState::ClientState_Lobby:
|
||||||
// attempt to connect to lobby
|
// attempt to connect to lobby
|
||||||
if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) )
|
if( !this->privData->nwClient->Connect(this->privData->connectPort, this->privData->ip.c_str()) )
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
|
@ -194,6 +197,9 @@ const GameClientState::NetEvent& LanMenuState::DataRecieved( const NetEvent &mes
|
||||||
std::string ip = decoded.ip;
|
std::string ip = decoded.ip;
|
||||||
std::string name = decoded.name;
|
std::string name = decoded.name;
|
||||||
printf("Broadcast message: %d: %s: %s\n", port, ip.c_str(), name.c_str());
|
printf("Broadcast message: %d: %s: %s\n", port, ip.c_str(), name.c_str());
|
||||||
|
|
||||||
|
this->privData->connectPort = port;
|
||||||
|
this->privData->ip = ip;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue