lets see if this will post this time, i lost my whole last post.
Since I've been taking a while with this, and havn't got much done and integrating it (ive been having problems) I thought I'd post how I got file transfers working, so at least you guys can see it, and do something with it. (maybe even one of you guys will get around to adding it into msn.pm for me )
couple of issues with this code: 1. It loops through the whole file sending it, will be bad for big files as it will take over. 2. doesnt always get the ip, testing locally it didnt get my real ip just my routers 3. i was coding this to make it work, not be pretty, or effective. I've learnt a bit about some new stuff, eg syswrite and sysread in the process, but its still terrible. I couldnt think of ways to make things work how i wanted, i ended up even using select for one socket, since i couldnt think of how to know when it was ready.
First thing I added to msn.pm (this is based off msn.pm 1.3.8 i think) is a method to send the file.
I had to hardcode the filesize, because stat wouldnt work for me.
Code:
=head2 sendfile<br /><br />sends a file to the user<br /><br />=cut<br /><br />sub sendfile<br />{<br /> my $self = shift || croak(strMethodOnly);;<br /> my $path = shift;<br /> <br /> my $filesize = (stat($path))[7]; #<---- Didn't ever get the filesize for me, probably path problem.<br /><br /> my $cookie = int(rand(1553692604)) + 1;<br /> <br /> my $header = qq{MIME-Version: 1.0\nContent-Type: text/x-msmsgsinvite; charset=UTF-8\n\n} .<br /> qq{Application-Name: File Transfer\n} .<br /> qq{Application-GUID: {5D3E02AB-6190-11d3-BBBB-00C04F795683}\n} .<br /> qq{Invitation-Command: INVITE\n} .<br /> qq{Invitation-Cookie: $cookie\n} .<br /> qq{Application-File: $path\n} .<br /> qq{Application-FileSize: 7\n}; #<---- FileSize in bytes<br /> #qq{Connectivity: N\n};<br /> <br /> $header =~ s/\n/\*lazy*\n/gs;<br /><br /> $self->sendraw('MSG', 'N ' . length($header) . "\*lazy*\n" . $header);<br />}
Second is 2 events (which will need to be coded directly into msn.pm eventually). I also left out the application name, i forgot about it, but its in the one below it, nothing big to add.
as i did them at seperate times, alot of the code is duplicate, it could have been combined to make it cleaner (altho nothing in this code is clean anyways )
and then theres the sub to send the actual data from the file. Which basically reads in the whole file and sends it until its done, which is not very nice!
Joined: 03 May 2006 Posts: 2292 Location: Colorado
Posted: Fri Apr 02, 2004 7:44 pm Post subject:
I'm pretty lost on most of that. lol. Now that we have MSN cleaned up alot though we can move to haveing a SB module an NS module and now a FileSend module. Then it cna just register its socket that it creates with the Main object just like conversations do now. Its realy just a conversation with different events.
BTW Siebe is joining the development team! He has good experience with P2P and stuff so maybe we can get some cool features going. _________________ Eric256
Proud previous owner and current admin of Bot-depot.com