I have tried every possible way I can think of to send image data via the
gamekit from one phone to another.
If i just send it in 1024 byte blocks what comes out on the other end is a
corrupt image.
So I have looked at examples but cannot find any examples of sending anything
more than a small text block or all numeric data. Nothing shows any example of
larger data blocks like you would have with an image.
I send a struct:
typedef struct{
int index;
const char* data;
}packet;
My sending code is:
while (remaining >0) {
[data getBytes:&localPacket.data range:NSMakeRange(marker,
packetSize)];
packet localPacket;
localPacket.index = idx;
[session sendData:[NSData dataWithBytes:localPacket.data
length:sizeof(localPacket.data)+sizeof(int)] toPeers:[NSArray
arrayWithObject:peerID]
withDataMode:GKSendDataReliable error:&error];
remaining -=sizeof(localPacket.data);
marker +=sizeof(localPacket.data);
}
I know that this is wrong since it does not work.
The problem I am having is that attempting to get the data on the other end
leaves me with a digital mess. The data on the received end is garbage.
I am receiving with:
packet incData;
[data getBytes:&incData];
I assumed from the examples I followed that this would give me back my struct.
However, the index value is some randomly huge number that is wrong and any
attempt to access the data value causes a EXC_BAD_ACCESS. the 'data' length is
always 8 bytes. however the packetSize is set to 1024bytes when the data is
read in to the variable.
Basically I honestly have no clue how to send anything but a few lines of text
or some numbers. Is it even possible to send images via
gamekit?_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]