blob: e5d6d7603f9ccfbffaffe6c1473fb1448aeb3235 [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
9var store = function(user, success) {
10 console.log("stored:", user.uid);
11 users[user.uid] = user;
12 success();
13};
14var retrieve = function(uid, success) {
15 console.log("retrieved:", uid);
16 success(users[uid]);
17};
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);