rabbitmq-c  0.5.3
C AMQP Client library for RabbitMQ
websocket.h
Go to the documentation of this file.
00001 #ifndef WEBSOCKET_H_
00002 #define WEBSOCKET_H_
00003 
00004 #include <stdio.h>
00005 #include <stdlib.h>
00006 #include <string.h>
00007 #include <time.h>
00008 #include <sys/socket.h>
00009 #include <netdb.h>
00010 #include <stdlib.h>
00011 #include <openssl/sha.h>
00012 #include <openssl/rand.h>
00013 #include <openssl/ssl.h>
00014 #include <openssl/err.h>
00015 #include <sys/uio.h>
00016 
00023 //websocket message type
00024 static const int WEBSOCKET_MESSAGE_TEXT = 1;
00025 static const int WEBSOCKET_MESSAGE_BINARY = 2;
00026 static const int WEBSOCKET_MESSAGE_CLOSED = 8;
00027 
00028 // websocket readystate
00029 static const int WEBSOCKET_READYSTATE_CONNECTING = 0;
00030 static const int WEBSOCKET_READYSTATE_OPEN = 1;
00031 static const int WEBSOCKET_READYSTATE_CLOSING = 2;
00032 static const int WEBSOCKET_READYSTATE_CLOSED = 3;
00033 
00038 typedef struct websocket_message_event_t_stct {
00039   int type;         
00040   char* data;       
00041   int length;       
00042 }websocket_message_event_t;
00043 
00049 typedef struct websocket_t_stct websocket_t;
00050 
00056 websocket_t* websocket_new();
00057 
00063 void websocket_free(websocket_t* ws);
00064 
00074 int websocket_connect(websocket_t* ws, const char* location, const char* protocol, const char* extension);
00075 
00082 int websocket_send_text(websocket_t* ws, const char* text);
00083 
00091 int websocket_send_binary(websocket_t* ws, const char* binary, size_t size);
00092 
00100 int websocket_send_binaryv(websocket_t* ws, const struct iovec *iov, int iovcnt);
00101 
00107 int websocket_close(websocket_t* ws);
00108 
00117 int websocket_close_with_reason(websocket_t* ws, int code, const char* reason);
00118 
00130 websocket_message_event_t* websocket_recv(websocket_t* ws);
00131 
00139 const char* websocket_url(websocket_t* ws);
00140 
00146 int websocket_readystate(websocket_t* ws);
00147 
00154 const char* websocket_protocol(websocket_t* ws);
00155 
00162 const char* websocket_extension(websocket_t* ws);
00163 
00164 //SSL functions
00165 
00173 int websocket_ssl_set_cacert(websocket_t *ws, const char *cacert);
00174 
00183 int websocket_ssl_set_clientkey(websocket_t *ws, const char *cert, const char *key);
00184 
00192 int websocket_ssl_set_verify_callback(websocket_t* ws, int (*callback)(int preverify_ok, X509_STORE_CTX *ctx));
00193 
00194 #endif /* WEBSOCKET_H_ */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines