Jump to content

Collaborative editing over TCP


Recommended Posts

hi, i have been thinking lately of doing something that would enable multiple clients to work together on something, their geographical locations not being a constraint . I would like to have perhaps a textbox where a client would write something and the same text would appear simultaneously over the other clients , letter by letter . now if some other user changes somethng on their client , the change would be reflected globally . Somewhat like collaborative editing stuff. I managed to do 1) make two gui's and write text on one and see that in the other and have realtime editing capability in them . All these without implementing tcp .

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
$hWnd=GUICreate("Realtime Editing",400,300,-1)
$hInputEdit=GUICtrlCreateEdit("",0,0,400,150,$ES_WANTRETURN)

GUISetState(@SW_SHOW)
$hWnd2=GUICreate("Test Client",400,300,-1)
$hInputEdit2=GUICtrlCreateEdit("",0,0,400,150,$ES_WANTRETURN)
GUIRegisterMsg($WM_COMMAND,"WM_COMMAND")
GUISetState(@SW_SHOW)

Do
$msg=GUIGetMsg()
Until $msg=$GUI_EVENT_close


Func WM_COMMAND($hWinHandle,$iMsg,$wParam,$lParam)

If _WinAPI_HiWord($wParam)=$EN_CHANGE And _WINAPI_LoWord($wParam)=$hInputEdit Then
  $bEdited=(GUICtrlRead($hInputEdit))
  GUICtrlSetData($hInputEdit2,$bEdited)

EndIf
If _WinAPI_HiWord($wParam)=$EN_CHANGE And _WINAPI_LoWord($wParam)=$hInputEdit2 Then
  $bEdited=(GUICtrlRead($hInputEdit2))
  GUICtrlSetData($hInputEdit,$bEdited)

EndIf
EndFunc

When i tried using the same principle using a simple server client i get a different result .

Suppose i type "test" in one textarea. The other client over the tcp displays the text as

t

te

tes

test

not quite what i want . Can someone suggest any ideas or show an example snippet on how to emplement that ? or maybe redirect me to some post where a thing such as this has been implemented (i didnt find any) .?

Thanks in advance :D

Edited by DarkAngel
Link to comment
Share on other sites

Darkangel,

Without seeing your code for the TCP solution I am going to guess that you need to read the entire TCP buffer before you update the edit control. The example that you posted appears to be updating the edit control, character by character, with a concatenation of the TCP stream.

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

DarkAngel,

Should really see example of the code...this seems to be a synchronization problem (e.g. when variables are updated/cleared, when edit controls are read/updated, etc)

You may want to look at a couple of the "chat" examples on this board...

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...