diff --git a/examples/broadcast_server_tls/broadcast_admin.html b/examples/broadcast_server_tls/broadcast_admin.html
index 6024cc175c..0e6c917278 100644
--- a/examples/broadcast_server_tls/broadcast_admin.html
+++ b/examples/broadcast_server_tls/broadcast_admin.html
@@ -50,11 +50,11 @@ function connect() {
ws.onclose = function(e) {
document.getElementById("messages").innerHTML += "Client: The connection to "+url+" was closed.
";
- clear_hud()
+ clear_hud();
};
ws.onmessage = function(e) {
- foo = JSON.parse(e.data);
+ foo = JSON.parse(e.data);
if (foo.type == "message") {
if (options.console_enabled) {
@@ -63,13 +63,12 @@ function connect() {
} else if (foo.type == "con") {
document.getElementById("connected_clients").innerHTML = foo.value;
} else if (foo.type == "stats") {
- console.log(foo);
for (var i in foo.messages) {
var hash = foo.messages[i].hash;
if (hash in msgs) {
- msgs[hash]["sent"] += foo.messages[i].sent;
- msgs[hash]["acked"] += foo.messages[i].acked;
+ msgs[hash]["sent"] = foo.messages[i].sent;
+ msgs[hash]["acked"] = foo.messages[i].acked;
msgs[hash]["time"] = foo.messages[i].time;
} else {
msgs[hash] = {"id":foo.messages[i].id,
@@ -80,13 +79,13 @@ function connect() {
}
}
- var foo = "";
+ var o = "";
for (i in msgs) {
- foo += "
| "+msgs[i].id+" | "+msgs[i].sent+" | "+msgs[i].acked+" | "+msgs[i].size+" | "+msgs[i].time+" |
";
+ o += "| "+msgs[i].id+" | "+msgs[i].sent+" | "+msgs[i].acked+" | "+format_data(msgs[i].size)+" | "+msgs[i].time+" | "+(msgs[i].time != 0 ? (msgs[i].acked/(msgs[i].time/1000.0)).toFixed(0)+"/s" : "")+" | "+(msgs[i].time != 0 ? format_data(msgs[i].acked*msgs[i].size/(msgs[i].time/1000.0))+"/s" : "")+" |
";
}
- $("#sent_messages").html(foo);
+ $("#sent_messages").html(o);
/*document.getElementById("messages_per_sec").innerHTML = foo.messages+"/s";
document.getElementById("bytes_per_sec").innerHTML = format_data(foo.bytes)+"/s";
@@ -94,13 +93,16 @@ function connect() {
document.getElementById("messages_acked").innerHTML = foo.messages_acked;
document.getElementById("bytes_sent").innerHTML = format_data(foo.bytes_sent);*/
+
document.getElementById("admin_connections").innerHTML = foo.admin_connections;
+ document.getElementById("connected_clients").innerHTML = foo.connections;
client_history.push([foo.timestamp,foo.connections]);
if (client_history.length > total_points) {
client_history = client_history.slice(client_history.length-total_points);
}
+
/*data2.push([foo.timestamp,foo.bytes]);
if (data2.length > total_points) {
data2 = data2.slice(data2.length-total_points);
@@ -279,7 +281,7 @@ body,html {
- | id | sent | acked | size | time |
+ | id | sent | acked | size | time | message rate | data rate |
diff --git a/examples/broadcast_server_tls/broadcast_server_tls.cpp b/examples/broadcast_server_tls/broadcast_server_tls.cpp
index d1583d1e2a..ae1dffcd7c 100644
--- a/examples/broadcast_server_tls/broadcast_server_tls.cpp
+++ b/examples/broadcast_server_tls/broadcast_server_tls.cpp
@@ -95,9 +95,9 @@ public:
}
void on_open(connection_ptr connection) {
- if (!m_timer) {
+ if (!m_timer) {
m_timer.reset(new boost::asio::deadline_timer(connection->get_io_service(),boost::posix_time::seconds(0)));
- m_timer->expires_from_now(boost::posix_time::milliseconds(1000));
+ m_timer->expires_from_now(boost::posix_time::milliseconds(500));
m_timer->async_wait(boost::bind(&type::on_timer,this,boost::asio::placeholders::error));
m_last_time = boost::posix_time::microsec_clock::local_time();
}
@@ -108,7 +108,7 @@ public:
m_connections.insert(connection);
}
- typename std::set::iterator it;
+ /*typename std::set::iterator it;
std::stringstream foo;
foo << "{\"type\":\"con\""
@@ -118,7 +118,7 @@ public:
for (it = m_admin_connections.begin(); it != m_admin_connections.end(); it++) {
(*it)->send(foo.str(),false);
- }
+ }*/
}
void on_close(connection_ptr connection) {
@@ -126,7 +126,7 @@ public:
m_connections.erase(connection);
m_admin_connections.erase(connection);
- typename std::set::iterator it;
+ /*typename std::set::iterator it;
std::stringstream foo;
foo << "{\"type\":\"con\""
@@ -136,7 +136,7 @@ public:
for (it = m_admin_connections.begin(); it != m_admin_connections.end(); it++) {
(*it)->send(foo.str(),false);
- }
+ }*/
}
@@ -207,7 +207,8 @@ public:
std::map::iterator it = m_msgs.find(hash);
if (it == m_msgs.end()) {
- std::cout << "ack for message we didn't send" << std::endl;
+ std::cout << "ack for message we didn't send: " << hash
+ << "(" << hash.size() << ")" << std::endl;
return;
}
@@ -347,12 +348,12 @@ public:
<< ",\"acked\":" << (*msg_it).second.acked
<< ",\"size\":" << (*msg_it).second.size
<< ",\"time\":" << (*msg_it).second.time
- << "}";
+ << "}" << (msg_it == last ? "" : ",");
}
foo << "]}";
- m_msgs.clear();
+ //m_msgs.clear();
//<< ((m_messages_cache * seconds)*1000) << ",\"data\":"
//<< ((m_data_cache * seconds)*1000) << ",\"messages_sent\":"
@@ -368,7 +369,7 @@ public:
//m_data = 0;
//}
- m_timer->expires_from_now(boost::posix_time::milliseconds(1000));
+ m_timer->expires_from_now(boost::posix_time::milliseconds(500));
m_timer->async_wait(boost::bind(&type::on_timer,this,boost::asio::placeholders::error));
}
@@ -391,7 +392,7 @@ private:
int m_nextid;
std::map m_msgs;
-
+
std::set m_connections;
std::set m_admin_connections;
};