fmt-app

1.0.16 • Public • Published

FMTapp

P2P file share module with centralized server for tracking files, supports custom ui

It follows simple protocol:

  • When a peer A connects to FMT, A should automatically send information about its shared files as a list of records to the FMT in the following format: <file name, file type (text, jpg, etc), file size, file last modified date (DD/MM/YY), IP address, port number>. A should send “HELLO” and receive “HI” before sending the information.

  • When A wants to download a file with the name “File Name”, A requests the file from FMT by sending “SEARCH: ” + “File Name”. FMT finds records that exactly match (or partially match) “File Name”. FMT should send “FOUND: ” + list of records if it finds, or “NOT FOUND” if it finds no records.

  • After receiving a list of records, A should choose one of the peers2 from the list, say B, and connect to B (using IP and port number) to request and download the file. For that A should send “DOWNLOAD: ” + “FileName”

  • When A wants to leave the system, A should notify FailMailTracker about this so that FMT can remove A from the list of online users. A should send “BYE” to MT to do so.

    var FMTapp = require('./fmtapp.js');

    //1. Ask central server for records that contain ocaml (it resolves into resultArray), then download file from one of the peer (second param of downloadFi is the name field of the record)
    var p2pserver = new FMTapp.P2PServer((servercon)=>{
        p2pserver.searchForRe('ocaml').then(resultArr=>p2pserver.downloadFi(resultArr,'ocaml'));
    });

    p2pserver.listen();

Readme

Keywords

Package Sidebar

Install

npm i fmt-app

Weekly Downloads

0

Version

1.0.16

License

MIT

Last publish

Collaborators

  • rustamzh