| 129 | } |
| 130 | |
| 131 | void received(queue<Event> events) |
| 132 | { |
| 133 | while (!events.empty()) { |
| 134 | Event event = events.front(); |
| 135 | events.pop(); |
| 136 | |
| 137 | switch (event.type()) { |
| 138 | case Event::SUBSCRIBED: { |
| 139 | cout << "Received a SUBSCRIBED event" << endl; |
| 140 | |
| 141 | state = SUBSCRIBED; |
| 142 | break; |
| 143 | } |
| 144 | |
| 145 | case Event::LAUNCH: { |
| 146 | const TaskInfo& task = event.launch().task(); |
| 147 | tasks[task.task_id()] = task; |
| 148 | |
| 149 | cout << "Starting task " << task.task_id().value() << endl; |
| 150 | |
| 151 | sendStatusUpdate(task, TaskState::TASK_RUNNING); |
| 152 | |
| 153 | // This is where one would perform the requested task. |
| 154 | |
| 155 | cout << "Finishing task " << task.task_id().value() << endl; |
| 156 | |
| 157 | sendStatusUpdate(task, TaskState::TASK_FINISHED); |
| 158 | break; |
| 159 | } |
| 160 | |
| 161 | case Event::LAUNCH_GROUP: { |
| 162 | cout << "Received a LAUNCH_GROUP event"; |
| 163 | // TODO(vinod): Implement this. |
| 164 | break; |
| 165 | } |
| 166 | |
| 167 | case Event::KILL: { |
| 168 | cout << "Received a KILL event" << endl; |
| 169 | break; |
| 170 | } |
| 171 | |
| 172 | case Event::ACKNOWLEDGED: { |
| 173 | cout << "Received an ACKNOWLEDGED event" << endl; |
| 174 | |
| 175 | // Remove the corresponding update. |
| 176 | updates.erase(id::UUID::fromBytes(event.acknowledged().uuid()).get()); |
| 177 | |
| 178 | // Remove the corresponding task. |
| 179 | tasks.erase(event.acknowledged().task_id()); |
| 180 | break; |
| 181 | } |
| 182 | |
| 183 | case Event::MESSAGE: { |
| 184 | cout << "Received a MESSAGE event" << endl; |
| 185 | break; |
| 186 | } |
| 187 | |
| 188 | case Event::SHUTDOWN: { |