Bredbandskollen CLI  1.2
Asynchronous network task engine
infotask.h
1 // Copyright (c) 2018 IIS (The Internet Foundation in Sweden)
2 // Written by Göran Andersson <initgoran@gmail.com>
3 
4 #pragma once
5 
6 #include "measurementtask.h"
7 
8 class InfoTask : public MeasurementTask {
9 public:
10  InfoTask(const std::string &label, const std::string &ticket_string,
11  const std::string &hash_key, const HttpHost &server,
12  unsigned int no_conn = 1, unsigned int max_conn = 3,
13  double duration = 300.0) :
14  MeasurementTask(label, ticket_string, server,
15  no_conn, max_conn, duration),
16  key(hash_key)
17  {
18  }
19  void newRequest(HttpClientConnection *) override;
21  return false;
22  }
24  const std::string &msg) override;
25  double timerEvent() override;
26 
27  // Stop waiting for upload result after at most t seconds:
28  void setUploadDeadline(double t) {
29  if (t > 0.0)
30  upload_deadline = elapsed() + t;
31  else
32  upload_deadline = t;
33  }
34 
35  // Stop waiting for measurement ID after at most t seconds:
36  void setInfoDeadline(double t) {
37  if (t > 0.0)
38  info_deadline = elapsed() + t;
39  else
40  info_deadline = t;
41  }
42 private:
43  std::string key;
44  double upload_deadline = -1.0;
45  double info_deadline = -1.0;
46 };
HTTP/1.1 client protocol.
Definition: httpclientconnection.h:39
Definition: httpconnection.h:11
The host name and port number of a HTTP host.
Definition: httphost.h:17
Definition: infotask.h:8
bool wsTextMessage(HttpConnection *, const std::string &msg) override
Incoming websocket text message. Return false to kill connection.
Definition: infotask.cpp:10
void newRequest(HttpClientConnection *) override
Initiate next request, or ignore to close connection.
Definition: infotask.cpp:6
double timerEvent() override
Definition: infotask.cpp:17
bool requestComplete(HttpClientConnection *) override
Called when response has been fully read.
Definition: infotask.h:20
std::string label() const
Return the object's log label.
Definition: logger.h:251
Definition: measurementtask.h:9
double elapsed() const
Return number of seconds since the task was started.
Definition: task.h:234