1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
/* le contexte */
// int len
// int bytes
// struct Packet { vector<byte> bytes; };
// char* substr(char*, int, int); -> cf. manuel PHP. Pareil ^^
XServer::Packet PacketFactory::CreatePacket(char *s) {
len = strlen(s);
bytes = floor((float)len/2)-floor((float)len/6);
for(int i=1; i<=bytes; ++i) {
cout << "Pushing " << substr(s, (i-1)*3, 1) << endl;
Packet.bytes.push_back(substr(s, (i-1)*3, 1));
}
Packet.index = 0;
cout << "Created packet : " << Packet.bytes.size() << endl;
for(int i=0; i<bytes; ++i) {
cout << "byte " << i << Packet.bytes[i] << endl;
}
return Packet;
} |
Partager