New packet types implemented for timeout system - unused yet.
This commit is contained in:
@@ -819,13 +819,16 @@ Server Notification: Timeout Warning
|
|||||||
0 1 2 3
|
0 1 2 3
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Message Type = 257 | Message Length = 8 |
|
| Message Type = 257 | Message Length = 12 |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Timeout Reason | Seconds Remaining |
|
| Timeout Reason | Remaining Seconds |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| Reserved |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
Timeout Reason:
|
Timeout Reason:
|
||||||
0x0000 - No data received
|
0x0000 - No data received
|
||||||
0x0001 - Inactive Game
|
0x0001 - Inactive Game
|
||||||
|
0xFFFF - Other reason
|
||||||
|
|
||||||
|
|
||||||
Client Reply: Reset Timeout
|
Client Reply: Reset Timeout
|
||||||
|
|||||||
+2
-2
@@ -74,8 +74,8 @@ enum Button {
|
|||||||
BUTTON_BIG_BLIND };
|
BUTTON_BIG_BLIND };
|
||||||
|
|
||||||
enum NetTimeoutReason {
|
enum NetTimeoutReason {
|
||||||
GENERIC = 0,
|
NETWORK_TIMEOUT_GENERIC = 0,
|
||||||
OPENGAMEADMINIDLE
|
NETWORK_TIMEOUT_GAME_ADMIN_IDLE
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ServerStats
|
struct ServerStats
|
||||||
|
|||||||
@@ -13,13 +13,13 @@
|
|||||||
#include "session.h"
|
#include "session.h"
|
||||||
|
|
||||||
timeoutMsgBoxImpl::timeoutMsgBoxImpl(QMainWindow *parent)
|
timeoutMsgBoxImpl::timeoutMsgBoxImpl(QMainWindow *parent)
|
||||||
: QMessageBox(parent)
|
: QMessageBox(parent), msgID(NETWORK_TIMEOUT_GENERIC)
|
||||||
{
|
{
|
||||||
okButton = this->addButton(QMessageBox::Ok);
|
okButton = this->addButton(QMessageBox::Ok);
|
||||||
|
|
||||||
this->setWindowTitle(tr("Timeout Warning"));
|
this->setWindowTitle(tr("Timeout Warning"));
|
||||||
this->setIcon(QMessageBox::Warning);
|
this->setIcon(QMessageBox::Warning);
|
||||||
this->setInformativeText(tr("Please click \"OK\" to stop timeout!"));
|
this->setInformativeText(tr("Please click \"OK\" to stop the countdown!"));
|
||||||
|
|
||||||
timeOutTimer = new QTimer;
|
timeOutTimer = new QTimer;
|
||||||
|
|
||||||
@@ -47,9 +47,11 @@ void timeoutMsgBoxImpl::timerRefresh() {
|
|||||||
sec -= realTimerValue/1000;
|
sec -= realTimerValue/1000;
|
||||||
if (sec < 0) sec = 0;
|
if (sec < 0) sec = 0;
|
||||||
switch (msgID) {
|
switch (msgID) {
|
||||||
case GENERIC: { this->setText(tr("Your connection is about to time out due to inactivity in %1 seconds.").arg(sec,0,10)); }
|
case NETWORK_TIMEOUT_GAME_ADMIN_IDLE:
|
||||||
|
this->setText(tr("Your open game reaches timeout in %1 seconds.").arg(sec,0,10));
|
||||||
break;
|
break;
|
||||||
case OPENGAMEADMINIDLE: { this->setText(tr("Your open game reaches timeout in %1 seconds.").arg(sec,0,10)); }
|
default:
|
||||||
|
this->setText(tr("Your connection is about to time out due to inactivity in %1 seconds.").arg(sec,0,10));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public slots:
|
|||||||
void stopTimeout();
|
void stopTimeout();
|
||||||
|
|
||||||
void setMySession ( boost::shared_ptr<Session> theValue ) { mySession = theValue; }
|
void setMySession ( boost::shared_ptr<Session> theValue ) { mySession = theValue; }
|
||||||
void setMsgID ( int theValue ) { msgID = theValue; }
|
void setMsgID ( NetTimeoutReason theValue ) { msgID = theValue; }
|
||||||
void setTimeoutDuration ( int theValue ) { timeoutDuration = theValue; }
|
void setTimeoutDuration ( int theValue ) { timeoutDuration = theValue; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -46,7 +46,7 @@ private:
|
|||||||
QTimer *timeOutTimer;
|
QTimer *timeOutTimer;
|
||||||
QPushButton *okButton;
|
QPushButton *okButton;
|
||||||
boost::shared_ptr<Session> mySession;
|
boost::shared_ptr<Session> mySession;
|
||||||
int msgID;
|
NetTimeoutReason msgID;
|
||||||
int timeoutDuration;
|
int timeoutDuration;
|
||||||
boost::timers::portable::microsec_timer realTimer;
|
boost::timers::portable::microsec_timer realTimer;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ using namespace std;
|
|||||||
#define NET_TYPE_STATISTICS_CHANGED 0x0080
|
#define NET_TYPE_STATISTICS_CHANGED 0x0080
|
||||||
|
|
||||||
#define NET_TYPE_REMOVED_FROM_GAME 0x0100
|
#define NET_TYPE_REMOVED_FROM_GAME 0x0100
|
||||||
|
#define NET_TYPE_TIMEOUT_WARNING 0x0101
|
||||||
|
#define NET_TYPE_RESET_TIMEOUT 0x0102
|
||||||
|
|
||||||
#define NET_TYPE_SEND_CHAT_TEXT 0x0200
|
#define NET_TYPE_SEND_CHAT_TEXT 0x0200
|
||||||
#define NET_TYPE_CHAT_TEXT 0x0201
|
#define NET_TYPE_CHAT_TEXT 0x0201
|
||||||
@@ -97,6 +99,11 @@ using namespace std;
|
|||||||
#define NET_REMOVED_KICKED 0x0003
|
#define NET_REMOVED_KICKED 0x0003
|
||||||
#define NET_REMOVED_OTHER_REASON 0xFFFF
|
#define NET_REMOVED_OTHER_REASON 0xFFFF
|
||||||
|
|
||||||
|
// Reasons for timeout warning
|
||||||
|
#define NET_TIMEOUT_NO_DATA_RECEIVED 0x0000
|
||||||
|
#define NET_TIMEOUT_INACTIVE_GAME 0x0001
|
||||||
|
#define NET_TIMEOUT_OTHER_REASON 0xFFFF
|
||||||
|
|
||||||
// Internal error codes.
|
// Internal error codes.
|
||||||
#define NET_ERR_RESERVED 0x0000
|
#define NET_ERR_RESERVED 0x0000
|
||||||
#define NET_ERR_INIT_VERSION_NOT_SUPPORTED 0x0001
|
#define NET_ERR_INIT_VERSION_NOT_SUPPORTED 0x0001
|
||||||
@@ -497,6 +504,20 @@ struct GCC_PACKED NetPacketRemovedFromGameData
|
|||||||
u_int16_t reserved;
|
u_int16_t reserved;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct GCC_PACKED NetPacketTimeoutWarningData
|
||||||
|
{
|
||||||
|
NetPacketHeader head;
|
||||||
|
u_int16_t timeoutReason;
|
||||||
|
u_int16_t remainingSeconds;
|
||||||
|
u_int32_t reserved;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GCC_PACKED NetPacketResetTimeoutData
|
||||||
|
{
|
||||||
|
NetPacketHeader head;
|
||||||
|
u_int32_t reserved;
|
||||||
|
};
|
||||||
|
|
||||||
struct GCC_PACKED NetPacketSendChatTextData
|
struct GCC_PACKED NetPacketSendChatTextData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
@@ -762,6 +783,12 @@ NetPacket::Create(char *data, unsigned &dataSize)
|
|||||||
case NET_TYPE_REMOVED_FROM_GAME:
|
case NET_TYPE_REMOVED_FROM_GAME:
|
||||||
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketRemovedFromGame);
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketRemovedFromGame);
|
||||||
break;
|
break;
|
||||||
|
case NET_TYPE_TIMEOUT_WARNING:
|
||||||
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketTimeoutWarning);
|
||||||
|
break;
|
||||||
|
case NET_TYPE_RESET_TIMEOUT:
|
||||||
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketResetTimeout);
|
||||||
|
break;
|
||||||
case NET_TYPE_SEND_CHAT_TEXT:
|
case NET_TYPE_SEND_CHAT_TEXT:
|
||||||
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketSendChatText);
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketSendChatText);
|
||||||
break;
|
break;
|
||||||
@@ -1101,6 +1128,18 @@ NetPacket::ToNetPacketRemovedFromGame() const
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NetPacketTimeoutWarning *
|
||||||
|
NetPacket::ToNetPacketTimeoutWarning() const
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NetPacketResetTimeout *
|
||||||
|
NetPacket::ToNetPacketResetTimeout() const
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
const NetPacketSendChatText *
|
const NetPacketSendChatText *
|
||||||
NetPacket::ToNetPacketSendChatText() const
|
NetPacket::ToNetPacketSendChatText() const
|
||||||
{
|
{
|
||||||
@@ -4275,6 +4314,119 @@ NetPacketRemovedFromGame::InternalCheck(const NetPacketHeader*) const
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NetPacketTimeoutWarning::NetPacketTimeoutWarning()
|
||||||
|
: NetPacket(NET_TYPE_TIMEOUT_WARNING, sizeof(NetPacketTimeoutWarningData), sizeof(NetPacketTimeoutWarningData))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NetPacketTimeoutWarning::~NetPacketTimeoutWarning()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<NetPacket>
|
||||||
|
NetPacketTimeoutWarning::Clone() const
|
||||||
|
{
|
||||||
|
boost::shared_ptr<NetPacket> newPacket(new NetPacketTimeoutWarning);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket->SetRawData(GetRawData());
|
||||||
|
} catch (const NetException &)
|
||||||
|
{
|
||||||
|
// Need to return the new packet anyway.
|
||||||
|
}
|
||||||
|
return newPacket;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetPacketTimeoutWarning::SetData(const NetPacketTimeoutWarning::Data &inData)
|
||||||
|
{
|
||||||
|
NetPacketTimeoutWarningData *tmpData = (NetPacketTimeoutWarningData *)GetRawData();
|
||||||
|
|
||||||
|
switch (inData.timeoutReason)
|
||||||
|
{
|
||||||
|
case NETWORK_TIMEOUT_GENERIC:
|
||||||
|
tmpData->timeoutReason = htons(NET_TIMEOUT_NO_DATA_RECEIVED);
|
||||||
|
break;
|
||||||
|
case NETWORK_TIMEOUT_GAME_ADMIN_IDLE:
|
||||||
|
tmpData->timeoutReason = htons(NET_TIMEOUT_INACTIVE_GAME);
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
tmpData->timeoutReason = htons(NET_TIMEOUT_OTHER_REASON);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the packet - just in case.
|
||||||
|
Check(GetRawData());
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetPacketTimeoutWarning::GetData(NetPacketTimeoutWarning::Data &outData) const
|
||||||
|
{
|
||||||
|
NetPacketTimeoutWarningData *tmpData = (NetPacketTimeoutWarningData *)GetRawData();
|
||||||
|
|
||||||
|
switch (ntohs(tmpData->timeoutReason))
|
||||||
|
{
|
||||||
|
// Removed Errors.
|
||||||
|
case NET_TIMEOUT_INACTIVE_GAME :
|
||||||
|
outData.timeoutReason = NETWORK_TIMEOUT_GAME_ADMIN_IDLE;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
outData.timeoutReason = NETWORK_TIMEOUT_GENERIC;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const NetPacketTimeoutWarning *
|
||||||
|
NetPacketTimeoutWarning::ToNetPacketTimeoutWarning() const
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetPacketTimeoutWarning::InternalCheck(const NetPacketHeader*) const
|
||||||
|
{
|
||||||
|
// Nothing to do.
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NetPacketResetTimeout::NetPacketResetTimeout()
|
||||||
|
: NetPacket(NET_TYPE_RESET_TIMEOUT, sizeof(NetPacketResetTimeoutData), sizeof(NetPacketResetTimeoutData))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NetPacketResetTimeout::~NetPacketResetTimeout()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<NetPacket>
|
||||||
|
NetPacketResetTimeout::Clone() const
|
||||||
|
{
|
||||||
|
boost::shared_ptr<NetPacket> newPacket(new NetPacketResetTimeout);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket->SetRawData(GetRawData());
|
||||||
|
} catch (const NetException &)
|
||||||
|
{
|
||||||
|
// Need to return the new packet anyway.
|
||||||
|
}
|
||||||
|
return newPacket;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NetPacketResetTimeout *
|
||||||
|
NetPacketResetTimeout::ToNetPacketResetTimeout() const
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetPacketResetTimeout::InternalCheck(const NetPacketHeader*) const
|
||||||
|
{
|
||||||
|
// Nothing to do.
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
NetPacketSendChatText::NetPacketSendChatText()
|
NetPacketSendChatText::NetPacketSendChatText()
|
||||||
: NetPacket(NET_TYPE_SEND_CHAT_TEXT, sizeof(NetPacketSendChatTextData), MAX_PACKET_SIZE)
|
: NetPacket(NET_TYPE_SEND_CHAT_TEXT, sizeof(NetPacketSendChatTextData), MAX_PACKET_SIZE)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ class NetPacketEndOfHandHideCards;
|
|||||||
class NetPacketEndOfGame;
|
class NetPacketEndOfGame;
|
||||||
class NetPacketStatisticsChanged;
|
class NetPacketStatisticsChanged;
|
||||||
class NetPacketRemovedFromGame;
|
class NetPacketRemovedFromGame;
|
||||||
|
class NetPacketTimeoutWarning;
|
||||||
|
class NetPacketResetTimeout;
|
||||||
class NetPacketSendChatText;
|
class NetPacketSendChatText;
|
||||||
class NetPacketChatText;
|
class NetPacketChatText;
|
||||||
class NetPacketError;
|
class NetPacketError;
|
||||||
@@ -149,6 +151,8 @@ public:
|
|||||||
virtual const NetPacketEndOfGame *ToNetPacketEndOfGame() const;
|
virtual const NetPacketEndOfGame *ToNetPacketEndOfGame() const;
|
||||||
virtual const NetPacketStatisticsChanged *ToNetPacketStatisticsChanged() const;
|
virtual const NetPacketStatisticsChanged *ToNetPacketStatisticsChanged() const;
|
||||||
virtual const NetPacketRemovedFromGame *ToNetPacketRemovedFromGame() const;
|
virtual const NetPacketRemovedFromGame *ToNetPacketRemovedFromGame() const;
|
||||||
|
virtual const NetPacketTimeoutWarning *ToNetPacketTimeoutWarning() const;
|
||||||
|
virtual const NetPacketResetTimeout *ToNetPacketResetTimeout() const;
|
||||||
virtual const NetPacketSendChatText *ToNetPacketSendChatText() const;
|
virtual const NetPacketSendChatText *ToNetPacketSendChatText() const;
|
||||||
virtual const NetPacketChatText *ToNetPacketChatText() const;
|
virtual const NetPacketChatText *ToNetPacketChatText() const;
|
||||||
virtual const NetPacketError *ToNetPacketError() const;
|
virtual const NetPacketError *ToNetPacketError() const;
|
||||||
@@ -1169,6 +1173,46 @@ protected:
|
|||||||
virtual void InternalCheck(const NetPacketHeader* data) const;
|
virtual void InternalCheck(const NetPacketHeader* data) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class NetPacketTimeoutWarning : public NetPacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct Data
|
||||||
|
{
|
||||||
|
NetTimeoutReason timeoutReason;
|
||||||
|
u_int16_t remainingSeconds;
|
||||||
|
};
|
||||||
|
|
||||||
|
NetPacketTimeoutWarning();
|
||||||
|
virtual ~NetPacketTimeoutWarning();
|
||||||
|
|
||||||
|
virtual boost::shared_ptr<NetPacket> Clone() const;
|
||||||
|
|
||||||
|
void SetData(const Data &inData);
|
||||||
|
void GetData(Data &outData) const;
|
||||||
|
|
||||||
|
virtual const NetPacketTimeoutWarning *ToNetPacketTimeoutWarning() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void InternalCheck(const NetPacketHeader* data) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class NetPacketResetTimeout : public NetPacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
NetPacketResetTimeout();
|
||||||
|
virtual ~NetPacketResetTimeout();
|
||||||
|
|
||||||
|
virtual boost::shared_ptr<NetPacket> Clone() const;
|
||||||
|
|
||||||
|
virtual const NetPacketResetTimeout *ToNetPacketResetTimeout() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void InternalCheck(const NetPacketHeader* data) const;
|
||||||
|
};
|
||||||
|
|
||||||
class NetPacketSendChatText : public NetPacket
|
class NetPacketSendChatText : public NetPacket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user