|
|
@ -73,11 +73,12 @@ public:
|
|
|
|
* Sends a request to the server, asking for permission to join a room with the specified
|
|
|
|
* Sends a request to the server, asking for permission to join a room with the specified
|
|
|
|
* nickname and preferred mac.
|
|
|
|
* nickname and preferred mac.
|
|
|
|
* @params nickname The desired nickname.
|
|
|
|
* @params nickname The desired nickname.
|
|
|
|
|
|
|
|
* @params console_id_hash A hash of the Console ID.
|
|
|
|
* @params preferred_mac The preferred MAC address to use in the room, the NoPreferredMac tells
|
|
|
|
* @params preferred_mac The preferred MAC address to use in the room, the NoPreferredMac tells
|
|
|
|
* @params password The password for the room
|
|
|
|
* @params password The password for the room
|
|
|
|
* the server to assign one for us.
|
|
|
|
* the server to assign one for us.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void SendJoinRequest(const std::string& nickname,
|
|
|
|
void SendJoinRequest(const std::string& nickname, const std::string& console_id_hash,
|
|
|
|
const MacAddress& preferred_mac = NoPreferredMac,
|
|
|
|
const MacAddress& preferred_mac = NoPreferredMac,
|
|
|
|
const std::string& password = "");
|
|
|
|
const std::string& password = "");
|
|
|
|
|
|
|
|
|
|
|
@ -163,6 +164,9 @@ void RoomMember::RoomMemberImpl::MemberLoop() {
|
|
|
|
case IdMacCollision:
|
|
|
|
case IdMacCollision:
|
|
|
|
SetState(State::MacCollision);
|
|
|
|
SetState(State::MacCollision);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IdConsoleIdCollision:
|
|
|
|
|
|
|
|
SetState(State::ConsoleIdCollision);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case IdVersionMismatch:
|
|
|
|
case IdVersionMismatch:
|
|
|
|
SetState(State::WrongVersion);
|
|
|
|
SetState(State::WrongVersion);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -204,11 +208,13 @@ void RoomMember::RoomMemberImpl::Send(Packet&& packet) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RoomMember::RoomMemberImpl::SendJoinRequest(const std::string& nickname,
|
|
|
|
void RoomMember::RoomMemberImpl::SendJoinRequest(const std::string& nickname,
|
|
|
|
|
|
|
|
const std::string& console_id_hash,
|
|
|
|
const MacAddress& preferred_mac,
|
|
|
|
const MacAddress& preferred_mac,
|
|
|
|
const std::string& password) {
|
|
|
|
const std::string& password) {
|
|
|
|
Packet packet;
|
|
|
|
Packet packet;
|
|
|
|
packet << static_cast<u8>(IdJoinRequest);
|
|
|
|
packet << static_cast<u8>(IdJoinRequest);
|
|
|
|
packet << nickname;
|
|
|
|
packet << nickname;
|
|
|
|
|
|
|
|
packet << console_id_hash;
|
|
|
|
packet << preferred_mac;
|
|
|
|
packet << preferred_mac;
|
|
|
|
packet << network_version;
|
|
|
|
packet << network_version;
|
|
|
|
packet << password;
|
|
|
|
packet << password;
|
|
|
@ -392,9 +398,9 @@ RoomInformation RoomMember::GetRoomInformation() const {
|
|
|
|
return room_member_impl->room_information;
|
|
|
|
return room_member_impl->room_information;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RoomMember::Join(const std::string& nick, const char* server_addr, u16 server_port,
|
|
|
|
void RoomMember::Join(const std::string& nick, const std::string& console_id_hash,
|
|
|
|
u16 client_port, const MacAddress& preferred_mac,
|
|
|
|
const char* server_addr, u16 server_port, u16 client_port,
|
|
|
|
const std::string& password) {
|
|
|
|
const MacAddress& preferred_mac, const std::string& password) {
|
|
|
|
// If the member is connected, kill the connection first
|
|
|
|
// If the member is connected, kill the connection first
|
|
|
|
if (room_member_impl->loop_thread && room_member_impl->loop_thread->joinable()) {
|
|
|
|
if (room_member_impl->loop_thread && room_member_impl->loop_thread->joinable()) {
|
|
|
|
Leave();
|
|
|
|
Leave();
|
|
|
@ -427,7 +433,7 @@ void RoomMember::Join(const std::string& nick, const char* server_addr, u16 serv
|
|
|
|
if (net > 0 && event.type == ENET_EVENT_TYPE_CONNECT) {
|
|
|
|
if (net > 0 && event.type == ENET_EVENT_TYPE_CONNECT) {
|
|
|
|
room_member_impl->nickname = nick;
|
|
|
|
room_member_impl->nickname = nick;
|
|
|
|
room_member_impl->StartLoop();
|
|
|
|
room_member_impl->StartLoop();
|
|
|
|
room_member_impl->SendJoinRequest(nick, preferred_mac, password);
|
|
|
|
room_member_impl->SendJoinRequest(nick, console_id_hash, preferred_mac, password);
|
|
|
|
SendGameInfo(room_member_impl->current_game_info);
|
|
|
|
SendGameInfo(room_member_impl->current_game_info);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
enet_peer_disconnect(room_member_impl->server, 0);
|
|
|
|
enet_peer_disconnect(room_member_impl->server, 0);
|
|
|
|