PhantomSDR Support Forum

General Category => PhantomSDR Bugs => Topic started by: Bas ON5HB on Nov 10, 2024, 12:37 PM

Title: Something wrong with the chatbox...Chatbox code fix!!
Post by: Bas ON5HB on Nov 10, 2024, 12:37 PM
My websdr crashed this morning, and wouldn't restart.

Thank you for using PhantomSDR+, you are supporting the Development of an Open-Source WebSDR Project ♥
Using OpenCL
Using OpenCL platform: Intel(R) OpenCL Graphics
Using OpenCL device: Intel(R) HD Graphics 630
Markers updated.
Waterfall is sent every 1 FFTs
terminate called after throwing an instance of 'websocketpp::exception'
  what():  A payload contained invalid data
Afgebroken (geheugendump gemaakt)

Only after deleting chat.txt it would work again.


Title: Re: Something wrong with the chatbox...
Post by: Bas ON5HB on Nov 11, 2024, 02:39 PM
I went into the code and changed the number of chatlines from 100 to 20....let's see if it works, in src/chat.cpp

New code:

void ChatClient::store_chat_message(const std::string& message) {
    if(chat_messages_history.size() >= 20) {
        chat_messages_history.pop_front();
    }
    else
    chat_messages_history.push_back(message);
    save_chat_history();
}

and:

void ChatClient::load_chat_history() {
    std::ifstream file("chat_history.txt");
    std::string line;
    while (std::getline(file, line) && chat_messages_history.size() < 20) {
        chat_messages_history.push_back(line);
    }
    file.close();
}

Then go into build and run: ninja

As this should reduce the chat max messages to 20 instead of 100, I THINK the chat has too many characters for the websocket to cope.

With a little luck this will solve the crashing over chatting ;)

Title: Re: Something wrong with the chatbox...
Post by: Bas ON5HB on Nov 11, 2024, 03:12 PM
Have been testing and the code works...

Maybe you want to keep 100 lines....then only insert ELSE like in the first code and run ninja.

Because the ELSE was missing, it kept growing ;D
Title: Re: Something wrong with the chatbox...
Post by: Phil - NY4Q on Nov 11, 2024, 11:43 PM
I like the idea of only 20 lines of chat. Thanks Bas.
Title: Re: Something wrong with the chatbox...
Post by: Bas ON5HB on Nov 12, 2024, 11:28 AM
After 24 hours the chatbox-file is still 20 lines ;D
Title: Re: Something wrong with the chatbox...
Post by: magicint1337 on Nov 15, 2024, 11:16 AM
Will include this in the next commit / version