File tree Expand file tree Collapse file tree 5 files changed +344
-237
lines changed
Expand file tree Collapse file tree 5 files changed +344
-237
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ set(DMDUTIL_SOURCES
7676 src/Logger.cpp
7777 src/AlphaNumeric.cpp
7878 src/SceneGenerator.cpp
79+ src/DMDServer.cpp
7980)
8081
8182if (PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux" )
@@ -144,7 +145,7 @@ if(BUILD_SHARED)
144145
145146 if (PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux" )
146147 add_executable (dmdserver
147- src/dmdServer .cpp
148+ src/server .cpp
148149 src/Logger.cpp
149150 )
150151 target_link_libraries (dmdserver PUBLIC dmdutil_shared)
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < atomic>
4+ #include < mutex>
5+ #include < thread>
6+ #include < vector>
7+
8+ #include " DMDUtil/DMD.h"
9+ #include " sockpp/tcp_acceptor.h"
10+
11+ #define DMDSERVER_MAX_WIDTH 256
12+ #define DMDSERVER_MAX_HEIGHT 64
13+
14+ namespace DMDUtil
15+ {
16+
17+ class DMDUTILAPI DMDServer
18+ {
19+ public:
20+ DMDServer (DMD* dmd, bool fixedAltColorPath = false , bool fixedPupPath = false );
21+ ~DMDServer ();
22+
23+ bool Start (const char * addr, in_port_t port);
24+ void Stop ();
25+ bool IsRunning () const { return m_running; }
26+
27+ private:
28+ void AcceptLoop ();
29+ void ClientThread (sockpp::tcp_socket sock, uint32_t threadId);
30+
31+ DMD* m_dmd;
32+ bool m_fixedAltColorPath;
33+ bool m_fixedPupPath;
34+ std::atomic<bool > m_running{false };
35+ sockpp::tcp_acceptor m_acceptor;
36+
37+ uint32_t m_currentThreadId{0 };
38+ std::mutex m_threadMutex;
39+ uint32_t m_disconnectOtherClients{0 };
40+ std::vector<uint32_t > m_threads;
41+ std::thread* m_acceptThread{nullptr };
42+ };
43+
44+ } // namespace DMDUtil
Original file line number Diff line number Diff line change 1717#include "LevelDMD.h"
1818#include "RGB24DMD.h"
1919#include "SceneGenerator.h"
20+ #include "DMDServer.h"
You can’t perform that action at this time.
0 commit comments