root/ServerEvents.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#pragma once
#include "utils.h"
#include "List.h"
#include <curl/curl.h>

struct ServerEventCallback {
    void* userdata;
    void (*fn)(const char*,const char*,void*);
};

struct ServerEvents {
    struct Buffer buffer;
    List* callbacks;
    CURL* handle;
};

void ServerEvents_init(struct ServerEvents* this);
void ServerEvents_destroyMembers(struct ServerEvents* this);

void ServerEvents_connect(struct ServerEvents* this, const char* baseUrl, CURLM* multiHandle);
void ServerEvents_addCallback(struct ServerEvents* this,
                              void(*fn)(const char*,const char*,void*), void* userdata);
size_t ServerEvents_write(void* buffer, size_t charSize, size_t bufferSize, void* userdata);
void ServerEvents_parseMessage(struct ServerEvents* this);