Browse Source

change connection routines

master
Jørgen Lien Sellæg 9 years ago
parent
commit
c8ab73af86
  1. 4
      toREST/include/ws.hpp
  2. 4
      toREST/tests/ws_test.cpp

4
toREST/include/ws.hpp

@ -24,9 +24,7 @@ void on_close(Session &session, Connection con, int status, const std::string &r
template <class Server, class Session, class Connection> template <class Server, class Session, class Connection>
void on_open(Server &server, Session &session, Connection con) { void on_open(Server &server, Session &session, Connection con) {
if (session.is_valid()) { if (!session.is_valid()) {
session.post_torrent_updates();
} else {
server.send_close(con, status::unexpected, "Session not valid"); server.send_close(con, status::unexpected, "Session not valid");
} }
} }

4
toREST/tests/ws_test.cpp

@ -35,8 +35,8 @@ SCENARIO("we have a websocket resource") {
session.valid = true; session.valid = true;
WHEN("we open the connection") { WHEN("we open the connection") {
tr::ws::on_open(server, session, connection); tr::ws::on_open(server, session, connection);
THEN("the session should post torrent torrent updates") { THEN("the session should not post torrent torrent updates") {
REQUIRE(session.post_torrent_updates_calls_ == 1); REQUIRE(server.send_close_calls_ == 0);
} }
} }
} }

Loading…
Cancel
Save