( begin auto-generated from Server_available.xml ) Returns the next client in line with a new message. ( end auto-generated ) @brief Returns the next client in line with a new message. @webref server @usage application
()
| 224 | * @usage application |
| 225 | */ |
| 226 | public Client available() { |
| 227 | synchronized (clientsLock) { |
| 228 | int index = lastAvailable + 1; |
| 229 | if (index >= clientCount) index = 0; |
| 230 | |
| 231 | for (int i = 0; i < clientCount; i++) { |
| 232 | int which = (index + i) % clientCount; |
| 233 | Client client = clients[which]; |
| 234 | //Check for valid client |
| 235 | if (!client.active()){ |
| 236 | removeIndex(which); //Remove dead client |
| 237 | i--; //Don't skip the next client |
| 238 | //If the client has data make sure lastAvailable |
| 239 | //doesn't end up skipping the next client |
| 240 | which--; |
| 241 | //fall through to allow data from dead clients |
| 242 | //to be retreived. |
| 243 | } |
| 244 | if (client.available() > 0) { |
| 245 | lastAvailable = which; |
| 246 | return client; |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | return null; |
| 251 | } |
| 252 | |
| 253 | |
| 254 | /** |
nothing calls this directly
no test coverage detected