Fixed some stuff

This commit is contained in:
WolverinDEV 2019-07-19 22:16:27 +02:00
parent 5c41277871
commit 26007a51c4
2 changed files with 10 additions and 4 deletions

View File

@ -487,13 +487,17 @@ void ServerConnection::send_voice_data(const void *buffer, size_t buffer_length,
if(head) /* head packet */
packet->enable_flag(ts::protocol::PacketFlag::Compressed);
this->protocol_handler->send_packet(packet);
if((rand() % 10) < 2) {
log_info(category::connection, tr("Dropping voice packet"));
} else {
this->protocol_handler->send_packet(packet);
}
}
void ServerConnection::close_connection() {
if(this_thread::get_id() == this->socket->io_thread().get_id()) {
lock_guard lock(this->disconnect_lock);
if(this->socket && this_thread::get_id() == this->socket->io_thread().get_id()) {
logger::debug(category::connection, tr("close_connection() called in IO thread. Closing connection within event loop!"));
lock_guard lock(this->disconnect_lock);
if(!this->event_loop_execute_connection_close) {
this->event_loop_execute_connection_close = true;
this->event_condition.notify_one();
@ -501,7 +505,6 @@ void ServerConnection::close_connection() {
return;
}
lock_guard lock(this->disconnect_lock);
this->event_loop_execute_connection_close = false;
if(this->socket) {
this->socket->finalize();

View File

@ -147,6 +147,7 @@ const do_connect = () => {
};
consumer.callback_data = buffer => {
console.log("Sending voice data");
connection.send_voice_data_raw(buffer, consumer.channels, consumer.sample_rate, true);
//stream.write_data_rated(buffer.buffer, true, consumer.sample_rate);
};
@ -177,9 +178,11 @@ setInterval(() => {
global.gc();
}, 1000);
let a_map = [consumer, recorder];
/* keep the object alive */
setTimeout(() => {
connection.connected();
a_map = a_map.filter(e => true);
}, 1000);
connection_list.push(connection);