Hey,
EDIT : i was struggling to make p2p with files using byte packet, here is the SOLVED and working version of the code
i am using the Steamwork SDK for this, using 2 func, ( sendp2p/readp2p)
Code:
void SendP2PPacket(ulong TargetCSID, EP2PSend UDPTCPBUFF, File &f, int Channel=0)
{
f.pos(0);
byte *data;
void* buffer = Alloc(data, f.size());
f.get(buffer, f.size());
if(!SteamNetworking().SendP2PPacket( CSteamID(TargetCSID), buffer, f.size(), UDPTCPBUFF, Channel ))
{
Gui.msgBox(S, S+"Error Sending Packet via P2P");
}
Free( buffer );
}
So far nothing too hard, i pack my File with what i want to send, i pass it along to this function, pos is set back to (0) and send some byte buffer that get created with it. the rest of the args doesnt really matter, its just the target and the method used.
then on my loop(receiver) i am catching the packets using steam func like this
Code:
void UpdateP2PPacket()
{
uint32 msgSize=0;
int nChannel = 0;
while(SteamNetworking().IsP2PPacketAvailable(&msgSize, nChannel))
{
byte *data;
void* packet = Alloc(data, msgSize);
CSteamID steamIDRemote;
uint32 bytesRead = 0;
if(SteamNetworking().ReadP2PPacket(data, msgSize, &bytesRead, &steamIDRemote))
{
File f_packet;
f_packet.writeMem().putN(data, msgSize);
f_packet.pos(0);
byte t=0;
int test=0;
t=f_packet.getByte();
f_packet.decIntV(test);
Gui.msgBox(S, S+"WORKS"+t+"/"+test);
}
Free( packet );
}
}
there again, nothing crazy. we check if a packet is available, if it is then we get the size in byte.
then we malloc for the byte ( depending of msgsize ).
then we call the func to get this packet, and store it in our mem. then read write it as file, then read the file itself
thanks for the helps