Page 1 of 1
Вопросы по сети и многопоточности (пишу небольшой xmpp-клиент)
Posted: Mon May 25, 2015 9:47 pm
by upcFrost
Заранее извиняюсь за глупые вопросы. Пишу небольшой xmpp-клиент, слегка просел на получении сообщений. Собственно, окно для сообщений делаю отдельным потоком. Как я понял, эвент network получает именно родительский поток, а не дочерний. Есть ли какой-нибудь вариант чтоб его проверяли сразу оба потока (ну или хоть IPC, хотя имхо костыль будет)? Или проще сделать одно окно ростер+сообщения и не парить себе мозг? Просто не слишком хочется переносить куски логики для сообщений в логику ростера, да и скайпообразный интерфейс не слишком нравится.
И второй вопрос по box_lib. Ввиду отсутствия половины манов тыкаю наугад, есть ли способ чтоб text_edit выглядел не слишком вырвиглазо? Вид TinyPad намного лучше, но там рисование идет вручную.
upd.: и еще про отладку - умеет ли mtdbg с потоками работать?
Re: Сеть и многопоточность
Posted: Mon May 25, 2015 10:26 pm
by hidnplayr
Welcome to the forums,
Unfortunately, I could not understand all your questions (google translate's Russian is bad, and my own is even worse.)
Threads and processes in KolibriOS are the same thing, so it's not possible to have one process with multiple threads as in linux/windows.
Socket functions only work properly in the thread where the socket was opened.
If you don't need multiple windows, it might be best to use non-blocking sockets, and run everything in one thread.
Perhaps you can borrow some code of the IRC client for your XMPP experiments.
Good luck!
Re: Сеть и многопоточность
Posted: Mon May 25, 2015 10:34 pm
by upcFrost
thx, so it's better to use 1 thread/window. That's a bit sad but ok, i was trying to make it with multiple windows like pidgin or old skype.
the second question was about t_edit from box_lib. Because of lack of docs i'm just poking it randomly, and the question was is there any way to make it look a bit better. TinyPad looks good, but it uses pure canvas drawing (and i'm afraid that'd be too much for me to handle).
the third question was about mtdbg and threads, but since i'll try to convert everything into 1 thread, it doesn't matter now.
Re: Сеть и многопоточность
Posted: Mon May 25, 2015 10:51 pm
by hidnplayr
It's certainly possible to run with multiple windows later. But I would use only one thread for the first version(s), for simplicity.
For box lib, there is the text and html documentation in source code tree. (
http://websvn.kolibrios.org/listing.php ... box_lib%2F)
There is also this page on the wiki:
http://wiki.kolibrios.org/wiki/Box_lib/ru and countless examples on SVN ofcourse.
Please, bare in mind that textbox in box_lib has no multi-line support. (That's why I wrote my own multi-line, multi-color, read-only text box in IRC client.)
I'm not sure about thread support in MTDBG, so will not answer that question at this point.
Re: Сеть и многопоточность
Posted: Mon May 25, 2015 11:00 pm
by upcFrost
The man i'm using for t_edit is the one from svn. Not the best one, maybe, but still useful, at least it's possible to use source if in doubt. Also, it's t_edit, not editbox, so it can handle multiline, and its input can be easily pruned down to arrows/ctrl+c. The only problem is how it looks

Actually, right now sending messages works ok (or 90% ok).
About windows - is there any way to make second window in one process? Or it's just 1 process == 1 window?
Re: Сеть и многопоточность
Posted: Mon May 25, 2015 11:06 pm
by hidnplayr
Oh okay. I have not worked with t_edit so cannot help you with that, but it should work with multiline indeed.
There is only one window per process possible. Unfortunately.
Re: Сеть и многопоточность
Posted: Mon May 25, 2015 11:10 pm
by upcFrost
ok, thx for help

maybe i'll still try ipc, like if one logic chain fails to parse the query, it just calls yet another logic chain over ipc.