Branch
Hash :
e8313084
Author :
Date :
2022-09-12T22:16:56
Add minimal WebSocket server implementation for evhttp (#1322) This adds few functions to use evhttp-based webserver to handle incoming WebSockets connections. We've tried to use both libevent and libwebsockets in our application, but found that we need to have different ports at the same time to handle standard HTTP and WebSockets traffic. This change can help to stick only with libevent library. Implementation was inspired by modified Libevent source code in ipush project [1]. [1]: https://github.com/sqfasd/ipush/tree/master/deps/libevent-2.0.21-stable Also, WebSocket-based chat server was added as a sample.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
# sample/include.am for libevent
# Copyright 2000-2007 Niels Provos
# Copyright 2007-2012 Niels Provos and Nick Mathewson
#
# See LICENSE for copying information.
SAMPLES = \
sample/dns-example \
sample/event-read-fifo \
sample/hello-world \
sample/http-server \
sample/http-connect \
sample/signal-test \
sample/time-test \
sample/ws-chat-server \
sample/watch-timing
if OPENSSL
SAMPLES += sample/le-proxy
sample_le_proxy_SOURCES = sample/le-proxy.c
sample_le_proxy_LDADD = libevent.la libevent_openssl.la $(OPENSSL_LIBS) $(OPENSSL_LIBADD)
sample_le_proxy_CPPFLAGS = $(AM_CPPFLAGS) $(OPENSSL_INCS)
SAMPLES += sample/becat
sample_becat_SOURCES = sample/becat.c
sample_becat_LDADD = libevent.la libevent_openssl.la $(OPENSSL_LIBS) $(OPENSSL_LIBADD)
sample_becat_CPPFLAGS = $(AM_CPPFLAGS) $(OPENSSL_INCS)
SAMPLES += sample/https-client
sample_https_client_SOURCES = \
sample/https-client.c \
sample/hostcheck.c \
sample/openssl_hostname_validation.c
sample_https_client_LDADD = libevent.la libevent_openssl.la $(OPENSSL_LIBS) $(OPENSSL_LIBADD)
if BUILD_WIN32
sample_https_client_LDADD += -lcrypt32
endif
sample_https_client_CPPFLAGS = $(AM_CPPFLAGS) $(OPENSSL_INCS)
noinst_HEADERS += \
sample/hostcheck.h \
sample/openssl_hostname_validation.h
endif
if MBEDTLS
SAMPLES += sample/ssl-client-mbedtls
sample_ssl_client_mbedtls_SOURCES = sample/ssl-client-mbedtls.c
sample_ssl_client_mbedtls_LDADD = libevent.la libevent_mbedtls.la $(MBEDTLS_LIBS) $(MBEDTLS_LIBADD)
sample_ssl_client_mbedtls_CPPFLAGS = $(AM_CPPFLAGS) $(MBEDTLS_INCS)
SAMPLES += sample/https-client-mbedtls
sample_https_client_mbedtls_SOURCES = sample/https-client.c
sample_https_client_mbedtls_LDADD = libevent.la libevent_mbedtls.la $(MBEDTLS_LIBS) $(MBEDTLS_LIBADD)
sample_https_client_mbedtls_CPPFLAGS = $(AM_CPPFLAGS) $(MBEDTLS_INCS) -DUSE_MBEDTLS
endif
if BUILD_SAMPLES
noinst_PROGRAMS += $(SAMPLES)
endif
$(SAMPLES) : libevent.la
sample_event_read_fifo_SOURCES = sample/event-read-fifo.c
sample_event_read_fifo_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la
sample_time_test_SOURCES = sample/time-test.c
sample_time_test_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la
sample_signal_test_SOURCES = sample/signal-test.c
sample_signal_test_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la
sample_dns_example_SOURCES = sample/dns-example.c
sample_dns_example_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la
sample_hello_world_SOURCES = sample/hello-world.c
sample_hello_world_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la
sample_http_server_SOURCES = sample/http-server.c
sample_http_server_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la
sample_http_connect_SOURCES = sample/http-connect.c
sample_http_connect_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la
sample_watch_timing_SOURCES = sample/watch-timing.c
sample_watch_timing_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la -lm
sample_ws_chat_server_SOURCES = sample/ws-chat-server.c
sample_ws_chat_server_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la -lm
EXTRA_DIST+=sample/ws-chat.html