Server-class is functional
[gopher-lib.git] / example-client.js
1 var Gopher = require('./lib.js');
2
3 var get = process.argv[2];
4 var fn = process.argv[3];
5
6 if(!process.argv[2]) {
7         console.log('Usage: URI [fileName]');
8         console.log('           URI      - A Gopher uri, such as gopher://dusted.dk/');
9         console.log('           fileName - Save to file instead of showing.');
10         console.log('           URI Schema: gopher://host[:port][/[type][selector][?query]]');
11         console.log('           Types: 0,1,(5),6,7,(9,I,g,h)  (=Binary)');
12         process.exit(1);
13 }
14
15 var res = new Gopher.Resource(get);
16 var client = new Gopher.Client({parseDir:true, timeout: 5000});
17 console.log( res.toJson() );
18 console.log( res.toURI() );
19 console.log( res.toDirectoryEntity() );
20
21 client.get( res, (err, reply)=>{
22
23         console.log(err, reply);
24         if(err) {
25                 process.exit(1);
26         }
27 }, fn);
28