protocol: make client-index implicit

This will enable us to unify the code in a later commit.

This is a protocol-breaking change, and means that matching editor
and player must be used.
This commit is contained in:
Erik Faye-Lund 2010-09-13 22:21:15 +02:00
parent 5bfd04f55b
commit 687df0876b
2 changed files with 6 additions and 9 deletions

View File

@ -561,9 +561,9 @@ SOCKET clientConnect(SOCKET serverSocket, sockaddr_in *host)
return clientSocket;
}
size_t clientIndex;
void processCommand(NetworkSocket &sock)
{
size_t clientIndex = 0;
int strLen, serverIndex, newRow;
std::string trackName;
const sync_track *t;
@ -572,9 +572,7 @@ void processCommand(NetworkSocket &sock)
switch (cmd) {
case GET_TRACK:
// read data
sock.recv((char *)&clientIndex, sizeof(int), 0);
sock.recv((char *)&strLen, sizeof(int), 0);
clientIndex = ntohl(clientIndex);
strLen = ntohl(strLen);
if (!sock.connected())
return;
@ -591,7 +589,7 @@ void processCommand(NetworkSocket &sock)
int(document.createTrack(trackName));
// setup remap
document.clientRemap[serverIndex] = clientIndex;
document.clientRemap[serverIndex] = clientIndex++;
// send key-frames
t = document.tracks[serverIndex];
@ -701,6 +699,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/,
SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)temp);
document.clientSocket = NetworkSocket(clientSocket);
document.clientRemap.clear();
clientIndex = 0;
document.sendPauseCommand(true);
document.sendSetRowCommand(trackView->getEditRow());
guiConnected = true;

View File

@ -157,15 +157,13 @@ void sync_save_tracks(const struct sync_device *d)
}
}
static int request_track_data(SOCKET sock, const char *name, uint32_t idx)
static int request_track_data(SOCKET sock, const char *name)
{
unsigned char cmd = GET_TRACK;
uint32_t name_len = htonl(strlen(name));
idx = htonl(idx);
/* send request data */
return xsend(sock, (char *)&cmd, 1, 0) ||
xsend(sock, (char *)&idx, sizeof(idx), 0) ||
xsend(sock, (char *)&name_len, sizeof(name_len), 0) ||
xsend(sock, name, (int)strlen(name), 0);
}
@ -223,7 +221,7 @@ static int purge_and_rerequest(struct sync_device *d)
d->data.tracks[i]->keys = NULL;
d->data.tracks[i]->num_keys = 0;
if (request_track_data(d->sock, d->data.tracks[i]->name, i))
if (request_track_data(d->sock, d->data.tracks[i]->name))
return 1;
}
return 0;
@ -318,7 +316,7 @@ const struct sync_track *sync_get_track(struct sync_device *d,
#if SYNC_PLAYER
load_track_data(t, sync_track_path(d->base, name));
#else
request_track_data(d->sock, name, idx);
request_track_data(d->sock, name);
#endif
return t;