Add the Client_find_by_session() function.
[umurmur.git] / src / client.h
index 9f17ddf3d822ec32d708a5523ec62eee69d892ea..9e3fcb5fa7b379f5ca18f2db33e6b2516b508910 100644 (file)
 
 #define IS_AUTH(_a_) ((_a_)->authenticated)
 
-typedef struct {   /* You can add new lines to this struct, any reordering of some of the lines will break the sharedmemory API */
-       int tcpfd;
+struct channel;
+
+typedef struct {
        SSL_handle_t *ssl;
-       bool_t SSLready;
-       bool_t shutdown_wait;
-       cryptState_t cryptState;
-       bool_t readBlockedOnWrite, writeBlockedOnRead;
-       struct sockaddr_storage remote_tcp;
-       struct sockaddr_storage remote_udp;
-       uint8_t rxbuf[BUFSIZE], txbuf[BUFSIZE];
-       uint32_t rxcount, msgsize, drainleft, txcount, txsize;
-       int sessionId;
-       uint8_t key[KEY_LENGTH];
+       struct dlist node;
        char *username;
-       bool_t bUDP, authenticated, deaf, mute, self_deaf, self_mute, recording, bOpus;
        char *os, *release, *os_version;
+       uint32_t rxcount, msgsize, drainleft, txcount, txsize;
+       int sessionId;
        uint32_t version;
        int codec_count;
        struct dlist codecs;
-       int availableBandwidth;
        etimer_t lastActivity, connectTime, idleTime;
-       struct dlist node;
        struct dlist txMsgQueue;
        int txQueueCount;
-       void *channel; /* Ugly... */
+       int availableBandwidth;
+       struct channel *channel;
        char *context;
        struct dlist chan_node;
        struct dlist voicetargets;
        struct dlist tokens;
        int tokencount;
-       uint8_t hash[20];
-       bool_t isAdmin;
-       bool_t isSuppressed;
+       int tcpfd;
        float UDPPingAvg, UDPPingVar, TCPPingAvg, TCPPingVar;
        uint32_t UDPPackets, TCPPackets;
+
+       bool_t SSLready;
+       bool_t shutdown_wait;
+       bool_t readBlockedOnWrite, writeBlockedOnRead;
+       bool_t bUDP, authenticated, deaf, mute, self_deaf, self_mute, recording, bOpus;
+       bool_t isAdmin;
+       bool_t isSuppressed;
+
+       struct sockaddr_storage remote_tcp;
+       struct sockaddr_storage remote_udp;
+
+       uint8_t key[KEY_LENGTH];
+       uint8_t hash[20];
+       cryptState_t cryptState;
+       uint8_t rxbuf[BUFSIZE], txbuf[BUFSIZE];
 } client_t;
 
 typedef struct {
@@ -126,6 +131,15 @@ void recheckCodecVersions(client_t *connectingClient);
 void Client_codec_add(client_t *client, int codec);
 void Client_codec_free(client_t *client);
 codec_t *Client_codec_iterate(client_t *client, codec_t **codec_itr);
-void Client_textmessage(client_t *client, char *text);
+void Client_textmessage(client_t *client, const char *text);
+bool_t Client_token_match(client_t *client, char const *str);
+void Client_token_free(client_t *client);
+void Client_token_add(client_t *client, char *token_string);
+
+/**
+ * Retrieve the client that matches the given session ID.
+ * Returns NULL if there's no such client.
+ */
+client_t *Client_find_by_session(int session_id);
 
 #endif