Skip to content

Commit

Permalink
rename echo_client to testee client to better reflect its role
Browse files Browse the repository at this point in the history
  • Loading branch information
zaphoyd committed Jul 14, 2013
1 parent 2964acd commit a9f3821
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 54 deletions.
42 changes: 6 additions & 36 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -203,21 +203,21 @@ if not env['PLATFORM'].startswith('win'):
# Main test application
#main = SConscript('#/examples/dev/SConscript',variant_dir = builddir + 'dev',duplicate = 0)

# testee_server
testee_server = SConscript('#/examples/testee_server/SConscript',variant_dir = builddir + 'testee_server',duplicate = 0)

# echo_server
echo_server = SConscript('#/examples/echo_server/SConscript',variant_dir = builddir + 'echo_server',duplicate = 0)

# echo_server_tls
if not env['PLATFORM'].startswith('win'):
if tls_build:
echo_server_tls = SConscript('#/examples/echo_server_tls/SConscript',variant_dir = builddir + 'echo_server_tls',duplicate = 0)

# broadcast_server
broadcast_server = SConscript('#/examples/broadcast_server/SConscript',variant_dir = builddir + 'broadcast_server',duplicate = 0)

# echo_client
echo_client = SConscript('#/examples/echo_client/SConscript',variant_dir = builddir + 'echo_client',duplicate = 0)
# testee_server
testee_server = SConscript('#/examples/testee_server/SConscript',variant_dir = builddir + 'testee_server',duplicate = 0)

# testee_client
testee_client = SConscript('#/examples/testee_client/SConscript',variant_dir = builddir + 'testee_client',duplicate = 0)

# utility_client
utility_client = SConscript('#/examples/utility_client/SConscript',variant_dir = builddir + 'utility_client',duplicate = 0)
Expand All @@ -234,33 +234,3 @@ if not env['PLATFORM'].startswith('win'):

# print_server
print_server = SConscript('#/examples/print_server/SConscript',variant_dir = builddir + 'print_server',duplicate = 0)

#
#wsperf = SConscript('#/examples/wsperf/SConscript',
# variant_dir = builddir + 'wsperf',
# duplicate = 0)

#echo_server = SConscript('#/examples/echo_server/SConscript',
# variant_dir = builddir + 'echo_server',
# 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',
# duplicate = 0)

#chat_client = SConscript('#/examples/chat_client/SConscript',
# variant_dir = builddir + 'chat_client',
# duplicate = 0)

#chat_server = SConscript('#/examples/chat_server/SConscript',
# variant_dir = builddir + 'chat_server',
# duplicate = 0)

#concurrent_server = SConscript('#/examples/concurrent_server/SConscript',
# variant_dir = builddir + 'concurrent_server',
# duplicate = 0)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)

init_target (echo_client)
init_target (testee_client)

build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Main development example
## Autobahn test client example
##

Import('env')
Expand All @@ -15,9 +15,9 @@ prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs]
prgs += env_cpp11.Program('echo_client', ["echo_client.cpp"], LIBS = ALL_LIBS)
prgs += env_cpp11.Program('testee_client', ["testee_client.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system','random'],env) + [platform_libs] + [polyfill_libs]
prgs += env.Program('echo_client', ["echo_client.cpp"], LIBS = ALL_LIBS)
prgs += env.Program('testee_client', ["testee_client.cpp"], LIBS = ALL_LIBS)

Return('prgs')
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ void on_message(client* c, websocketpp::connection_hdl hdl, message_ptr msg) {
client::connection_ptr con = c->get_con_from_hdl(hdl);

if (con->get_resource() == "/getCaseCount") {
std::cout << "Detected " << msg->get_payload() << " test cases." << std::endl;
std::cout << "Detected " << msg->get_payload() << " test cases."
<< std::endl;
case_count = atoi(msg->get_payload().c_str());
} else {
c->send(hdl, msg->get_payload(), msg->get_opcode());
Expand All @@ -28,7 +29,7 @@ void on_message(client* c, websocketpp::connection_hdl hdl, message_ptr msg) {

int main(int argc, char* argv[]) {
// Create a server endpoint
client echo_client;
client c;

std::string uri = "ws://localhost:9001";

Expand All @@ -38,36 +39,37 @@ int main(int argc, char* argv[]) {

try {
// We expect there to be a lot of errors, so suppress them
echo_client.clear_access_channels(websocketpp::log::alevel::all);
echo_client.clear_error_channels(websocketpp::log::elevel::all);
c.clear_access_channels(websocketpp::log::alevel::all);
c.clear_error_channels(websocketpp::log::elevel::all);

// Initialize ASIO
echo_client.init_asio();
c.init_asio();

// Register our handlers
echo_client.set_message_handler(bind(&on_message,&echo_client,::_1,::_2));
c.set_message_handler(bind(&on_message,&c,::_1,::_2));

websocketpp::lib::error_code ec;
client::connection_ptr con = echo_client.get_connection(uri+"/getCaseCount", ec);
echo_client.connect(con);
client::connection_ptr con = c.get_connection(uri+"/getCaseCount", ec);
c.connect(con);

// Start the ASIO io_service run loop
echo_client.run();
c.run();

std::cout << "case count: " << case_count << std::endl;

for (int i = 1; i <= case_count; i++) {
echo_client.reset();
c.reset();

std::stringstream url;

url << uri << "/runCase?case=" << i << "&agent=" << websocketpp::user_agent;
url << uri << "/runCase?case=" << i << "&agent="
<< websocketpp::user_agent;

con = echo_client.get_connection(url.str(), ec);
con = c.get_connection(url.str(), ec);

echo_client.connect(con);
c.connect(con);

echo_client.run();
c.run();
}

std::cout << "done" << std::endl;
Expand Down

0 comments on commit a9f3821

Please sign in to comment.