blob: 7f9b8fbe754ab80f8764b8f45a566617e5aab7bc [file] [log] [blame]
Roger Meier5c819c02011-04-09 11:10:04 +00001var thrift = require('thrift'),
2 ttransport = require('thrift/transport');
3
4var UserStorage = require('./gen-nodejs/UserStorage'),
5 ttypes = require('./gen-nodejs/user_types');
6
7var users = {};
8
Roger Meiereaa61d82012-01-12 21:38:29 +00009var store = function(user, result) {
Roger Meier5c819c02011-04-09 11:10:04 +000010 console.log("stored:", user.uid);
11 users[user.uid] = user;
Roger Meiereaa61d82012-01-12 21:38:29 +000012 result(null);
Roger Meier5c819c02011-04-09 11:10:04 +000013};
Roger Meiereaa61d82012-01-12 21:38:29 +000014var retrieve = function(uid, result) {
Roger Meier5c819c02011-04-09 11:10:04 +000015 console.log("retrieved:", uid);
Roger Meiereaa61d82012-01-12 21:38:29 +000016 result(null, users[uid]);
Roger Meier5c819c02011-04-09 11:10:04 +000017};
18
19var server_framed = thrift.createServer(UserStorage, {
20 store: store,
21 retrieve: retrieve
22});
23server_framed.listen(9090);
24var server_buffered = thrift.createServer(UserStorage, {
25 store: store,
26 retrieve: retrieve
27}, {transport: ttransport.TBufferedTransport});
28server_buffered.listen(9091);