2014-11-11 6 views
0

노드 용 'nntp' package을 사용하여 유즈넷의 그룹에 메시지를 게시하려고합니다. 예제가 제대로 작동하지 않습니다. "alt.binaries. '로 시작하는 모든 뉴스 그룹의 목록을 가져와야합니다. 업로드 예를 들어nntp 클라이언트 (nodejs)가 작동하지 않습니다.

코드 :

var NNTP = require('nntp'), 
    inspect = require('util').inspect; 

var c = new NNTP(); 
c.on('ready', function() { 
    var msg = { 
    from: { name: 'Node User', email: '[email protected]' }, 
    groups: 'alt.test', 
    subject: 'Just testing, do not mind me', 
    body: 'node.js rules!' 
    }; 
    c.post(msg, function(err) { 
    if (err) throw err; 
    }); 
}); 
c.on('error', function(err) { 
    console.log('Error: ' + err); 
}); 
c.on('close', function(had_err) { 
    console.log('Connection closed'); 
}); 
c.connect({ 
    host: 'example.org', 
    user: 'foo', 
    password: 'bar' 
}); 

호스트, 사용자 및 암호는 위의 코드 조각에서 잘못된 있지만, 나는 그들이 (I 이러한 설정 작업을 다른 예를 얻을 수 있습니다)이 올바른지 확신합니다.

내가 갖는 오류 :

/Develop/node/Usenet/node_modules/nntp/lib/nntp.js:265 
     self._curReq.cb(undefined, code, retval, type); 
        ^
TypeError: Property 'cb' of object #<Object> is not a function 

내가 노드를 사용하고 있습니다 :

/Develop/node/Usenet/node_modules/nntp/lib/nntp.js:662 
    this._debug('> ' + this._curReq.cmd + ' ' + this._curReq.params); 
    ^
TypeError: Property '_debug' of object #<NNTP> is not a function 

내가 c.connect에서 개체에 디버그 기능을 추가하면 나는 다음과 같은 오류가 발생합니다 v0.10.32. 누군가 나를 도울 수 있기를 바랍니다. 감사합니다, 릭

답변

0

단지 추가 옵션에 "디버그 기능은() {}"연결

var c = new NNTP(); 

c.on('ready', function() { 
    var msg = { 
     from: { name: 'Node User', email: '[email protected]' }, 
     groups: 'alt.test', 
     subject: 'Just testing, do not mind me', 
     body: 'node.js rules!' 
    }; 

    c.post(msg, function(err) { 
     if (err) throw err; 
    }); 
}); 

c.on('error', function(err) { 
    console.log('Error: ' + err); 
}); 

c.on('close', function(had_err) { 
    console.log('Connection closed'); 
}); 

c.connect({ 
    host: 'example.org', 
    user: 'foo', 
    password: 'bar', 
    debug: function(){} 
}); 
에 반대