안녕하세요
전자 칠판에 서버와 클라이언트 간에 메모를 주고 받는 기능을 만들고 있습니다.
텍스트를 천천히 치면 문제가 없는데 빠르게 칠 경우
텍스트를 받는 쪽 메모에 보낸 텍스트가 중복되어 나타나는 현상이 일어납니다.
어떻게 하면 해결할 수 있을까요?
예를 들면
보낸 메세지:
abcdefg
받은 메세지:
abcdefgabcdefabcde
이런 식으로 보입니다
//---------------------------------------------------------------------------
void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender, TCustomWinSocket *Socket) //클라이언트로부터 메세지 수신
{
int i;
AnsiString Read, Prot;
Prot=Read.SubString(1, 2);
Read=Read.Delete(1, 2);
if (Prot=="02")
{
Memo1->Text=Read;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Memo1KeyPress(TObject *Sender, System::WideChar &Key) //텍스트 보낼 때
{
if (write==0)
{
for (int i = 0; i < Client_Number; i++) {
ServerSocket1->Socket->Connections[i]->SendText("02"+Memo1->Text);
}
}
}
|