1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
   |  
void __fastcall TScarboMainForm::ServeurExecute(TIdContext *AContext) {
	TByteDynArray pInfo;
	bool trouve = false;
	int nctx = 0;
	char chaine[256];
	TClientTCP *clx = NULL;
	try {
 
		while (!trouve && nctx < pClients->Count) {
			clx = (TClientScarbo*)pClients->Items[nctx];
			trouve = (clx->getContext() == AContext);
			nctx++;
		}
		if (trouve) {
			if (clx->getID() == 1 || clx->getID() == 2)
				AContext->Connection->IOHandler->ReadBytes(pInfo, 17440, false);
			if (clx->getID() == 3)
				AContext->Connection->IOHandler->ReadBytes(pInfo, 786688, false);
			if (clx->getID() == 0)
				AContext->Connection->IOHandler->ReadBytes(pInfo, 256, false);
 
			memcpy(chaine, &pInfo[0], 256);
			String lrep = "";
			int n = 0;
			while (n < 256 && chaine[n] != 0) {
				lrep += chaine[n];
				n++;
			}
			int deb = lrep.Pos("IDENTIFIANT");
			if (deb > 0) {
				String num = lrep.SubString(deb + 8, 1);
				int ref = num.ToInt();
				if (ref == 1 || ref == 2)
					clx->setDataBuff(64*64*4);
				if (ref == 3)
					clx->setDataBuff(512*512*4);
				clx->setID(ref);
				clx->setON(true);
				TThread::Synchronize(NULL, (TThreadMethod)&updateLed);
			}
			else {
				void *data = clx->getDataBuff();
				clx->setInfo(lrep);
				memcpy(data, &pInfo[256], clx->getTailleData());
				TThread::Synchronize(NULL, (TThreadMethod)&updateListe);
				TThread::Synchronize(NULL, (TThreadMethod)&updateImg);
			}
 
		}
	}
	catch (const Exception& e) {
		// AFAIRE
	}
} | 
Partager