Bulk-insert messages into the db (again)
This accidentally got slaughtered while moving to the new event backend. Now
messages are buffered in CoreSession until the event queue is empty, which means
that a bulk of incoming messages will completely be processed before inserting into
the database, resulting in a huge performance gain.
This buffers even more aggressive than the old version, as we process Qt events in between,
which means we'll receive and process any additional data from the socket before flushing the
message queue. The downside is that nothing will arrive in the client as long as your socket gets
flooded, but on the other hand, it will greatly reduce db I/O in such cases.