Changeset 36:29e3b676c0c2 in xplra for src/plugin
- Timestamp:
- 02/10/13 08:21:47 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/plugin/src/xplra
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/plugin/src/xplra/ListenThread.cc
r13 r36 55 55 while(!quitEvent.check() && !quitEvent.failed() && !acceptor.failed()) { 56 56 if (acceptor.accept()) { 57 ServerThread* serverThread = new ServerThread(requestQueue, 57 ServerThread* serverThread = new ServerThread(*this, 58 requestQueue, 58 59 acceptor); 59 60 serverThread->start(); -
src/plugin/src/xplra/ListenThread.h
r13 r36 54 54 private: 55 55 /** 56 * The version of X-Plane. 57 */ 58 int xplaneVersion; 59 60 /** 61 * The version of the XPLM library. 62 */ 63 int xplmVersion; 64 65 /** 56 66 * The waiter used in the thread. 57 67 */ … … 73 83 * Construct the thread. 74 84 */ 75 ListenThread(); 85 ListenThread(int xplaneVersion, int xplmVersion); 86 87 /** 88 * Get the versions 89 */ 90 void getVersions(int& xplane, int& xplm) const; 76 91 77 92 /** … … 90 105 //------------------------------------------------------------------------------ 91 106 92 inline ListenThread::ListenThread( ) :107 inline ListenThread::ListenThread(int xplaneVersion, int xplmVersion) : 93 108 Thread(true), 109 xplaneVersion(xplaneVersion), 110 xplmVersion(xplmVersion), 94 111 quitEvent(&waiter) 95 112 { 113 } 114 115 //------------------------------------------------------------------------------ 116 117 inline void ListenThread::getVersions(int& xplane, int& xplm) const 118 { 119 xplane = xplaneVersion; 120 xplm = xplmVersion; 96 121 } 97 122 -
src/plugin/src/xplra/Protocol.h
r13 r36 92 92 93 93 /** 94 * Command: get the versions of the simulator 95 */ 96 static const uint8_t COMMAND_GET_VERSIONS = 0x31; 97 98 /** 94 99 * Data type: int 95 100 */ … … 176 181 */ 177 182 static const size_t MAX_MULTI_COUNT = 1024; 183 184 /** 185 * The version of the plugin. 186 */ 187 static const int version = 10; 178 188 }; 179 189 -
src/plugin/src/xplra/ServerThread.cc
r13 r36 31 31 #include "ServerThread.h" 32 32 33 #include "ListenThread.h" 33 34 #include "RequestQueue.h" 34 35 #include "Protocol.h" … … 72 73 //------------------------------------------------------------------------------ 73 74 74 ServerThread::ServerThread(RequestQueue& requestQueue, LocalAcceptor& acceptor) : 75 ServerThread::ServerThread(ListenThread& listenThread, 76 RequestQueue& requestQueue, LocalAcceptor& acceptor) : 75 77 Thread(true), 78 listenThread(listenThread), 76 79 requestQueue(requestQueue), 77 80 bufferedStream(acceptor.getSocket(&waiter)), … … 147 150 } else if (command==Protocol::COMMAND_EXECUTE_SET_MULTI) { 148 151 if (!handleExecuteSetMulti()) break; 152 } else if (command==Protocol::COMMAND_GET_VERSIONS) { 153 if (!handleGetVersions()) break; 149 154 } else { 150 155 stream.writeU8(Protocol::RESULT_INVALID_COMMAND); … … 384 389 //------------------------------------------------------------------------------ 385 390 391 bool ServerThread::handleGetVersions() 392 { 393 int xplaneVersion = 0; 394 int xplmVersion = 0; 395 396 listenThread.getVersions(xplaneVersion, xplmVersion); 397 398 stream.writeU8(Protocol::RESULT_OK); 399 stream.writeS32(xplaneVersion); 400 stream.writeS32(xplmVersion); 401 stream.writeS32(Protocol::version); 402 403 return true; 404 } 405 406 //------------------------------------------------------------------------------ 407 386 408 // Local Variables: 387 409 // mode: C++ -
src/plugin/src/xplra/ServerThread.h
r13 r36 49 49 //------------------------------------------------------------------------------ 50 50 51 class ListenThread; 52 51 53 class RequestQueue; 52 54 … … 95 97 private: 96 98 /** 99 * The listen thread this server was started by. 100 */ 101 ListenThread& listenThread; 102 103 /** 97 104 * The request queue to use. 98 105 */ … … 139 146 * given acceptor. 140 147 */ 141 ServerThread( RequestQueue& requestQueue,148 ServerThread(ListenThread& listenThread, RequestQueue& requestQueue, 142 149 hu::varadiistvan::scpl::io::LocalAcceptor& acceptor); 143 150 … … 227 234 */ 228 235 bool handleExecuteSetMulti(); 236 237 /** 238 * Handle the COMMAND_GET_VERSIONS command 239 * 240 * @return true, if we can continue, false if the thread should quit 241 */ 242 bool handleGetVersions(); 229 243 }; 230 244 -
src/plugin/src/xplra/plugin.cc
r13 r36 83 83 Util::debug("hu.varadiistvan.xplra.XPluginEnable called\n"); 84 84 // XPLMRegisterFlightLoopCallback(&callback, 5.0, 0); 85 listenThread = new ListenThread(); 85 86 int xplaneVersion = 0; 87 int xplmVersion = 0; 88 XPLMHostApplicationID hostID = 0; 89 XPLMGetVersions(&xplaneVersion, &xplmVersion, &hostID); 90 91 listenThread = new ListenThread(xplaneVersion, xplmVersion); 86 92 listenThread->start(); 87 93 }
Note:
See TracChangeset
for help on using the changeset viewer.