by greeniekin
on 12/23/2014 01:05, 1 messages, last message: 12/23/2014 07:55, 1176 views, last view: 04/17/2024 22:51 |
I been playing with modifying cube2.
I am able to send my custom message and receive it though it has variable size data. when i send a message it's encoded size is 41. when I receive on the other side I get the size is 41 though when i check p.length() it is only 2 when it should be at least 11(because 41char/int32). If i keep try and reading the server disconnects with an error"disconnecting(message error)..."
I can not understand why this is not working.
I have been using the following to send a custom message from client.
int transSize=((encodedSize+3)/sizeof(int));
addmsg(N_TEAMTALK, "riv",(int)encodedSize, transSize, &(data[0]));
data is an unsigned char array encodedSize is the data length.
on the server i use this
case N_TEAMTALK:
{
int sampleCount = getint(p);
conoutf(CON_GAMEINFO, "f2teamtalk %d %d!",p.length(),sampleCount);
int* samples = new int[(sampleCount+4)/sizeof(int)];
int i=0;
loopk(sampleCount/sizeof(int))
{
samples[i++]=getint(p);
}
delete[] samples;
break;
}
|