Jump to content

Перебор всех подключений


Dinkin

Recommended Posts

Добрый день.

В TUniMainModule в private у меня есть переменная id_user, могу ли я как то из TUniServerModule сделать перебор всех соединений с определенным id и запустить на них какую либо функцию из TUniMainModule 

Этим я хочу инициировать со стороны сервера событие у подключения.

Link to comment
Share on other sites

Если я правильно понял вопрос, то лучше знать ID сессии и по нем искать:

var Session := UniServerModule.GetSession(SessionID);
var MainModule := TUniMainModule(Session.UniApplication.UniMainModule);
 

  • Like 1
Link to comment
Share on other sites

Спасибо!

А могу лия таким образом обращаться с TUniMainModule одной сессии к другим TUniMainModule ? или всё-таки луче это делать через TUniServerModule ?

Link to comment
Share on other sites

10 hours ago, Dinkin said:

Спасибо!

А могу лия таким образом обращаться с TUniMainModule одной сессии к другим TUniMainModule ? или всё-таки луче это делать через TUniServerModule ?

Пробуй. Скорее всего будет работать.

  • Like 1
Link to comment
Share on other sites

В свою сессию отлично создается панелька на главной форме, а в чужие сессии ошибка. Может есть правило для работы с компонентами в чужих сессиях?

Link to comment
Share on other sites

На форме в Memo  у меня ключи сессий, хочу в каждой сессии создать по кнопке
 

void __fastcall TMainForm::UniButton1Click(TObject *Sender)
{
    for(int i = 0; i < UniMemo1->Lines->Count; ++i)
        {
            TUniMainModule *modul = static_cast<TUniMainModule*>(UniServerModule()->GetSession(UniMemo1->Lines->Strings[i])->UniMainModule);
            TMainForm *MainForm   = static_cast<TMainForm*>(modul->MainFormSender);

            TUniButton * button = new TUniButton(MainForm);
            button->Parent         = MainForm;
        }
}

, но создается только в текущей, в других выходит ошибка

error2.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...