Compare commits

...

121 Commits

Author SHA1 Message Date
Peter Thorson 43970572f5 version bump 2012-12-19 06:36:28 -06:00
Peter Thorson 6a1dccc8cb corrects an infinite loop when the acceptor is closed in thread pool mode references #168 2012-12-19 06:26:28 -06:00
Peter Thorson 6aa11a7fac Updates user agent/version string 2012-12-11 07:45:20 -06:00
Peter Thorson 0318700c00 m_requested_subprotocols wasn't getting populated. fixes #155
Thank you to robagar for finding this bug and jeffjcrowe for supplying
a patch
2012-12-11 07:07:25 -06:00
Peter Thorson 27a6d6f4d3 Close acceptor on stop_listen. fixes #161 2012-12-11 06:53:43 -06:00
Peter Thorson ce1c1d3a76 removes unnecessary check fixes #163 2012-12-11 06:42:50 -06:00
Peter Thorson 1c8ba9954e Adjusts ordering guarantees on message sending references #149 2012-10-12 07:56:05 -05:00
Peter Thorson 52ce31bea4 updates the order of endpoint and handler construction #references 147 2012-10-12 06:36:23 -05:00
Peter Thorson 47a3c060ee Revert "Fix Compiler Warning on using std::copy: no point using STL routines inside low-level C-style code"
This reverts commit 5dfe48b043.
2012-10-12 06:31:18 -05:00
Peter Thorson d80d9afd88 preliminary work on a fix to the ARM aliasing issues 2012-10-12 06:29:42 -05:00
Peter Thorson 25322aac0d adds missing virtual destructor 2012-10-12 06:29:42 -05:00
Peter Thorson 10ac9c41ec removes unused varaible from wsperf 2012-10-12 06:29:42 -05:00
Peter Thorson 492ada4788 updates SConstruct compile flags for posix and darwin 2012-10-12 06:29:41 -05:00
Peter Thorson b73f1526b6 Merge pull request #148 from NNemec/master
Various small changes of general interest
2012-10-12 04:29:12 -07:00
Norbert Nemec 34a10b0916 split server::listen interface into start_listen and stop_listen, allowing the controlling thread to continue running asynchronously. (Legacy interface provided) 2012-10-09 15:08:25 +02:00
Norbert Nemec db0a43a228 Disable warning C4355 for plain.hpp similar to server.hpp (beware: this hides a real design problem) 2012-10-09 14:06:20 +02:00
Norbert Nemec dbdb150021 clarify interface by correct argument names 2012-10-09 14:00:07 +02:00
Norbert Nemec 5dfe48b043 Fix Compiler Warning on using std::copy: no point using STL routines inside low-level C-style code 2012-10-09 13:59:52 +02:00
Norbert Nemec 3e3b5a0bb8 fix compiler issue 2012-10-09 12:15:17 +02:00
Norbert Nemec 54b1931963 Fix compiler issue: boost/cstdint.hpp contains the types inside boost:: namespace. <stdint.h> should be available by default. vcpp2008 has its own workaround. 2012-10-09 12:15:03 +02:00
Norbert Nemec c2f83814dc Update vcpp2008 project files and use common.vsprops for configuring external dependencies (i.e. boost) 2012-10-09 12:11:01 +02:00
Peter Thorson dd9899c34b Adds virtual destructors to handler interfaces fixes #136 2012-09-24 07:47:14 -05:00
Peter Thorson a17a27dd5c updates set_handler to by synchronous fixes #139 2012-09-24 07:41:25 -05:00
Peter Thorson 546846af19 Merge pull request #141 from 422053362/patch-1
Workaround for windows min and max macros with std::min and std::max
2012-09-24 05:12:01 -07:00
422053362 12245fd745 Update src/roles/client.hpp
sometimes it cause error。
 I have check the function "uniform_int_distribution" ,
 the right way to construct is
 boost::random::uniform_int_distribution<>(
                (std::numeric_limits<int32_t>::min)(),
                (std::numeric_limits<int32_t>::max)()
             )
not 
 boost::random::uniform_int_distribution<>(
                std::numeric_limits<int32_t>::min(),
                std::numeric_limits<int32_t>::max()
             )
maybe sometimes the second way would not cause error,but sometimes it dose.so I modified.
2012-09-23 05:33:57 +08:00
Peter Thorson 16aaa00a1c Fixes an issue where http handler callback is called before building the URI #references #118
Thank you ShuminHuang for filing this bug
2012-08-04 09:59:41 -05:00
Peter Thorson 4b3ca1911b Merge pull request #131 from jrosser/fixes
Small fixes for compiling on Ubuntu 12.04
2012-08-04 07:44:12 -07:00
Peter Thorson 925b4cdd68 Merge pull request #124 from oberstet/master
minor thing
2012-08-04 07:36:10 -07:00
Jonathan Rosser 6f0722b04e fix build of fuzzing_client
this seems fairly fundamental - does nothing else use this and fail?
2012-07-31 13:01:04 +01:00
Jonathan Rosser 3ecec05364 fix stress_client warning and compile error 2012-07-31 13:00:53 +01:00
Jonathan Rosser a0040da1d7 add another missing linkage against pthreads 2012-07-31 09:44:27 +01:00
Jonathan Rosser 159b9d3a88 fix missing boost_thread from some examples 2012-07-29 08:47:16 +01:00
Jonathan Rosser b7009335fe fix usage of C99 macros in C++ 2012-07-26 11:29:10 +01:00
Tobias Oberstein 44bacdb323 does away with VC++ warning: C4309 - truncation of constant value 2012-07-18 14:09:39 +02:00
Peter Thorson 3208b1b493 fixes telemetry server bug references #121 2012-07-11 08:47:45 -05:00
Peter Thorson 1f8113bbd6 adds telemetry server example 2012-07-11 08:20:37 -05:00
Peter Thorson 87d76a3995 Fixes a frame read issue with hybi00 references #101 2012-07-10 07:25:27 -05:00
Peter Thorson 84e021e679 updates makefile for wsperf stress test 2012-06-28 06:52:11 -05:00
Peter Thorson 8d9f55ad23 Merge pull request #117 from dasty/master
Just fixing compilation issue for people who use makefile
2012-06-28 04:39:15 -07:00
Peter Thorson 9716a2269c Merge pull request #113 from pmarques/master
Compiler error due to ambiguous methods resolution
2012-06-28 04:36:40 -07:00
Radek Dostal 125142a7d1 $(CXX) linker should not be run for build of object files
Signed-off-by: Radek Dostal <rd@radekdostal.com>
2012-06-18 18:57:51 +02:00
Peter Thorson f78b9df4ad disable file descriptor limits by default to not confuse windows 2012-06-07 13:46:18 -05:00
Peter Thorson 241a28cbd7 javascript reference clients for message_test and stress_test 2012-06-07 13:44:56 -05:00
Peter Thorson 61be3c182c stress_test now supports message sending & stats 2012-06-07 13:44:56 -05:00
Peter Thorson a3b7546d65 Merge pull request #116 from oberstet/master
make win build and warn free
2012-06-07 05:57:20 -07:00
Peter Thorson 0cd1c58505 stress_test parameter parsing 2012-06-07 06:09:24 -05:00
Peter Thorson 674042f576 preliminary support for thousands of connections on darwin and linux 2012-06-07 06:09:02 -05:00
Peter Thorson 0b10e9c0a3 adds extract string support for wscmd 2012-06-07 06:07:42 -05:00
Tobias Oberstein 9838895d39 slight adjust 2012-06-07 12:55:07 +02:00
Tobias Oberstein 19173e9584 some minor things (make win build warn free) 2012-06-07 12:49:55 +02:00
Peter Thorson b58cf53353 some windows fixes 2012-06-05 08:39:08 -05:00
Peter Thorson 2d12256c7c adds handshake delay and test doneness check 2012-06-05 08:26:06 -05:00
Peter Thorson 1d3942622a this can cause crazy runaway reconnects, need to rethink 2012-06-05 08:25:52 -05:00
Peter Thorson 002e75891e adds preliminary stress_test mode to wsperf 2012-06-04 08:47:37 -05:00
Peter Thorson 2f6565565b adds client on_handshake_init callback 2012-06-04 08:47:37 -05:00
Peter Thorson 232fd1ebf6 Merge pull request #115 from beeftaco/master
Updated project and solution files for better Windows compatibility
2012-05-29 04:06:41 -07:00
beeftaco 469c97c7d9 Updated compatibility for VS2010 2012-05-28 11:47:34 -07:00
Patrick F. Marques 8e091853cc Correction of compiler error due to ambiguous "call conversionS" 2012-05-03 10:40:57 +01:00
Peter Thorson 899b7e3bea defines CPP11 friend fix for Visual Studio 2012-04-22 15:22:40 -05:00
Peter Thorson 9ba194a7f9 fixes #103 2012-04-13 08:47:48 -05:00
Peter Thorson e928f4a566 adds preliminary machine readable connection failure information 2012-04-13 08:34:22 -05:00
Peter Thorson 31a9f9a9bc potential fixes for hixie76 handshakes, references #101 2012-04-13 07:38:15 -05:00
Peter Thorson 7875f03f76 adds WS handshake timeout 2012-04-13 07:36:00 -05:00
Peter Thorson 419178dead adds hook for on_handshake_init 2012-04-13 07:35:29 -05:00
Peter Thorson a4bca13636 generic timeout support 2012-04-13 07:34:50 -05:00
Peter Thorson 8d846000bf adds on_tcp_init hook and TLS handshake timeout 2012-04-13 07:34:22 -05:00
Peter Thorson dc3be3d658 adds on_tcp_init hook 2012-04-13 07:34:11 -05:00
Peter Thorson 75ef3defe9 adds header needed on unix 2012-04-13 07:33:52 -05:00
Peter Thorson 0eedb6e8b6 moves JS libraries into "vendor" folder to escape Linguist 2012-04-13 07:33:30 -05:00
Peter Thorson 04f8413f7d Merge pull request #104 from jdale88/master
Compiler fixes for VS2010
2012-04-12 19:25:01 -07:00
Jamie Dale 42afb69ede Compiler fixes for VS2010.
This fixes some errors caused by Windows defining things like min and max, as well as a number of warnings about type conversion, unused parameters, inability to generate assignment operators, and constant conditions.

All type conversions were assumed to be intentional, and static_casts have been added to remove the compiler warnings.

The server code should now build cleanly with level 4 warnings enabled (as used in my project), and the client code should build cleanly with level 3 warnings enabled (as used by the WebSocket++ projects).
2012-04-12 19:31:12 +01:00
Peter Thorson af23ead5fc removes more duplicate javascript libraries 2012-04-10 09:09:07 -05:00
Peter Thorson dc1e432cdf removes second bundled copy of slot 2012-04-10 09:03:11 -05:00
Peter Thorson 7c4c359ef9 disable experimental support for client thread pool by default 2012-04-10 08:54:51 -05:00
Peter Thorson 1512598e3f logging robustness changes 2012-04-10 08:26:23 -05:00
Peter Thorson 9bc3220b5e message processor performance improvements 2012-04-10 08:25:46 -05:00
Peter Thorson 8129787625 to_hex for char* 2012-04-10 08:24:54 -05:00
Peter Thorson 14802c7afc wsperf logging and preliminary stress_test work 2012-04-10 08:24:39 -05:00
Peter Thorson 64156eff9f updates build system files 2012-04-10 08:22:30 -05:00
Peter Thorson 4e7b899dc7 new wsperf module files 2012-04-10 08:21:57 -05:00
Peter Thorson ea19f1e501 masking utility functions and unit tests 2012-04-10 08:21:35 -05:00
Peter Thorson f3fc8a2466 cleans up and documents some hixie 76 issues references #101 2012-04-07 10:15:28 -05:00
Peter Thorson 6c9d814392 fixes #78 2012-04-07 10:06:36 -05:00
Peter Thorson eb79122da9 update Xcode project 2012-04-07 10:03:32 -05:00
Peter Thorson bb2154613c removes some debug code 2012-04-07 10:02:53 -05:00
Peter Thorson 5f3fbc9593 Merge branch 'master' of github.com:zaphoyd/websocketpp 2012-03-28 09:51:05 -05:00
Peter Thorson b2f57039ae fixes user agent header typo, fixes #100 2012-03-28 09:50:26 -05:00
Peter Thorson 0c90670176 fixes wsperf build on g++ 4.6 2012-03-27 08:15:41 -05:00
Peter Thorson b8ddddfe01 masking optimizations off by default 2012-03-25 14:33:00 -05:00
Peter Thorson 0f95459ac4 preliminary masking code performance improvements 2012-03-25 08:40:29 -05:00
Peter Thorson 368a0f3726 fixes mutex support in const methods 2012-03-25 08:39:39 -05:00
Peter Thorson 3017830e77 clean up legacy code 2012-03-23 13:44:24 -05:00
Peter Thorson edf244daf7 better detached connection error handling 2012-03-23 13:44:03 -05:00
Peter Thorson 2109723b34 adds thread pool support to concurrent_server example 2012-03-21 22:46:38 -06:00
Peter Thorson 9348aa4c21 adds thread pool support to server 2012-03-21 22:37:04 -06:00
Peter Thorson 6ca0b49ae0 more concurrency cleanup, misc features 2012-03-21 21:57:58 -06:00
Peter Thorson 517852cd95 adds silent close option 2012-03-21 21:57:20 -06:00
Peter Thorson d20a2f6fef hybi processor silent close frame 2012-03-21 21:56:51 -06:00
Peter Thorson 461fe64242 async handle_read_frame in server 2012-03-21 21:56:23 -06:00
Peter Thorson 892fdd2456 updates defaults 2012-03-21 21:56:01 -06:00
Peter Thorson 3cef677c31 docs and concurrency clean up 2012-03-19 16:20:27 -06:00
Peter Thorson 2f6a014a2e docs and cleanup 2012-03-19 16:19:44 -06:00
Peter Thorson 59efe59466 wrap async calls with strand 2012-03-19 15:53:49 -06:00
Peter Thorson 9d221c6a84 updates some todos 2012-03-19 15:53:17 -06:00
Peter Thorson 60c2f8efb2 lots of new constants 2012-03-19 15:50:11 -06:00
Peter Thorson b5cd8488ce update chat client for new API 2012-03-19 15:49:51 -06:00
Peter Thorson 8e73e436d0 WS++ very fast fail on utf8 fixes 2012-03-18 16:41:54 -05:00
Peter Thorson 14562aa8bc enable angle by default 2012-03-18 16:41:30 -05:00
Peter Thorson ae12a9ee52 C++ style copy and set 2012-03-18 14:33:13 -05:00
Peter Thorson 41cd2ac01e Merge pull request #95 from blindmatrix/76296fe2dd49c55d85f818005ea9bb6901807c79
Fixed compile-time warnings
2012-03-18 11:42:21 -07:00
Sven Almgren 76296fe2dd Fixed broken conversion 2012-03-15 16:15:41 +01:00
Sven Almgren 9cdc8e7009 Merge branch 'master' of https://github.com/zaphoyd/websocketpp 2012-03-15 15:15:50 +01:00
Sven Almgren 6fabf34630 Removed some nonstrict-alias code 2012-03-15 15:15:19 +01:00
Peter Thorson f6fd0f4fb2 Merge pull request #93 from oberstet/master
Build fixes
2012-03-15 06:33:06 -07:00
Tobias Oberstein 09c541185d disable TLS build on Win .. needs OpenSSL dev .. 2012-03-15 14:27:25 +01:00
Tobias Oberstein c6bb4912b2 fix scons build 2012-03-15 14:11:21 +01:00
Peter Thorson 3994731df8 Merge branch 'master' of github.com:zaphoyd/websocketpp 2012-03-15 07:37:31 -05:00
Peter Thorson 6b32481a87 make static library default 2012-03-15 07:36:29 -05:00
Peter Thorson 2fa84a07f0 Merge pull request #92 from blindmatrix/master
Removed extra comma in header (and more stuff)
2012-03-15 05:36:08 -07:00
Sven Almgren 1a0796d315 Removed duplicate variable in assignment (m_state = m_state = X) 2012-03-15 12:57:34 +01:00
Sven Almgren 002b8a2c35 Removed extra comma, as -pedantic complains 2012-03-15 11:56:34 +01:00
233 changed files with 5052 additions and 20616 deletions
+11 -8
View File
@@ -28,7 +28,7 @@
# It's authors were Jonathan Wallace and Bernhard Fluehmann.
objects = network_utilities.o sha1.o base64.o md5.o uri.o hybi_header.o data.o
objects = network_utilities.o sha1.o base64.o md5.o uri.o hybi_header.o hybi_util.o data.o
BOOST_PREFIX ?= /usr/local
BOOST_LIB_PATH ?= $(BOOST_PREFIX)/lib
@@ -76,7 +76,7 @@ CXX ?= c++
AR ?= ar
PIC ?= PIC
BUILD_TYPE ?= default
SHARED ?= 1
SHARED ?= 0
# Internal Variables
@@ -150,22 +150,25 @@ endif
# Compile object files
$(objdir)/sha1.o: $(srcdir)/sha1/sha1.cpp
$(CXX) $< -o $@ $(CXXFLAGS)
$(CXX) $< -c -o $@ $(CXXFLAGS)
$(objdir)/base64.o: $(srcdir)/base64/base64.cpp
$(CXX) $< -o $@ $(CXXFLAGS)
$(CXX) $< -c -o $@ $(CXXFLAGS)
$(objdir)/hybi_header.o: $(srcdir)/processors/hybi_header.cpp
$(CXX) $< -o $@ $(CXXFLAGS)
$(CXX) $< -c -o $@ $(CXXFLAGS)
$(objdir)/hybi_util.o: $(srcdir)/processors/hybi_util.cpp
$(CXX) $< -c -o $@ $(CXXFLAGS)
$(objdir)/data.o: $(srcdir)/messages/data.cpp
$(CXX) $< -o $@ $(CXXFLAGS)
$(CXX) $< -c -o $@ $(CXXFLAGS)
$(objdir)/md5.o: $(srcdir)/md5/md5.c
$(CXX) $< -o $@ $(CXXFLAGS)
$(CXX) $< -c -o $@ $(CXXFLAGS)
$(objdir)/%.o: $(srcdir)/%.cpp
$(CXX) $< -o $@ $(CXXFLAGS)
$(CXX) $< -c -o $@ $(CXXFLAGS)
ifeq ($(SHARED),1)
install: banner install_headers $(lib_target)
+19 -6
View File
@@ -10,6 +10,8 @@
import os, sys
env = Environment(ENV = os.environ)
#env["CXX"] = "clang++"
## Boost
##
## Note: You need to either set BOOSTROOT to the root of a stock Boost distribution
@@ -59,9 +61,13 @@ if env['PLATFORM'].startswith('win'):
elif env['PLATFORM'] == 'posix':
env.Append(CPPDEFINES = ['NDEBUG'])
env.Append(CCFLAGS = ['-Wall', '-fno-strict-aliasing'])
env.Append(CCFLAGS = ['-O3', '-fomit-frame-pointer', '-march=core2'])
env.Append(CCFLAGS = ['-O3', '-fomit-frame-pointer'])
#env['LINKFLAGS'] = ''
elif env['PLATFORM'] == 'darwin':
env.Append(CPPDEFINES = ['NDEBUG'])
env.Append(CCFLAGS = ['-Wall', '-Wcast-align'])
env.Append(CCFLAGS = ['-O3', '-fomit-frame-pointer'])
#env['LINKFLAGS'] = ''
if env['PLATFORM'].startswith('win'):
env['LIBPATH'] = env['BOOST_LIBS']
@@ -72,11 +78,15 @@ else:
platform_libs = []
tls_libs = []
tls_build = False
if env['PLATFORM'] == 'posix':
platform_libs = ['pthread', 'rt']
tls_libs = ['ssl', 'crypto']
tls_build = True
elif env['PLATFORM'] == 'darwin':
tls_libs = ['ssl', 'crypto']
tls_build = True
elif env['PLATFORM'].startswith('win'):
# Win/VC++ supports autolinking. nothing to do.
pass
@@ -110,9 +120,10 @@ echo_server = SConscript('#/examples/echo_server/SConscript',
variant_dir = builddir + 'echo_server',
duplicate = 0)
echo_server_tls = SConscript('#/examples/echo_server_tls/SConscript',
variant_dir = builddir + 'echo_server_tls',
duplicate = 0)
if tls_build:
echo_server_tls = SConscript('#/examples/echo_server_tls/SConscript',
variant_dir = builddir + 'echo_server_tls',
duplicate = 0)
echo_client = SConscript('#/examples/echo_client/SConscript',
variant_dir = builddir + 'echo_client',
@@ -130,4 +141,6 @@ concurrent_server = SConscript('#/examples/concurrent_server/SConscript',
variant_dir = builddir + 'concurrent_server',
duplicate = 0)
telemetry_server = SConscript('#/examples/telemetry_server/SConscript',
variant_dir = builddir + 'telemetry_server',
duplicate = 0)
+1 -1
View File
@@ -1,4 +1,4 @@
BOOST_LIBS=boost_system boost_date_time boost_regex
BOOST_LIBS=boost_system boost_date_time boost_regex boost_thread
include ../common.mk
@@ -4,9 +4,9 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>WebSocket++ Broadcast Admin</title>
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="flot/excanvas.min.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="flot/jquery.js"></script>
<script language="javascript" type="text/javascript" src="flot/jquery.flot.js"></script>
<script language="javascript" type="text/javascript" src="md5.js"></script>
<script language="javascript" type="text/javascript" src="vendor/flot/jquery.js"></script>
<script language="javascript" type="text/javascript" src="vendor/flot/jquery.flot.js"></script>
<script language="javascript" type="text/javascript" src="vendor/md5.js"></script>
</head>
<body>

Before

Width:  |  Height:  |  Size: 916 B

After

Width:  |  Height:  |  Size: 916 B

Before

Width:  |  Height:  |  Size: 891 B

After

Width:  |  Height:  |  Size: 891 B

Before

Width:  |  Height:  |  Size: 897 B

After

Width:  |  Height:  |  Size: 897 B

Before

Width:  |  Height:  |  Size: 916 B

After

Width:  |  Height:  |  Size: 916 B

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

+2
View File
@@ -2,6 +2,8 @@ BOOST_LIBS=boost_system boost_thread boost_regex boost_random
include ../common.mk
LDFLAGS := $(LDFLAGS) -lpthread
chat_client: chat_client.o chat_client_handler.o
$(CXX) $(CFLAGS) $^ -o $@ $(LDFLAGS)
+1 -1
View File
@@ -8,7 +8,7 @@ Import('platform_libs')
localenv = env.Clone ()
sources = ["chat_client","chat_client_handler.cpp"]
sources = ["chat_client.cpp","chat_client_handler.cpp"]
LIBS = [wslib, platform_libs] + boostlibs(['system',
'date_time',
+3 -3
View File
@@ -52,8 +52,8 @@ int main(int argc, char* argv[]) {
try {
chat_client_handler_ptr handler(new chat_client_handler());
client::connection_ptr con;
client endpoint(handler);
client::connection_ptr con;
endpoint.alog().unset_level(websocketpp::log::alevel::ALL);
endpoint.elog().unset_level(websocketpp::log::elevel::ALL);
@@ -63,14 +63,14 @@ int main(int argc, char* argv[]) {
con = endpoint.get_connection(uri);
con->add_request_header("User Agent","WebSocket++/0.2.0 WebSocket++Chat/0.2.0");
con->add_request_header("User-Agent","WebSocket++/0.2.0 WebSocket++Chat/0.2.0");
con->add_subprotocol("com.zaphoyd.websocketpp.chat");
con->set_origin("http://zaphoyd.com");
endpoint.connect(con);
boost::thread t(boost::bind(&client::run, &endpoint));
boost::thread t(boost::bind(&client::run, &endpoint, false));
char line[512];
while (std::cin.getline(line, 512)) {
+1 -1
View File
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
<script type="text/javascript" src="jquery-1.6.3.min.js"></script>
<script type="text/javascript" src="vendor/jquery-1.6.3.min.js"></script>
</head>
<body>
-177
View File
@@ -1,177 +0,0 @@
<!doctype html>
<html>
<head>
<script type="text/javascript" src="jquery-1.6.3.min.js"></script>
</head>
<body>
<script type="text/javascript">
var ws;
var url;
$(document).ready(init);
function init() {
$(document).keypress(function(event) {
if ( event.which == 13 ) {
event.preventDefault();
send();
}
});
}
function connect() {
url = $("#server_url").val();
console.log(url);
if ("WebSocket" in window) {
ws = new WebSocket(url);
} else if ("MozWebSocket" in window) {
ws = new MozWebSocket(url);
} else {
chat_message("This Browser does not support WebSockets");
return;
}
ws.onopen = function(e) {
chat_message("A connection to "+url+" has been opened.");
$("#server_url").attr("disabled",true);
$("#toggle_connect").html("Disconnect");
};
ws.onerror = function(e) {
chat_message("An error occured, see console log for more details.");
console.log(e);
};
ws.onclose = function(e) {
chat_message("The connection to "+url+" was closed.");
};
ws.onmessage = function(e) {
var message = JSON.parse(e.data);
if (message.type == "msg") {
chat_message(message.value,message.sender);
} else if (message.type == "participants") {
var o = "<ul>";
for (var p in message.value) {
o += "<li>"+message.value[p]+"</li>";
}
o += "</ul>";
$("#participants").html(o);
}
};
}
function chat_message(message,sender) {
if (arguments.length == 1) {
sender = "";
}
var style;
if (sender == "") {
style = "client";
} else if (sender == "server") {
style = "server";
sender = "["+sender+"]";
} else {
style = "message";
sender = "["+sender+"]";
}
$("#messages").append("<span class='"+style+"'><span class='sender'>"+sender+"</span> <span class='msg'>"+message+"</span></span><br />");
$("#messages").prop({ scrollTop: $("#messages").prop("scrollHeight") });
}
function disconnect() {
ws.close();
$("#server_url").removeAttr("disabled");
$("#toggle_connect").html("Connect");
$("#participants").html("");
}
function toggle_connect() {
if ($("#server_url").attr("disabled") != "disabled") {
connect();
} else {
disconnect();
}
}
function send() {
if (ws === undefined || ws.readyState != 1) {
chat_message("Websocket is not avaliable for writing");
return;
}
ws.send($("#msg").val());
$("#msg").val("");
}
</script>
<style>
body,html {
margin: 0px;
padding: 0px;
height: 100%;
background-color: #999;
font-family: sans-serif;
font-size: 14px;
}
h3 {
}
#controls {
padding: 4px;
float:right;
width: 300px;
}
input {
width: 200px;
}
#messages {
height: 100%;
overflow: auto;
background-color: black;
}
#messages .client {
color: #ccc;
}
#messages .server {
color: yellow;
}
#messages .message {
color: white;
}
</style>
<div id="controls">
<div id="server">
<input type="text" name="server_url" id="server_url" value="ws://thor-websocket.zaphoyd.net:9000/chat" />
<button id="toggle_connect" onclick="toggle_connect();">Connect</button>
</div>
<div id="message_input"><input type="text" name="msg" id="msg" value="Hello World!" />
<button onclick="send();">Send</button></div>
<h3>Chat Participants</h3>
<div id="participants"></div>
</div>
<div id="messages"></div>
</body>
</html>
File diff suppressed because one or more lines are too long
@@ -139,40 +139,53 @@ void process_requests(request_coordinator* coordinator) {
}
}
// concurrent server takes two arguments. A port to bind to and a number of
// worker threads to create. The thread count must be an integer greater than
// or equal to zero.
// usage: <port> <thread_pool_threads> <worker_threads>
//
// num_threads=0 Standard non-threaded WebSocket++ mode. Handlers will block
// i/o operations and other handlers.
// num_threads=1 One thread processes requests serially the other handles i/o
// This allows new connections and requests to be made while the
// processing thread is busy, but does allow long jobs to
// monopolize the processor increasing request latency.
// num_threads>1 Multiple processing threads will work on the single queue of
// requests provided by the i/o thread. This enables out of order
// completion of requests. The number of threads can be tuned
// based on hardware concurrency available and expected load and
// job length.
// port = port to listen on
// thread_pool_threads = number of threads in the pool running io_service.run()
// worker_threads = number of threads in the sleep work pool.
//
// thread_pool_threads determines the number of threads that process i/o handlers. This
// must be at least one. Handlers and callbacks for individual connections are always
// serially executed within that connection. An i/o thread pool will not improve
// performance in cases where number of connections < number of threads in pool.
//
// worker_threads=0 Standard non-threaded WebSocket++ mode. Handlers will block
// i/o operations within their own connection.
// worker_threads=1 A single work thread processes requests serially separate from the i/o
// thread(s). This allows new connections and requests to be made while the
// processing thread is busy, but does allow long jobs to
// monopolize the processor increasing request latency.
// worker_threads>1 Multiple work threads will work on the single queue of
// requests provided by the i/o thread(s). This enables out of order
// completion of requests. The number of threads can be tuned
// based on hardware concurrency available and expected load and
// job length.
int main(int argc, char* argv[]) {
unsigned short port = 9002;
unsigned short num_threads = 2;
size_t worker_threads = 2;
size_t pool_threads = 2;
try {
if (argc == 2) {
if (argc >= 2) {
std::stringstream buffer(argv[1]);
buffer >> port;
}
if (argc == 3) {
if (argc >= 3) {
std::stringstream buffer(argv[2]);
buffer >> num_threads;
buffer >> pool_threads;
}
if (argc >= 4) {
std::stringstream buffer(argv[3]);
buffer >> worker_threads;
}
request_coordinator rc;
server::handler::ptr h;
if (num_threads == 0) {
if (worker_threads == 0) {
h = server::handler::ptr(new server_handler());
} else {
h = server::handler::ptr(new concurrent_server_handler(rc));
@@ -187,13 +200,20 @@ int main(int argc, char* argv[]) {
echo_endpoint.elog().set_level(websocketpp::log::elevel::FATAL);
std::list<boost::shared_ptr<boost::thread> > threads;
for (int i = 0; i < num_threads; i++) {
threads.push_back(boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&process_requests, &rc))));
if (worker_threads > 0) {
for (size_t i = 0; i < worker_threads; i++) {
threads.push_back(
boost::shared_ptr<boost::thread>(
new boost::thread(boost::bind(&process_requests, &rc))
)
);
}
}
std::cout << "Starting WebSocket sleep server on port " << port << " with " << num_threads << " processing threads." << std::endl;
echo_endpoint.listen(port);
std::cout << "Starting WebSocket sleep server on port " << port
<< " with thread pool size " << pool_threads << " and "
<< worker_threads << " worker threads." << std::endl;
echo_endpoint.listen(port,pool_threads);
} catch (std::exception& e) {
std::cerr << "Exception: " << e.what() << std::endl;
}
+1 -3
View File
@@ -70,9 +70,7 @@ int main(int argc, char* argv[]) {
endpoint.elog().unset_level(websocketpp::log::elevel::ALL);
con = endpoint.connect(uri+"getCaseCount");
con->add_request_header("User Agent","WebSocket++/0.2.0-dev");
endpoint.run();
std::cout << "case count: " << boost::dynamic_pointer_cast<echo_client_handler>(handler)->m_case_count << std::endl;
+2
View File
@@ -2,6 +2,8 @@ BOOST_LIBS=boost_system boost_date_time boost_thread boost_regex boost_random
include ../common.mk
LDFLAGS := $(LDFLAGS) -lpthread
fuzzing_client: fuzzing_client.o
$(CXX) $(CFLAGS) $^ -o $@ $(LDFLAGS)
+1 -1
View File
@@ -1,4 +1,4 @@
BOOST_LIBS=boost_system boost_date_time boost_regex
BOOST_LIBS=boost_system boost_date_time boost_regex boost_thread
include ../common.mk
+13 -11
View File
@@ -138,8 +138,8 @@ private:
m_msg_stats.clear();
}
int m_connections_max;
int m_connections_cur;
unsigned int m_connections_max;
unsigned int m_connections_cur;
std::map<std::string,size_t> m_msg_stats;
boost::shared_ptr<boost::asio::deadline_timer> m_timer;
};
@@ -150,14 +150,16 @@ int main(int argc, char* argv[]) {
int num_connections = 100;
int batch_size = 25;
int delay_ms = 16;
if (argc != 5) {
std::cout << "Usage: `echo_client test_url num_connections batch_size delay_ms`" << std::endl;
} else {
uri = argv[1];
num_connections = atoi(argv[2]);
batch_size = atoi(argv[3]);
delay_ms = atoi(argv[4]);
if (argc > 1) {
if (argc != 5) {
std::cout << "Usage: `echo_client test_url num_connections batch_size delay_ms`" << std::endl;
} else {
uri = argv[1];
num_connections = atoi(argv[2]);
batch_size = atoi(argv[3]);
delay_ms = atoi(argv[4]);
}
}
// 12288 is max OS X limit without changing kernal settings
@@ -209,7 +211,7 @@ int main(int argc, char* argv[]) {
connections.insert(endpoint.connect(uri));
boost::thread t(boost::bind(&plain_endpoint_type::run, &endpoint));
boost::thread t(boost::bind(&plain_endpoint_type::run, &endpoint, false));
std::cout << "launching " << num_connections << " connections to " << uri << " in batches of " << batch_size << std::endl;
+17
View File
@@ -0,0 +1,17 @@
BOOST_LIBS=boost_system boost_date_time boost_program_options boost_thread boost_regex
include ../common.mk
LDFLAGS := $(LDFLAGS) -lpthread
telemetry_server: telemetry_server.o
$(CXX) $(CFLAGS) $^ -o $@ $(LDFLAGS)
%.o: %.cpp
$(CXX) -c $(CFLAGS) -o $@ $^
# cleanup by removing generated files
#
.PHONY: clean
clean:
rm -f *.o telemetry_server
+20
View File
@@ -0,0 +1,20 @@
## telemetry_server
##
Import('env')
Import('boostlibs')
Import('wslib')
Import('platform_libs')
localenv = env.Clone ()
sources = ["telemetry_server.cpp"]
LIBS = [wslib, platform_libs] + boostlibs(['system',
'date_time',
'regex',
'thread'])
prg = localenv.Program('telemetry_server', sources, LIBS = LIBS)
Return('prg')
@@ -0,0 +1,158 @@
/*
* Copyright (c) 2012, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "../../src/websocketpp.hpp"
#include <cstring>
#include <set>
#include <boost/functional.hpp>
#include <boost/bind.hpp>
using websocketpp::server;
/// Thread body. Counts up indefinitely, one increment per second. After each
/// it calls the handler back asking it to broadcast the new value. The handler
/// callback returns whether or not the handler would like the telemetry thread
/// to stop. If callback returns true the telemetry loop ands end the thread
/// exits.
void generate_telemetry(boost::function<bool(const std::string&)> callback) {
size_t value = 0;
for (;;) {
// do some work
value++;
// broadcast state
std::stringstream m;
m << value;
if (callback(m.str())) {
break;
}
// wait
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
}
}
class telemetry_server_handler : public server::handler {
public:
typedef telemetry_server_handler type;
typedef boost::shared_ptr<type> ptr;
telemetry_server_handler() : m_done(false),m_value(0) {
boost::function<bool(const std::string&)> callback = boost::bind(&type::on_tick,this,_1);
// start a thread that will generate telemetry independently and call
// this handler back when it has new data to send.
m_telemetry_thread.reset(new boost::thread(
boost::bind(
&generate_telemetry,
callback
)
));
}
// If the handler is going away set done to true and wait for the thread
// to exit.
~telemetry_server_handler() {
{
boost::lock_guard<boost::mutex> guard(m_mutex);
m_done = true;
}
m_telemetry_thread->join();
}
/// Function that we pass to the telemetry thread to broadcast the new
/// state. It returns the global "are we done" value so we can control when
/// the thread stops running.
bool on_tick(const std::string& msg) {
boost::lock_guard<boost::mutex> guard(m_mutex);
std::set<connection_ptr>::iterator it;
for (it = m_connections.begin(); it != m_connections.end(); it++) {
(*it)->send(msg);
}
return m_done;
}
// register a new client
void on_open(connection_ptr con) {
boost::lock_guard<boost::mutex> guard(m_mutex);
m_connections.insert(con);
}
// remove an exiting client
void on_close(connection_ptr con) {
boost::lock_guard<boost::mutex> guard(m_mutex);
m_connections.erase(con);
}
private:
bool m_done;
size_t m_value;
std::set<connection_ptr> m_connections;
boost::mutex m_mutex; // guards m_connections
boost::shared_ptr<boost::thread> m_telemetry_thread;
};
int main(int argc, char* argv[]) {
unsigned short port = 9007;
if (argc == 2) {
port = atoi(argv[1]);
if (port == 0) {
std::cout << "Unable to parse port input " << argv[1] << std::endl;
return 1;
}
}
try {
server::handler::ptr handler(new telemetry_server_handler());
server endpoint(handler);
endpoint.alog().unset_level(websocketpp::log::alevel::ALL);
endpoint.elog().unset_level(websocketpp::log::elevel::ALL);
endpoint.alog().set_level(websocketpp::log::alevel::CONNECT);
endpoint.alog().set_level(websocketpp::log::alevel::DISCONNECT);
endpoint.elog().set_level(websocketpp::log::elevel::RERROR);
endpoint.elog().set_level(websocketpp::log::elevel::FATAL);
std::cout << "Starting WebSocket telemetry server on port " << port << std::endl;
endpoint.listen(port);
} catch (std::exception& e) {
std::cerr << "Exception: " << e.what() << std::endl;
}
return 0;
}
+1 -1
View File
@@ -11,7 +11,7 @@ ifneq ($(OS), Darwin)
LDFLAGS := $(LDFLAGS) -lrt -lpthread
endif
wsperf: wsperf.o request.o case.o generic.o wscmd.o
wsperf: wsperf.o request.o case.o generic.o wscmd.o stress_aggregate.o stress_handler.o
$(CXX) $(CFLAGS) $^ -o $@ $(LDFLAGS)
%.o: %.cpp
+9 -7
View File
@@ -12,15 +12,17 @@ sources = ["wsperf.cpp",
"request.cpp",
"case.cpp",
"generic.cpp",
"stress_handler.cpp",
"stress_aggregate.cpp",
"wscmd.cpp"]
LIBS = [wslib, platform_libs] + boostlibs(['system',
'date_time',
'regex',
'thread',
'random',
'chrono',
'program_options'])
LIBS = [wslib] + boostlibs(['system',
'date_time',
'regex',
'thread',
'random',
'chrono',
'program_options']) + [platform_libs]
prg = localenv.Program('wsperf', sources, LIBS = LIBS)
+5 -1
View File
@@ -72,7 +72,11 @@ public:
void on_timer(connection_ptr con,const boost::system::error_code& error);
void on_close(connection_ptr con) {}
void on_close(connection_ptr con) {
con->alog()->at(websocketpp::log::alevel::DEVEL)
<< "case_handler::on_close"
<< websocketpp::log::endl;
}
void on_fail(connection_ptr con);
const std::string& get_data() const;
File diff suppressed because it is too large Load Diff
-76
View File
@@ -1,76 +0,0 @@
Frequently asked questions
--------------------------
Q: How much data can Flot cope with?
A: Flot will happily draw everything you send to it so the answer
depends on the browser. The excanvas emulation used for IE (built with
VML) makes IE by far the slowest browser so be sure to test with that
if IE users are in your target group.
1000 points is not a problem, but as soon as you start having more
points than the pixel width, you should probably start thinking about
downsampling/aggregation as this is near the resolution limit of the
chart anyway. If you downsample server-side, you also save bandwidth.
Q: Flot isn't working when I'm using JSON data as source!
A: Actually, Flot loves JSON data, you just got the format wrong.
Double check that you're not inputting strings instead of numbers,
like [["0", "-2.13"], ["5", "4.3"]]. This is most common mistake, and
the error might not show up immediately because Javascript can do some
conversion automatically.
Q: Can I export the graph?
A: This is a limitation of the canvas technology. There's a hook in
the canvas object for getting an image out, but you won't get the tick
labels. And it's not likely to be supported by IE. At this point, your
best bet is probably taking a screenshot, e.g. with PrtScn.
Q: The bars are all tiny in time mode?
A: It's not really possible to determine the bar width automatically.
So you have to set the width with the barWidth option which is NOT in
pixels, but in the units of the x axis (or the y axis for horizontal
bars). For time mode that's milliseconds so the default value of 1
makes the bars 1 millisecond wide.
Q: Can I use Flot with libraries like Mootools or Prototype?
A: Yes, Flot supports it out of the box and it's easy! Just use jQuery
instead of $, e.g. call jQuery.plot instead of $.plot and use
jQuery(something) instead of $(something). As a convenience, you can
put in a DOM element for the graph placeholder where the examples and
the API documentation are using jQuery objects.
Depending on how you include jQuery, you may have to add one line of
code to prevent jQuery from overwriting functions from the other
libraries, see the documentation in jQuery ("Using jQuery with other
libraries") for details.
Q: Flot doesn't work with [insert name of Javascript UI framework]!
A: The only non-standard thing used by Flot is the canvas tag;
otherwise it is simply a series of absolute positioned divs within the
placeholder tag you put in. If this is not working, it's probably
because the framework you're using is doing something weird with the
DOM, or you're using it the wrong way.
A common problem is that there's display:none on a container until the
user does something. Many tab widgets work this way, and there's
nothing wrong with it - you just can't call Flot inside a display:none
container as explained in the README so you need to hold off the Flot
call until the container is actually displayed (or use
visibility:hidden instead of display:none or move the container
off-screen).
If you find there's a specific thing we can do to Flot to help, feel
free to submit a bug report. Otherwise, you're welcome to ask for help
on the forum/mailing list, but please don't submit a bug report to
Flot.
-22
View File
@@ -1,22 +0,0 @@
Copyright (c) 2007-2009 IOLA and Ole Laursen
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
-9
View File
@@ -1,9 +0,0 @@
# Makefile for generating minified files
.PHONY: all
# we cheat and process all .js files instead of an exhaustive list
all: $(patsubst %.js,%.min.js,$(filter-out %.min.js,$(wildcard *.js)))
%.min.js: %.js
yui-compressor $< -o $@

Some files were not shown because too many files have changed in this diff Show More