iOS: Screen locking fix (#109)
* Disconnect from game when screen locks * Fix socket behaviour on iOS
This commit is contained in:
parent
68bd3f0c9a
commit
09c5ba652c
@ -22,6 +22,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "inputhandler.h"
|
||||
#include "mainmenumanager.h"
|
||||
|
||||
#ifdef __IOS__
|
||||
extern void external_exit_game();
|
||||
#endif
|
||||
|
||||
bool MyEventReceiver::OnEvent(const SEvent &event)
|
||||
{
|
||||
/*
|
||||
@ -58,6 +62,15 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __IOS__
|
||||
if (event.EventType == irr::EET_APPLICATION_EVENT) {
|
||||
if (event.ApplicationEvent.EventType == irr::EAET_WILL_PAUSE)
|
||||
external_exit_game();
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (event.EventType == irr::EET_JOYSTICK_INPUT_EVENT) {
|
||||
/* TODO add a check like:
|
||||
if (event.JoystickEvent != joystick_we_listen_for)
|
||||
|
@ -4884,6 +4884,13 @@ void external_pause_game()
|
||||
g_game->pauseGame();
|
||||
}
|
||||
|
||||
void external_exit_game()
|
||||
{
|
||||
if (!g_game)
|
||||
return;
|
||||
g_gamecallback->disconnect();
|
||||
}
|
||||
|
||||
void external_statustext(const char *text, float duration)
|
||||
{
|
||||
if (!g_game)
|
||||
|
@ -2166,6 +2166,9 @@ void ConnectionReceiveThread::receive()
|
||||
Address sender;
|
||||
s32 received_size = m_connection->m_udpSocket.Receive(sender, *packetdata, packet_maxsize);
|
||||
|
||||
if (received_size == -1)
|
||||
break;
|
||||
|
||||
if ((received_size < BASE_HEADER_SIZE) ||
|
||||
(readU32(&packetdata[0]) != m_connection->GetProtocolID()))
|
||||
{
|
||||
|
@ -348,6 +348,11 @@ bool UDPSocket::init(bool ipv6, bool noExceptions)
|
||||
|
||||
setTimeoutMs(0);
|
||||
|
||||
#ifdef __IOS__
|
||||
int val = 1;
|
||||
setsockopt(m_handle, SOL_SOCKET, SO_NOSIGPIPE, &val, sizeof(val));
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user