Changeset 7:bafe58db1509 in xplra for src
- Timestamp:
- 01/04/13 12:50:45 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/xplra
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/xplra/GetDataRefTask.cc
r6 r7 69 69 if (!stream) return 0; 70 70 71 if (length>Protocol::MAX_LENGTH) { 72 result = Protocol::RESULT_INVALID_LENGTH; 73 return 0; 74 } 75 if (offset<0) { 76 result = Protocol::RESULT_INVALID_OFFSET; 77 return 0; 78 } 79 71 80 if (type==Protocol::TYPE_FLOAT_ARRAY) { 72 81 return new GetFloatArrayDataRefTask(name, length, offset); -
src/xplra/Makefile.am
r6 r7 30 30 TaskRequest.cc \ 31 31 DataRefTask.cc \ 32 GetDataRefTask.cc 32 GetDataRefTask.cc \ 33 SetDataRefTask.cc 33 34 34 35 libxplra_la_LIBADD=$(LIBXPLCOMMON_LIBS) … … 43 44 TaskRequest.h \ 44 45 DataRefTask.h \ 45 GetDataRefTask.h 46 GetDataRefTask.h \ 47 SetDataRefTask.h -
src/xplra/Protocol.h
r6 r7 45 45 */ 46 46 static const uint8_t COMMAND_GET_SINGLE = 0x01; 47 48 /** 49 * Command: set the value of a single dataref. 50 */ 51 static const uint8_t COMMAND_SET_SINGLE = 0x02; 47 52 48 53 /** … … 97 102 98 103 /** 104 * Result code: invalid length 105 */ 106 static const uint8_t RESULT_INVALID_LENGTH = 0x04; 107 108 /** 109 * Result code: invalid offset 110 */ 111 static const uint8_t RESULT_INVALID_OFFSET = 0x05; 112 113 /** 99 114 * Result code: other error 100 115 */ 101 116 static const uint8_t RESULT_OTHER_ERROR = 0xff; 117 118 /** 119 * The maximal length we accept (in order to protect ourselves). 120 */ 121 static const int MAX_LENGTH = 2048; 102 122 }; 103 123 -
src/xplra/ServerThread.cc
r6 r7 34 34 #include "Protocol.h" 35 35 #include "GetDataRefTask.h" 36 #include "SetDataRefTask.h" 36 37 #include "TaskRequest.h" 37 38 … … 111 112 112 113 if (command==Protocol::COMMAND_GET_SINGLE) { 113 if (!handleGetSingle(stream)) break; 114 if (!handleGetSingle()) break; 115 } else if (command==Protocol::COMMAND_SET_SINGLE) { 116 if (!handleSetSingle()) break; 114 117 } else { 115 118 stream.writeU8(Protocol::RESULT_INVALID_COMMAND); … … 123 126 //------------------------------------------------------------------------------ 124 127 125 bool ServerThread::handleGetSingle( xplcommon::DataStream& stream)128 bool ServerThread::handleGetSingle() 126 129 { 127 130 uint8_t result = Protocol::RESULT_OK; 128 129 131 GetDataRefTask* task = GetDataRefTask::create(result, stream); 130 132 131 133 if (!stream) return false; 132 134 else if (task==0) { 133 stream.writeU8( Protocol::RESULT_INVALID_TYPE);135 stream.writeU8(result); 134 136 return true; 135 137 } … … 150 152 //------------------------------------------------------------------------------ 151 153 154 bool ServerThread::handleSetSingle() 155 { 156 uint8_t result = Protocol::RESULT_OK; 157 SetDataRefTask* task = SetDataRefTask::create(result, stream); 158 159 if (!stream) return false; 160 else if (task==0) { 161 stream.writeU8(result); 162 return true; 163 } 164 165 TaskRequest request(task); 166 if (!requestQueue.execute(&request)) return false; 167 168 stream.writeU8(task->isValid() ? Protocol::RESULT_OK : 169 Protocol::RESULT_UNKNOWN_DATAREF); 170 return true; 171 } 172 173 //------------------------------------------------------------------------------ 174 152 175 // Local Variables: 153 176 // mode: C++ -
src/xplra/ServerThread.h
r6 r7 129 129 * @return true, if we can continue, false if the thread should quit 130 130 */ 131 bool handleGetSingle(xplcommon::DataStream& stream); 131 bool handleGetSingle(); 132 133 /** 134 * Handle the COMMAND_SET_SINGLE command 135 * 136 * @return true, if we can continue, false if the thread should quit 137 */ 138 bool handleSetSingle(); 132 139 }; 133 140
Note:
See TracChangeset
for help on using the changeset viewer.