A fast, lightweight and simple STOMP compatible messaging server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

client.h 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (C) 2011 Bernhard Froehlich <decke@bluelife.at>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Author's name may not be used endorse or promote products derived
  12. * from this software without specific prior written permission.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  15. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  18. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  20. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  21. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  22. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  23. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  24. * POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #ifndef _CLIENT_H_
  27. #define _CLIENT_H_
  28. #include <sys/queue.h>
  29. /**
  30. * A struct for client specific data, also includes
  31. * pointer to create a list of clients.
  32. */
  33. struct client {
  34. /* The clients socket. */
  35. int fd;
  36. /* Authentication flag for this connection. */
  37. int authenticated;
  38. /* The bufferedevent for this client. */
  39. struct bufferevent *bev;
  40. /* Request with probably padding */
  41. char *rawrequest;
  42. /* Parsed command */
  43. int request_cmd;
  44. /* Plain request including headers and command */
  45. char *request;
  46. /* Request body */
  47. char *request_body;
  48. /* Parsed Headers */
  49. struct evkeyvalq *request_headers;
  50. /* The output buffer for this client. */
  51. struct evbuffer *response_buf;
  52. /* Response command */
  53. int response_cmd;
  54. /* Response body */
  55. char *response;
  56. /* Response Headers */
  57. struct evkeyvalq *response_headers;
  58. TAILQ_ENTRY(client) entries;
  59. };
  60. TAILQ_HEAD(, client) clients;
  61. struct queue {
  62. char *queuename;
  63. volatile u_int read;
  64. volatile u_int write;
  65. TAILQ_HEAD(, client) subscribers;
  66. TAILQ_ENTRY(queue) entries;
  67. };
  68. TAILQ_HEAD(, queue) queues;
  69. #endif /* _CLIENT_H_ */