Skip to content

Commit

Permalink
remove trailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
zaphoyd committed Jul 21, 2013
1 parent df82891 commit c017331
Show file tree
Hide file tree
Showing 143 changed files with 3,602 additions and 3,602 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ if (BUILD_TESTS OR BUILD_EXAMPLES)
else ()
message (FATAL_ERROR "Failed to find required dependency: boost")
endif ()

find_package(OpenSSL)
endif()

Expand Down
8 changes: 4 additions & 4 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ modification, are permitted provided that the following conditions are met:
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
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.
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4 changes: 2 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ else:
print "C++11 build environment disabled"

# if the build system is known to allow the isystem modifier for library include
# values then use it for the boost libraries. Otherwise just add them to the
# values then use it for the boost libraries. Otherwise just add them to the
# regular CPPPATH values.
if env['CXX'].startswith('g++') or env['CXX'].startswith('clang'):
env.Append(CPPFLAGS = '-isystem ' + env['BOOST_INCLUDES'])
Expand All @@ -166,7 +166,7 @@ else:
env.Append(LIBPATH = [env['BOOST_LIBS']])

# if the build system is known to allow the isystem modifier for library include
# values then use it for the boost libraries. Otherwise just add them to the
# values then use it for the boost libraries. Otherwise just add them to the
# regular CPPPATH values.
if env_cpp11['CXX'].startswith('g++') or env_cpp11['CXX'].startswith('clang'):
env_cpp11.Append(CPPFLAGS = '-isystem ' + env_cpp11['BOOST_INCLUDES'])
Expand Down
4 changes: 2 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ HEAD
binary sizes.
- Updates handling of Server and User-Agent headers to better handle custom
settings and allow suppression of these headers for security purposes.
- Fix issue where pong timeout handler always fired. Thank you Steven Klassen
- Fix issue where pong timeout handler always fired. Thank you Steven Klassen
for reporting this bug.
- Add ping and pong endpoint wrapper methods
- Add `get_request()` pass through method to connection to allow calling methods
Expand All @@ -25,7 +25,7 @@ HEAD
0.3.0-alpha2 - 2013-06-09
- Fix a regression that caused servers being sent two close frames in a row
to end a connection uncleanly. #259
- Fix a regression that caused spurious frames following a legitimate close
- Fix a regression that caused spurious frames following a legitimate close
frames to erroneously trigger handlers. #258
- Change default HTTP response error code when no http_handler is defined from
500/Internal Server Error to 426/Upgrade Required
Expand Down
34 changes: 17 additions & 17 deletions examples/associative_storage/associative_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,55 +20,55 @@ class print_server {
public:
print_server() : m_next_sessionid(1) {
m_server.init_asio();

m_server.set_open_handler(bind(&print_server::on_open,this,::_1));
m_server.set_close_handler(bind(&print_server::on_close,this,::_1));
m_server.set_message_handler(bind(&print_server::on_message,this,::_1,::_2));
}

void on_open(connection_hdl hdl) {
connection_data data;

data.sessionid = m_next_sessionid++;
data.name = "";

m_connections[hdl] = data;
}

void on_close(connection_hdl hdl) {
connection_data& data = get_data_from_hdl(hdl);
std::cout << "Closing connection " << data.name

std::cout << "Closing connection " << data.name
<< " with sessionid " << data.sessionid << std::endl;

m_connections.erase(hdl);
}

void on_message(connection_hdl hdl, server::message_ptr msg) {
connection_data& data = get_data_from_hdl(hdl);

if (data.name == "") {
data.name = msg->get_payload();
std::cout << "Setting name of connection with sessionid "
std::cout << "Setting name of connection with sessionid "
<< data.sessionid << " to " << data.name << std::endl;
} else {
std::cout << "Got a message from connection " << data.name
std::cout << "Got a message from connection " << data.name
<< " with sessionid " << data.sessionid << std::endl;
}
}

connection_data& get_data_from_hdl(connection_hdl hdl) {
auto it = m_connections.find(hdl);

if (it == m_connections.end()) {
// this connection is not in the list. This really shouldn't happen
// and probably means something else is wrong.
throw std::invalid_argument("No data available for session");
}

return it->second;
}

void run(uint16_t port) {
m_server.listen(port);
m_server.start_accept();
Expand All @@ -85,4 +85,4 @@ class print_server {
int main() {
print_server server;
server.run(9002);
}
}
42 changes: 21 additions & 21 deletions examples/broadcast_server/broadcast_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,31 @@ enum action_type {
struct action {
action(action_type t, connection_hdl h) : type(t), hdl(h) {}
action(action_type t, server::message_ptr m) : type(t), msg(m) {}

action_type type;
websocketpp::connection_hdl hdl;
server::message_ptr msg;
};

class broadcast_server {
public:
broadcast_server() {
// Initialize Asio Transport
m_server.init_asio();

// Register handler callbacks
m_server.set_open_handler(bind(&broadcast_server::on_open,this,::_1));
m_server.set_close_handler(bind(&broadcast_server::on_close,this,::_1));
m_server.set_message_handler(bind(&broadcast_server::on_message,this,::_1,::_2));
}

void run(uint16_t port) {
// listen on specified port
m_server.listen(port);

// Start the server accept loop
m_server.start_accept();

// Start the ASIO io_service run loop
try {
m_server.run();
Expand All @@ -71,23 +71,23 @@ class broadcast_server {
std::cout << "other exception" << std::endl;
}
}

void on_open(connection_hdl hdl) {
unique_lock<mutex> lock(m_action_lock);
//std::cout << "on_open" << std::endl;
m_actions.push(action(SUBSCRIBE,hdl));
lock.unlock();
m_action_cond.notify_one();
}

void on_close(connection_hdl hdl) {
unique_lock<mutex> lock(m_action_lock);
//std::cout << "on_close" << std::endl;
m_actions.push(action(UNSUBSCRIBE,hdl));
lock.unlock();
m_action_cond.notify_one();
}

void on_message(connection_hdl hdl, server::message_ptr msg) {
// queue message up for sending by processing thread
unique_lock<mutex> lock(m_action_lock);
Expand All @@ -96,20 +96,20 @@ class broadcast_server {
lock.unlock();
m_action_cond.notify_one();
}

void process_messages() {
while(1) {
unique_lock<mutex> lock(m_action_lock);

while(m_actions.empty()) {
m_action_cond.wait(lock);
}

action a = m_actions.front();
m_actions.pop();

lock.unlock();

if (a.type == SUBSCRIBE) {
unique_lock<mutex> lock(m_connection_lock);
m_connections.insert(a.hdl);
Expand All @@ -118,7 +118,7 @@ class broadcast_server {
m_connections.erase(a.hdl);
} else if (a.type == MESSAGE) {
unique_lock<mutex> lock(m_connection_lock);

con_list::iterator it;
for (it = m_connections.begin(); it != m_connections.end(); ++it) {
m_server.send(*it,a.msg);
Expand All @@ -130,11 +130,11 @@ class broadcast_server {
}
private:
typedef std::set<connection_hdl,std::owner_less<connection_hdl>> con_list;

server m_server;
con_list m_connections;
std::queue<action> m_actions;

mutex m_action_lock;
mutex m_connection_lock;
condition_variable m_action_cond;
Expand All @@ -143,15 +143,15 @@ class broadcast_server {
int main() {
try {
broadcast_server server;

// Start a thread to run the processing loop
thread t(bind(&broadcast_server::process_messages,&server));

// Run the asio loop with the main thread
server.run(9002);

t.join();

} catch (std::exception & e) {
std::cout << e.what() << std::endl;
}
Expand Down
Loading

0 comments on commit c017331

Please sign in to comment.