Hi!
Im trying to make c++ programs.
When my program starts, program creates 2 threads:
-- in first thread (LoginScreen class) goes main program loop. This loop has auth form with login and password field and submit button. When user clicked on button, the data by socket connection submitted to server program, by the way submit button translates to disabled status;
-- second thread needs to work with socket -- it listen socket, dispatch packets and handle them.
My problem -- I dont know how to forward the received packet about successful authorization to the LoginScreen.
Today I learned mediator pattern (
https://sourcemaking.com/design_patterns/mediator/cpp/1 ), but I dont know how implement it to my program -- when program has two threads and this parts so different.
I also think about static class like Singleton with getInstance method, but I can not imagine how, especially due to the fact that he has a lot of logic:
public:
LoginScreen();
virtual void onAttach() override;
virtual void onDetach() override;
void onUpdate() override;
void onEvent(Event& event) override;
What I need to do?