Re: LyX Chat
Tommaso Cucinotta <tommaso <at> lyx.org>
2012-01-02 09:18:59 GMT
Il 28/12/2011 23:23, Tommaso Cucinotta ha scritto:
> Il 28/12/2011 19:31, Pavel Sanda ha scritto:
>> how hard would it be to enhance your patch so collaborate editing of
>> lyx document is possible?
>
> I thought to this just a little: from my patch, we can merely reuse the
> socket set-up and non-blocking polling structure for avoiding multiple
> threads. However, the structure of a collaborative editor should be
> quite different, as instead of transmitting document fragments, it
> should actually transmit users' actions.
>
> Luckily, LyX has a quite enforced separation between the GUI and
> the model, i.e., the (in)famous LFUN dispatching mechanism. Therefore,
> what is needed is simply a "RemoteView", with a client and a server part.
> The client part, instead of (or in addition to) dispatching the LFUN to
> the local view, serializes the whole LFUN (let's neglect commands
> inserting external material such as graphics, for now) through the
> socket,
> where the server part will periodically poll other user's LFUNs and
> dispatch actually them to the local view (local to the remote user
).
> This way you would have the
> user acting on his/her own local document, and the remote user
> copying the same actions on his/her own remote document.
>
> I'm only thinking to 2 users, not 3 or more, but the logic should not be
> that different.
If you want to see just a preliminary hack that kind of works, please,
find it attached.
The BufferView has been extended so as to allow for incoming connections
from a remote LyX instance, as well as to connect to a remote LyX instance.
All LFUNs dispatched to the view are also copied to the remote instance, and
any LFUN coming from it is dispatched locally.
In order to try the patch, you need to:
1) launch LyX, and create a new buffer
2) issue the "collaborate-bind 8888" command in the mini-buffer (8888 is
the TCP port, you can use whatever you prefer)
3) launch another LyX, and create a new buffer
4) issue the "collaborate-connect 127.0.0.1 8888" command in the
mini-buffer (change destination host and port as needed)
Now the two views are kept synchronized, i.e., any LFUN dispatched to
one of them is forwarded to the other.
I don't pretend the design to be anyway correct, just a hack made for
fun
.
While working on it, some weird things happens to fall under my eyes,
such as why in GuiView there is this
dispatchToBufferView() method that tries to dispatch to the buffer view
and after to its cursor, but why
doesn't the BufferView::dispatch() method itself dispatch to its own
cursor ?
Btw, any comment is welcome.
T.
ps: happy new year !!!!!