mirror of
https://github.com/SWG-Source/stationapi.git
synced 2026-01-15 22:04:17 -05:00
Merge branch 'master' into master
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
externals/udplibrary
|
||||
build*
|
||||
.vscode/
|
||||
@@ -1,19 +1,19 @@
|
||||
add_library(
|
||||
stationapi
|
||||
Node.hpp
|
||||
NodeClient.cpp
|
||||
NodeClient.hpp
|
||||
Serialization.hpp
|
||||
SQLite3.hpp
|
||||
StreamUtils.cpp
|
||||
StreamUtils.hpp
|
||||
StringUtils.cpp
|
||||
StringUtils.hpp)
|
||||
|
||||
add_library(stationapi
|
||||
Node.hpp
|
||||
NodeClient.cpp
|
||||
NodeClient.hpp
|
||||
Serialization.hpp
|
||||
SQLite3.hpp
|
||||
StreamUtils.cpp
|
||||
StreamUtils.hpp
|
||||
StringUtils.cpp
|
||||
StringUtils.hpp)
|
||||
target_include_directories(
|
||||
stationapi
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/externals/catch
|
||||
${PROJECT_SOURCE_DIR}/externals/easyloggingpp ${Boost_INCLUDE_DIRS}
|
||||
${SQLite3_INCLUDE_DIR})
|
||||
|
||||
target_include_directories(stationapi PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${PROJECT_SOURCE_DIR}/externals/catch
|
||||
${PROJECT_SOURCE_DIR}/externals/easyloggingpp
|
||||
${PROJECT_SOURCE_DIR}/externals/udplibrary
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${SQLite3_INCLUDE_DIR})
|
||||
target_link_libraries(stationapi udplibrary)
|
||||
|
||||
@@ -11,17 +11,21 @@
|
||||
#include <stdexcept>
|
||||
|
||||
template <typename NodeT, typename ClientT>
|
||||
class Node : public UdpManagerHandler {
|
||||
class Node : public UdpManagerHandler
|
||||
{
|
||||
public:
|
||||
explicit Node(NodeT* node, const std::string& listenAddress, uint16_t listenPort, bool bindToIp = false)
|
||||
: node_{node} {
|
||||
explicit Node(NodeT *node, const std::string &listenAddress, uint16_t listenPort, bool bindToIp = false)
|
||||
: node_{node}
|
||||
{
|
||||
|
||||
UdpManager::Params params;
|
||||
params.handler = this;
|
||||
params.port = listenPort;
|
||||
|
||||
if (bindToIp) {
|
||||
if (listenAddress.length() > sizeof(params.bindIpAddress)) {
|
||||
if (bindToIp)
|
||||
{
|
||||
if (listenAddress.length() > sizeof(params.bindIpAddress))
|
||||
{
|
||||
throw std::runtime_error{"Invalid bind ip specified: " + listenAddress};
|
||||
}
|
||||
|
||||
@@ -33,16 +37,15 @@ public:
|
||||
|
||||
virtual ~Node() { udpManager_->Release(); }
|
||||
|
||||
void Tick() {
|
||||
void Tick()
|
||||
{
|
||||
udpManager_->GiveTime();
|
||||
|
||||
auto remove_iter
|
||||
= std::remove_if(std::begin(clients_), std::end(clients_), [](auto& client) {
|
||||
return client->GetConnection()->GetStatus() == UdpConnection::cStatusDisconnected || client == std::end(clients_);
|
||||
});
|
||||
auto remove_iter = std::remove_if(std::begin(clients_), std::end(clients_), [](auto &client)
|
||||
{ return client->GetConnection()->GetStatus() == UdpConnection::cStatusDisconnected; });
|
||||
|
||||
if (remove_iter != std::end(clients_))
|
||||
clients_.erase(remove_iter);
|
||||
clients_.erase(remove_iter, clients_.end());
|
||||
|
||||
OnTick();
|
||||
}
|
||||
@@ -50,13 +53,14 @@ public:
|
||||
private:
|
||||
virtual void OnTick() = 0;
|
||||
|
||||
void OnConnectRequest(UdpConnection* connection) override {
|
||||
void OnConnectRequest(UdpConnection *connection) override
|
||||
{
|
||||
AddClient(std::make_unique<ClientT>(connection, node_));
|
||||
}
|
||||
|
||||
void AddClient(std::unique_ptr<ClientT> client) { clients_.push_back(std::move(client)); }
|
||||
|
||||
std::vector<std::unique_ptr<ClientT>> clients_;
|
||||
NodeT* node_;
|
||||
UdpManager* udpManager_;
|
||||
NodeT *node_;
|
||||
UdpManager *udpManager_;
|
||||
};
|
||||
|
||||
@@ -1,76 +1,75 @@
|
||||
|
||||
add_executable(stationchat
|
||||
protocol/AddBan.hpp
|
||||
protocol/AddFriend.hpp
|
||||
protocol/AddIgnore.hpp
|
||||
protocol/AddInvite.hpp
|
||||
protocol/AddModerator.hpp
|
||||
protocol/CreateRoom.hpp
|
||||
protocol/DestroyAvatar.hpp
|
||||
protocol/DestroyRoom.hpp
|
||||
protocol/EnterRoom.hpp
|
||||
protocol/FailoverReLoginAvatar.hpp
|
||||
protocol/FriendStatus.hpp
|
||||
protocol/GetAnyAvatar.hpp
|
||||
protocol/GetPersistentHeaders.hpp
|
||||
protocol/GetPersistentMessage.hpp
|
||||
protocol/GetRoom.hpp
|
||||
protocol/GetRoomSummaries.hpp
|
||||
protocol/IgnoreStatus.hpp
|
||||
protocol/KickAvatar.hpp
|
||||
protocol/LeaveRoom.hpp
|
||||
protocol/LoginAvatar.hpp
|
||||
protocol/LogoutAvatar.hpp
|
||||
protocol/Protocol.cpp
|
||||
protocol/RegistrarGetChatServer.hpp
|
||||
protocol/RemoveBan.hpp
|
||||
protocol/RemoveFriend.hpp
|
||||
protocol/RemoveIgnore.hpp
|
||||
protocol/RemoveInvite.hpp
|
||||
protocol/RemoveModerator.hpp
|
||||
protocol/SendInstantMessage.hpp
|
||||
protocol/SendPersistentMessage.hpp
|
||||
protocol/SendRoomMessage.hpp
|
||||
protocol/SetApiVersion.hpp
|
||||
protocol/SetAvatarAttributes.hpp
|
||||
protocol/UpdatePersistentMessage.hpp
|
||||
protocol/UpdatePersistentMessages.hpp
|
||||
|
||||
ChatAvatar.cpp
|
||||
ChatAvatar.hpp
|
||||
ChatAvatarService.cpp
|
||||
ChatAvatarService.hpp
|
||||
ChatEnums.cpp
|
||||
ChatEnums.hpp
|
||||
ChatRoom.cpp
|
||||
ChatRoom.hpp
|
||||
ChatRoomService.cpp
|
||||
ChatRoomService.hpp
|
||||
GatewayClient.cpp
|
||||
GatewayClient.hpp
|
||||
GatewayNode.cpp
|
||||
GatewayNode.hpp
|
||||
main.cpp
|
||||
Message.hpp
|
||||
PersistentMessage.hpp
|
||||
PersistentMessageService.cpp
|
||||
PersistentMessageService.hpp
|
||||
RegistrarClient.cpp
|
||||
RegistrarClient.hpp
|
||||
RegistrarNode.cpp
|
||||
RegistrarNode.hpp
|
||||
StationChatApp.cpp
|
||||
StationChatApp.hpp
|
||||
StationChatConfig.hpp)
|
||||
|
||||
add_executable(
|
||||
stationchat
|
||||
protocol/AddBan.hpp
|
||||
protocol/AddFriend.hpp
|
||||
protocol/AddIgnore.hpp
|
||||
protocol/AddInvite.hpp
|
||||
protocol/AddModerator.hpp
|
||||
protocol/CreateRoom.hpp
|
||||
protocol/DestroyAvatar.hpp
|
||||
protocol/DestroyRoom.hpp
|
||||
protocol/EnterRoom.hpp
|
||||
protocol/FailoverReLoginAvatar.hpp
|
||||
protocol/FriendStatus.hpp
|
||||
protocol/GetAnyAvatar.hpp
|
||||
protocol/GetPersistentHeaders.hpp
|
||||
protocol/GetPersistentMessage.hpp
|
||||
protocol/GetRoom.hpp
|
||||
protocol/GetRoomSummaries.hpp
|
||||
protocol/IgnoreStatus.hpp
|
||||
protocol/KickAvatar.hpp
|
||||
protocol/LeaveRoom.hpp
|
||||
protocol/LoginAvatar.hpp
|
||||
protocol/LogoutAvatar.hpp
|
||||
protocol/Protocol.cpp
|
||||
protocol/RegistrarGetChatServer.hpp
|
||||
protocol/RemoveBan.hpp
|
||||
protocol/RemoveFriend.hpp
|
||||
protocol/RemoveIgnore.hpp
|
||||
protocol/RemoveInvite.hpp
|
||||
protocol/RemoveModerator.hpp
|
||||
protocol/SendInstantMessage.hpp
|
||||
protocol/SendPersistentMessage.hpp
|
||||
protocol/SendRoomMessage.hpp
|
||||
protocol/SetApiVersion.hpp
|
||||
protocol/SetAvatarAttributes.hpp
|
||||
protocol/UpdatePersistentMessage.hpp
|
||||
protocol/UpdatePersistentMessages.hpp
|
||||
ChatAvatar.cpp
|
||||
ChatAvatar.hpp
|
||||
ChatAvatarService.cpp
|
||||
ChatAvatarService.hpp
|
||||
ChatEnums.cpp
|
||||
ChatEnums.hpp
|
||||
ChatRoom.cpp
|
||||
ChatRoom.hpp
|
||||
ChatRoomService.cpp
|
||||
ChatRoomService.hpp
|
||||
GatewayClient.cpp
|
||||
GatewayClient.hpp
|
||||
GatewayNode.cpp
|
||||
GatewayNode.hpp
|
||||
main.cpp
|
||||
Message.hpp
|
||||
PersistentMessage.hpp
|
||||
PersistentMessageService.cpp
|
||||
PersistentMessageService.hpp
|
||||
RegistrarClient.cpp
|
||||
RegistrarClient.hpp
|
||||
RegistrarNode.cpp
|
||||
RegistrarNode.hpp
|
||||
StationChatApp.cpp
|
||||
StationChatApp.hpp
|
||||
StationChatConfig.hpp)
|
||||
|
||||
# cmake-format: off
|
||||
target_link_libraries(stationchat
|
||||
stationapi
|
||||
udplibrary
|
||||
${Boost_LIBRARIES}
|
||||
${SQLite3_LIBRARY}
|
||||
$<$<PLATFORM_ID:Windows>:ws2_32>)
|
||||
# cmake-format: on
|
||||
|
||||
target_include_directories(stationchat PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(stationchat PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
install(TARGETS stationchat RUNTIME DESTINATION bin)
|
||||
|
||||
Reference in New Issue
Block a user