move line breaking logic from socket thread to room thread