Created
January 22, 2014 22:20
-
-
Save gabrielstuff/8568589 to your computer and use it in GitHub Desktop.
Deal with event and future
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.methods({ | |
'imapConnect': function(email, password) { | |
var fut = new Future(), | |
imap = new Imap({ | |
user: email, | |
password: password, | |
host: host, | |
port: port, | |
tls: tls, | |
tlsOptions: { | |
rejectUnauthorized: false | |
} | |
}); | |
imap.once('ready', function() { | |
console.log('imap connection open'); | |
fut['return']('success'); | |
}); | |
imap.once('error', function(err) { | |
console.log(err); | |
fut['return'](err) | |
}); | |
imap.once('end', function() { | |
console.log('Connection ended'); | |
fut['return']('Connection ended'); | |
}); | |
imap.connect(); | |
return fut.wait(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment