WebSocket protocol support can now be configured and is only used in the dedicated server.
This commit is contained in:
@@ -64,7 +64,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
||||
myConfigState = OK;
|
||||
|
||||
// !!!! Revisionsnummer der Configdefaults !!!!!
|
||||
configRev = 100;
|
||||
configRev = 101;
|
||||
|
||||
//standard defaults
|
||||
logOnOffDefault = "1";
|
||||
@@ -220,7 +220,9 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
||||
configList.push_back(ConfigInfo("ServerPassword", CONFIG_TYPE_STRING, ""));
|
||||
configList.push_back(ConfigInfo("ServerUseIpv6", CONFIG_TYPE_INT, "0"));
|
||||
configList.push_back(ConfigInfo("ServerUseSctp", CONFIG_TYPE_INT, "0"));
|
||||
configList.push_back(ConfigInfo("ServerUseWebSocket", CONFIG_TYPE_INT, "0"));
|
||||
configList.push_back(ConfigInfo("ServerPort", CONFIG_TYPE_INT, "7234"));
|
||||
configList.push_back(ConfigInfo("ServerWebSocketPort", CONFIG_TYPE_INT, "7233"));
|
||||
configList.push_back(ConfigInfo("ServerUsePutAvatars", CONFIG_TYPE_INT, "0"));
|
||||
configList.push_back(ConfigInfo("ServerPutAvatarsAddress", CONFIG_TYPE_STRING, ""));
|
||||
configList.push_back(ConfigInfo("ServerPutAvatarsUser", CONFIG_TYPE_STRING, ""));
|
||||
|
||||
+4
-1
@@ -64,7 +64,10 @@ enum ServerMode {
|
||||
enum ServerTransportProtocol {
|
||||
TRANSPORT_PROTOCOL_TCP = 1,
|
||||
TRANSPORT_PROTOCOL_SCTP = 2,
|
||||
TRANSPORT_PROTOCOL_TCP_SCTP = 3
|
||||
TRANSPORT_PROTOCOL_TCP_SCTP = 3,
|
||||
TRANSPORT_PROTOCOL_WEBSOCKET = 4,
|
||||
TRANSPORT_PROTOCOL_TCP_WEBSOCKET = 5,
|
||||
TRANSPORT_PROTOCOL_TCP_SCTP_WEBSOCKET = 7
|
||||
};
|
||||
|
||||
enum GameState {
|
||||
|
||||
@@ -78,7 +78,7 @@ ServerManager::~ServerManager()
|
||||
}
|
||||
|
||||
void
|
||||
ServerManager::Init(unsigned serverPort, bool ipv6, ServerTransportProtocol proto, const string &logDir)
|
||||
ServerManager::Init(unsigned serverPort, unsigned websocketPort, bool ipv6, int proto, const string &logDir)
|
||||
{
|
||||
GetLobbyThread().Init(logDir);
|
||||
|
||||
@@ -93,9 +93,10 @@ ServerManager::Init(unsigned serverPort, bool ipv6, ServerTransportProtocol prot
|
||||
sctpAcceptHelper->Listen(serverPort, ipv6, logDir, m_lobbyThread);
|
||||
m_acceptHelperPool.push_back(sctpAcceptHelper);
|
||||
}*/
|
||||
if (proto & TRANSPORT_PROTOCOL_WEBSOCKET)
|
||||
{
|
||||
boost::shared_ptr<ServerAcceptInterface> webAcceptHelper(new ServerAcceptWebHelper(GetGui(), m_ioService));
|
||||
webAcceptHelper->Listen(7233, true, logDir, m_lobbyThread);
|
||||
webAcceptHelper->Listen(websocketPort, ipv6, logDir, m_lobbyThread);
|
||||
m_acceptHelperPool.push_back(webAcceptHelper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ ServerManagerIrc::~ServerManagerIrc()
|
||||
}
|
||||
|
||||
void
|
||||
ServerManagerIrc::Init(unsigned serverPort, bool ipv6, ServerTransportProtocol proto, const string &logDir)
|
||||
ServerManagerIrc::Init(unsigned serverPort, unsigned websocketPort, bool ipv6, int proto, const string &logDir)
|
||||
{
|
||||
boost::shared_ptr<IrcThread> tmpIrcAdminThread;
|
||||
boost::shared_ptr<IrcThread> tmpIrcLobbyThread;
|
||||
@@ -83,7 +83,7 @@ ServerManagerIrc::Init(unsigned serverPort, bool ipv6, ServerTransportProtocol p
|
||||
|
||||
m_adminBot->Init(m_lobbyThread, tmpIrcAdminThread, myConfig.readConfigString("CacheDir"));
|
||||
m_lobbyBot->Init(m_lobbyThread, tmpIrcLobbyThread);
|
||||
ServerManager::Init(serverPort, ipv6, proto, logDir);
|
||||
ServerManager::Init(serverPort, websocketPort, ipv6, proto, logDir);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
virtual ~ServerManager();
|
||||
|
||||
// Set the parameters.
|
||||
virtual void Init(unsigned serverPort, bool ipv6, ServerTransportProtocol proto, const std::string &logDir);
|
||||
virtual void Init(unsigned serverPort, unsigned websocketPort, bool ipv6, int proto, const std::string &logDir);
|
||||
|
||||
// Main start function.
|
||||
virtual void RunAll();
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
virtual ~ServerManagerIrc();
|
||||
|
||||
// Set the parameters.
|
||||
virtual void Init(unsigned serverPort, bool ipv6, ServerTransportProtocol proto, const std::string &logDir);
|
||||
virtual void Init(unsigned serverPort, unsigned websocketPort, bool ipv6, int proto, const std::string &logDir);
|
||||
|
||||
// Main start function.
|
||||
virtual void RunAll();
|
||||
|
||||
+9
-1
@@ -330,10 +330,18 @@ void Session::startNetworkServer(bool dedicated)
|
||||
|
||||
myNetServer = ServerManagerFactory::CreateServerManager(*myConfig, *myGui, mode, *myAvatarManager);
|
||||
|
||||
int protocol = TRANSPORT_PROTOCOL_TCP;
|
||||
if (dedicated && myConfig->readConfigInt("ServerUseWebSocket") == 1) {
|
||||
protocol |= TRANSPORT_PROTOCOL_WEBSOCKET;
|
||||
}
|
||||
if (myConfig->readConfigInt("ServerUseSctp") == 1) {
|
||||
protocol |= TRANSPORT_PROTOCOL_SCTP;
|
||||
}
|
||||
myNetServer->Init(
|
||||
myConfig->readConfigInt("ServerPort"),
|
||||
myConfig->readConfigInt("ServerWebSocketPort"),
|
||||
myConfig->readConfigInt("ServerUseIpv6") == 1,
|
||||
myConfig->readConfigInt("ServerUseSctp") == 1 ? TRANSPORT_PROTOCOL_TCP_SCTP : TRANSPORT_PROTOCOL_TCP,
|
||||
protocol,
|
||||
myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("LogDir"))
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user