fix ansi client and add unsub to server
This commit is contained in:
parent
d0f13d9078
commit
b73bfb2db1
@ -21,8 +21,8 @@
|
|||||||
#define MSG_METRIC_RESP 0x04
|
#define MSG_METRIC_RESP 0x04
|
||||||
#define MSG_SUBSCRIBE 0x05
|
#define MSG_SUBSCRIBE 0x05
|
||||||
#define MSG_PUSH 0x06
|
#define MSG_PUSH 0x06
|
||||||
|
#define MSG_UNSUB 0x07
|
||||||
#define MSG_ERROR 0xFF
|
#define MSG_ERROR 0xFF
|
||||||
|
|
||||||
#define HEADER_SIZE 3
|
#define HEADER_SIZE 3
|
||||||
|
|
||||||
static double get_metric(const char *name)
|
static double get_metric(const char *name)
|
||||||
@ -151,6 +151,10 @@ static void handle_client(int client_sock, struct sockaddr_in *addr)
|
|||||||
have_subscription = 1;
|
have_subscription = 1;
|
||||||
printf(" -> SUBSCRIBE '%s' every %u ms from %s\n", subscribed_metric, interval_ms, client_ip);
|
printf(" -> SUBSCRIBE '%s' every %u ms from %s\n", subscribed_metric, interval_ms, client_ip);
|
||||||
}
|
}
|
||||||
|
else if (type == MSG_UNSUB) {
|
||||||
|
have_subscription = 0;
|
||||||
|
printf(" <- UNSUB from %s\n", client_ip);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
const char *err = "Unknown message type";
|
const char *err = "Unknown message type";
|
||||||
send_message(client_sock, MSG_ERROR, err, strlen(err));
|
send_message(client_sock, MSG_ERROR, err, strlen(err));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user