Ho sviluppato un multiplayer dove i player collegati inviano strighe in continuazione del loro modello 3d agli altri player.
Quello che viene passato ai player è la Matrix del modello dove prendo la Matrix composta da 5 float che casto come stringa e li lego in una stringa finale da inviare ai client.
La matrix è per intenderci questa:
matBuffer[m]._11 con m che va da 0 fino a 5 e fino a matBuffer[m]._43 spero si comprenda cosa faccio.
La stringa è composta in questo modo:
stringa = "numeroPlayer=00000000=28002367"... ecc ecc fino all'ultima posizione della matrix.
Come arriva al client tramite stroke la splitto mi ricavo la matrix per il modello 3d e aggiorno la posizione del modello 3d sul cient che riceve.
Ecco questo funziona tutto soltanto che per inviare devo scomporre la matrix in stringa e quando ricevo devo ricomporre la matrix in float.
Stavo pensando di inviare i dati non per stringa ma per BYTE facendo:
byte=numeroPlayer | matbuffer... eliminando la conversione in stringa e la riconversione in matrix della stringa.
Per questo volevo sapere come inviare per BYTE e come ricevere e riprendere i byte trasmessi.
Vorrei provare questo meccanismo di invio per byte per vedere se il tutto sia + veloce.
Edit: dimenticavo la stringa è di 2048 char sempre fissa in + non si tratta di un gioco per esempio di battaglia navale dove il player può inviare una stringa di dati quando decide di farlo ma qui si tratta di inviare la matrix matBuffer del modello 3d in modo continuo agli altri client che ricevono dati in modo continuo...
questo è il codice per far capire cosa faccio:
--------code--------------
for(int m=0; m<6; m++){
swprintf(strMess1, L"%f", matBuffer[m]._11); lstrcat( strMotoMatrice, strMess1 ); lstrcat( strMotoMatrice, TEXT("=") );
swprintf(strMess1, L"%f", matBuffer[m]._12); lstrcat( strMotoMatrice, strMess1 ); lstrcat( strMotoMatrice, TEXT("=") );
swprintf(strMess1, L"%f", matBuffer[m]._13); lstrcat( strMotoMatrice, strMess1 ); lstrcat( strMotoMatrice, TEXT("=") );
swprintf(strMess1, L"%f", matBuffer[m]._21); lstrcat( strMotoMatrice, strMess1 ); lstrcat( strMotoMatrice, TEXT("=") );
swprintf(strMess1, L"%f", matBuffer[m]._22); lstrcat( strMotoMatrice, strMess1 ); lstrcat( strMotoMatrice, TEXT("=") );
swprintf(strMess1, L"%f", matBuffer[m]._23); lstrcat( strMotoMatrice, strMess1 ); lstrcat( strMotoMatrice, TEXT("=") );
swprintf(strMess1, L"%f", matBuffer[m]._31); lstrcat( strMotoMatrice, strMess1 ); lstrcat( strMotoMatrice, TEXT("=") );
swprintf(strMess1, L"%f", matBuffer[m]._32); lstrcat( strMotoMatrice, strMess1 ); lstrcat( strMotoMatrice, TEXT("=") );
swprintf(strMess1, L"%f", matBuffer[m]._33); lstrcat( strMotoMatrice, strMess1 ); lstrcat( strMotoMatrice, TEXT("=") );
swprintf(strMess1, L"%f", matBuffer[m]._41); lstrcat( strMotoMatrice, strMess1 ); lstrcat( strMotoMatrice, TEXT("=") );
swprintf(strMess1, L"%f", matBuffer[m]._42); lstrcat( strMotoMatrice, strMess1 ); lstrcat( strMotoMatrice, TEXT("=") );
swprintf(strMess1, L"%f", matBuffer[m]._43); lstrcat( strMotoMatrice, strMess1 ); lstrcat( strMotoMatrice, TEXT("=") );
}
TCHAR wszTest1[2048]=TEXT("#@_gioco_@#");
lstrcat( wszTest1, L"=" );
lstrcat( wszTest1, idS ); //id player
lstrcat( wszTest1, L"=" );
lstrcat( wszTest1, strMotoMatrice );
//invia dati come stringa
Okay(wszTest1);
--------end code----------
non vi sembra una stringa esagerata???? ...da inviare al server e poi smistare ai client??? ... i quali devono riscompattare la stringa e ricostruire la matrice???
Ecco pensavo invece di inviare tipo così:
stringa="id+matrice" in BYTE
ma non so se si può fare...