├── .bowerrc ├── .gitignore ├── Gruntfile.js ├── README.md ├── app.js ├── bin └── www ├── bower.json ├── lib ├── gen-nodejs │ ├── AccountSupervisorService.js │ ├── AgeCheckService.js │ ├── BuddyManagementService.js │ ├── BuddyService.js │ ├── ChannelApplicationProvidedService.js │ ├── ChannelService.js │ ├── MessageService.js │ ├── ShopService.js │ ├── SnsAdaptorService.js │ ├── TalkService.js │ ├── UniversalNotificationService.js │ └── line_types.js ├── line_client.js └── socket_client.js ├── package.json ├── public ├── css │ ├── style.css │ └── style.scss ├── img │ └── no-avatar.png └── js │ ├── app.js │ └── services │ ├── chat_service.js │ └── login_service.js ├── routes └── index.js └── views ├── error.ejs ├── footer.ejs ├── header.ejs ├── index.ejs └── partial ├── chat.ejs ├── login.ejs └── main.ejs /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "public/components", 3 | "json": "bower.json" 4 | } 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | public/components 3 | npm-debug.log 4 | api_test/ 5 | .sass-cache 6 | .DS_Store 7 | .editorconfig 8 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var request = require('request'); 4 | 5 | module.exports = function (grunt) { 6 | // show elapsed time at the end 7 | require('time-grunt')(grunt); 8 | // load all grunt tasks 9 | require('load-grunt-tasks')(grunt); 10 | 11 | var reloadPort = 35729, files; 12 | 13 | grunt.initConfig({ 14 | pkg: grunt.file.readJSON('package.json'), 15 | develop: { 16 | server: { 17 | file: 'bin/www' 18 | } 19 | }, 20 | sass: { 21 | dist: { 22 | files: { 23 | 'public/css/style.css': 'public/css/style.scss' 24 | } 25 | } 26 | }, 27 | watch: { 28 | options: { 29 | nospawn: true, 30 | livereload: reloadPort 31 | }, 32 | server: { 33 | files: [ 34 | 'bin/www', 35 | 'app.js', 36 | 'routes/*.js' 37 | ], 38 | tasks: ['develop', 'delayed-livereload'] 39 | }, 40 | js: { 41 | files: ['public/js/*.js'], 42 | options: { 43 | livereload: reloadPort 44 | } 45 | }, 46 | css: { 47 | files: [ 48 | 'public/css/*.scss' 49 | ], 50 | tasks: ['sass'], 51 | options: { 52 | livereload: reloadPort 53 | } 54 | }, 55 | views: { 56 | files: ['views/*.ejs'], 57 | options: { 58 | livereload: reloadPort 59 | } 60 | } 61 | } 62 | }); 63 | 64 | grunt.config.requires('watch.server.files'); 65 | files = grunt.config('watch.server.files'); 66 | files = grunt.file.expand(files); 67 | 68 | grunt.registerTask('delayed-livereload', 'Live reload after the node server has restarted.', function () { 69 | var done = this.async(); 70 | setTimeout(function () { 71 | request.get('http://localhost:' + reloadPort + '/changed?files=' + files.join(','), function (err, res) { 72 | var reloaded = !err && res.statusCode === 200; 73 | if (reloaded) { 74 | grunt.log.ok('Delayed live reload successful.'); 75 | } else { 76 | grunt.log.error('Unable to make a delayed live reload.'); 77 | } 78 | done(reloaded); 79 | }); 80 | }, 500); 81 | }); 82 | 83 | grunt.registerTask('default', [ 84 | 'sass', 85 | 'develop', 86 | 'watch' 87 | ]); 88 | }; 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Web-LINE 2 | ============== 3 | 4 | ![alt tag](https://cloud.githubusercontent.com/assets/1298784/7665406/912ee914-fbe7-11e4-85ec-7cc6f0ce0b09.png) 5 | 6 | 簡單來說,就是讓你可以用 Web 連上 LINE 7 | 8 | 可以幫助你在沒有 LINE 的平台上也能用 LINE 9 | 10 | 或是可以客製化自己的 LINE 11 | 12 | Demo 13 | ------------ 14 | 15 | http://webline-chsien.rhcloud.com/ 16 | 17 | 這是 public server,支援多人連線,但上限不確定能撐多少人 18 | 19 | 未加密的狀態下使用上可能會有安全性問題,建議使用分身帳號測試 20 | 21 | Usage 22 | ------------ 23 | ###Loal 24 | 25 | ``` 26 | npm install && bower install 27 | ``` 28 | 29 | ``` 30 | grunt 31 | ``` 32 | 33 | 瀏覽器開啟 `http://localhost:3000` 34 | 35 | ###Openshift 36 | 37 | 或是你也可以自己建立一台 Openshift Instance,直接 deploy 這個 repository 38 | 39 | Feature 40 | ------------ 41 | 42 | * 帳號登入 43 | * 取得聯絡人 44 | * 取得最近訊息 45 | * 接收與送出訊息 46 | 47 | 還有很多功能還沒實作,可以玩玩,歡迎 fork 及 pull request 48 | 49 | 感謝及聲明 50 | ------------ 51 | 感謝 Purple-line 這個專案提供的 protocol 及說明 52 | 53 | 本專案僅可用於個人使用,不可用在商業用途 54 | 55 | 聯絡我:LeeChSien 56 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var express = require('express'); 4 | var path = require('path'); 5 | var favicon = require('serve-favicon'); 6 | var logger = require('morgan'); 7 | var cookieParser = require('cookie-parser'); 8 | var bodyParser = require('body-parser'); 9 | 10 | var routes = require('./routes/index'); 11 | 12 | var app = express(); 13 | 14 | // view engine setup 15 | 16 | app.set('views', path.join(__dirname, 'views')); 17 | app.set('view engine', 'ejs'); 18 | 19 | var env = process.env.NODE_ENV || 'development'; 20 | app.locals.ENV = env; 21 | app.locals.ENV_DEVELOPMENT = env == 'development'; 22 | 23 | // app.use(favicon(__dirname + '/public/img/favicon.ico')); 24 | app.use(logger('dev')); 25 | app.use(bodyParser.json()); 26 | app.use(bodyParser.urlencoded({ 27 | extended: true 28 | })); 29 | app.use(cookieParser()); 30 | app.use(express.static(path.join(__dirname, 'public'))); 31 | 32 | app.use('/', routes); 33 | 34 | /// catch 404 and forward to error handler 35 | app.use(function(req, res, next) { 36 | var err = new Error('Not Found'); 37 | err.status = 404; 38 | next(err); 39 | }); 40 | 41 | /// error handlers 42 | 43 | // development error handler 44 | // will print stacktrace 45 | 46 | if (app.get('env') === 'development') { 47 | app.use(function(err, req, res, next) { 48 | res.status(err.status || 500); 49 | res.render('error', { 50 | message: err.message, 51 | error: err, 52 | title: 'error' 53 | }); 54 | }); 55 | } 56 | 57 | // production error handler 58 | // no stacktraces leaked to user 59 | app.use(function(err, req, res, next) { 60 | res.status(err.status || 500); 61 | res.render('error', { 62 | message: err.message, 63 | error: {}, 64 | title: 'error' 65 | }); 66 | }); 67 | 68 | 69 | module.exports = app; 70 | -------------------------------------------------------------------------------- /bin/www: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var debug = require('debug')('expressapp'); 3 | var app = require('../app'); 4 | var SocketClient = require('../lib/socket_client'); 5 | 6 | var server_port = process.env.OPENSHIFT_NODEJS_PORT || process.env.PORT || 3000; 7 | var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1'; 8 | var server = require('http').createServer(app); 9 | var io = SocketClient.prototype.io = require('socket.io')(server); 10 | 11 | app.set('port', server_port); 12 | 13 | server.listen(app.get('port'), server_ip_address, function() { 14 | console.log("Express server listening on port " + app.get('port')); 15 | }); 16 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "javascriptworkspace", 3 | "version": "0.0.1", 4 | "ignore": [ 5 | "**/.*", 6 | "node_modules", 7 | "components" 8 | ], 9 | "dependencies": { 10 | "angular": "~1.3.15", 11 | "angular-socket-io": "~0.7.0", 12 | "bootstrap": "~3.3.4", 13 | "angular-moment": "~0.10.1", 14 | "angular-animate": "~1.3.15", 15 | "angular-perfect-scrollbar": "~0.0.4", 16 | "jquery": "~2.1.4", 17 | "angularjs-scroll-glue": "~0.0.1", 18 | "font-awesome": "~4.3.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/gen-nodejs/AccountSupervisorService.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift Compiler (0.9.2) 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | var thrift = require('thrift'); 7 | var Thrift = thrift.Thrift; 8 | var Q = thrift.Q; 9 | 10 | 11 | var ttypes = require('./line_types'); 12 | //HELPER FUNCTIONS AND STRUCTURES 13 | 14 | AccountSupervisorService_getRSAKey_args = function(args) { 15 | }; 16 | AccountSupervisorService_getRSAKey_args.prototype = {}; 17 | AccountSupervisorService_getRSAKey_args.prototype.read = function(input) { 18 | input.readStructBegin(); 19 | while (true) 20 | { 21 | var ret = input.readFieldBegin(); 22 | var fname = ret.fname; 23 | var ftype = ret.ftype; 24 | var fid = ret.fid; 25 | if (ftype == Thrift.Type.STOP) { 26 | break; 27 | } 28 | input.skip(ftype); 29 | input.readFieldEnd(); 30 | } 31 | input.readStructEnd(); 32 | return; 33 | }; 34 | 35 | AccountSupervisorService_getRSAKey_args.prototype.write = function(output) { 36 | output.writeStructBegin('AccountSupervisorService_getRSAKey_args'); 37 | output.writeFieldStop(); 38 | output.writeStructEnd(); 39 | return; 40 | }; 41 | 42 | AccountSupervisorService_getRSAKey_result = function(args) { 43 | this.success = null; 44 | this.e = null; 45 | if (args instanceof ttypes.TalkException) { 46 | this.e = args; 47 | return; 48 | } 49 | if (args) { 50 | if (args.success !== undefined) { 51 | this.success = args.success; 52 | } 53 | if (args.e !== undefined) { 54 | this.e = args.e; 55 | } 56 | } 57 | }; 58 | AccountSupervisorService_getRSAKey_result.prototype = {}; 59 | AccountSupervisorService_getRSAKey_result.prototype.read = function(input) { 60 | input.readStructBegin(); 61 | while (true) 62 | { 63 | var ret = input.readFieldBegin(); 64 | var fname = ret.fname; 65 | var ftype = ret.ftype; 66 | var fid = ret.fid; 67 | if (ftype == Thrift.Type.STOP) { 68 | break; 69 | } 70 | switch (fid) 71 | { 72 | case 0: 73 | if (ftype == Thrift.Type.STRUCT) { 74 | this.success = new ttypes.RSAKey(); 75 | this.success.read(input); 76 | } else { 77 | input.skip(ftype); 78 | } 79 | break; 80 | case 1: 81 | if (ftype == Thrift.Type.STRUCT) { 82 | this.e = new ttypes.TalkException(); 83 | this.e.read(input); 84 | } else { 85 | input.skip(ftype); 86 | } 87 | break; 88 | default: 89 | input.skip(ftype); 90 | } 91 | input.readFieldEnd(); 92 | } 93 | input.readStructEnd(); 94 | return; 95 | }; 96 | 97 | AccountSupervisorService_getRSAKey_result.prototype.write = function(output) { 98 | output.writeStructBegin('AccountSupervisorService_getRSAKey_result'); 99 | if (this.success !== null && this.success !== undefined) { 100 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0); 101 | this.success.write(output); 102 | output.writeFieldEnd(); 103 | } 104 | if (this.e !== null && this.e !== undefined) { 105 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 106 | this.e.write(output); 107 | output.writeFieldEnd(); 108 | } 109 | output.writeFieldStop(); 110 | output.writeStructEnd(); 111 | return; 112 | }; 113 | 114 | AccountSupervisorService_notifyEmailConfirmationResult_args = function(args) { 115 | this.parameterMap = null; 116 | if (args) { 117 | if (args.parameterMap !== undefined) { 118 | this.parameterMap = args.parameterMap; 119 | } 120 | } 121 | }; 122 | AccountSupervisorService_notifyEmailConfirmationResult_args.prototype = {}; 123 | AccountSupervisorService_notifyEmailConfirmationResult_args.prototype.read = function(input) { 124 | input.readStructBegin(); 125 | while (true) 126 | { 127 | var ret = input.readFieldBegin(); 128 | var fname = ret.fname; 129 | var ftype = ret.ftype; 130 | var fid = ret.fid; 131 | if (ftype == Thrift.Type.STOP) { 132 | break; 133 | } 134 | switch (fid) 135 | { 136 | case 2: 137 | if (ftype == Thrift.Type.MAP) { 138 | var _size376 = 0; 139 | var _rtmp3380; 140 | this.parameterMap = {}; 141 | var _ktype377 = 0; 142 | var _vtype378 = 0; 143 | _rtmp3380 = input.readMapBegin(); 144 | _ktype377 = _rtmp3380.ktype; 145 | _vtype378 = _rtmp3380.vtype; 146 | _size376 = _rtmp3380.size; 147 | for (var _i381 = 0; _i381 < _size376; ++_i381) 148 | { 149 | var key382 = null; 150 | var val383 = null; 151 | key382 = input.readString(); 152 | val383 = input.readString(); 153 | this.parameterMap[key382] = val383; 154 | } 155 | input.readMapEnd(); 156 | } else { 157 | input.skip(ftype); 158 | } 159 | break; 160 | case 0: 161 | input.skip(ftype); 162 | break; 163 | default: 164 | input.skip(ftype); 165 | } 166 | input.readFieldEnd(); 167 | } 168 | input.readStructEnd(); 169 | return; 170 | }; 171 | 172 | AccountSupervisorService_notifyEmailConfirmationResult_args.prototype.write = function(output) { 173 | output.writeStructBegin('AccountSupervisorService_notifyEmailConfirmationResult_args'); 174 | if (this.parameterMap !== null && this.parameterMap !== undefined) { 175 | output.writeFieldBegin('parameterMap', Thrift.Type.MAP, 2); 176 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.STRING, Thrift.objectLength(this.parameterMap)); 177 | for (var kiter384 in this.parameterMap) 178 | { 179 | if (this.parameterMap.hasOwnProperty(kiter384)) 180 | { 181 | var viter385 = this.parameterMap[kiter384]; 182 | output.writeString(kiter384); 183 | output.writeString(viter385); 184 | } 185 | } 186 | output.writeMapEnd(); 187 | output.writeFieldEnd(); 188 | } 189 | output.writeFieldStop(); 190 | output.writeStructEnd(); 191 | return; 192 | }; 193 | 194 | AccountSupervisorService_notifyEmailConfirmationResult_result = function(args) { 195 | this.e = null; 196 | if (args instanceof ttypes.TalkException) { 197 | this.e = args; 198 | return; 199 | } 200 | if (args) { 201 | if (args.e !== undefined) { 202 | this.e = args.e; 203 | } 204 | } 205 | }; 206 | AccountSupervisorService_notifyEmailConfirmationResult_result.prototype = {}; 207 | AccountSupervisorService_notifyEmailConfirmationResult_result.prototype.read = function(input) { 208 | input.readStructBegin(); 209 | while (true) 210 | { 211 | var ret = input.readFieldBegin(); 212 | var fname = ret.fname; 213 | var ftype = ret.ftype; 214 | var fid = ret.fid; 215 | if (ftype == Thrift.Type.STOP) { 216 | break; 217 | } 218 | switch (fid) 219 | { 220 | case 1: 221 | if (ftype == Thrift.Type.STRUCT) { 222 | this.e = new ttypes.TalkException(); 223 | this.e.read(input); 224 | } else { 225 | input.skip(ftype); 226 | } 227 | break; 228 | case 0: 229 | input.skip(ftype); 230 | break; 231 | default: 232 | input.skip(ftype); 233 | } 234 | input.readFieldEnd(); 235 | } 236 | input.readStructEnd(); 237 | return; 238 | }; 239 | 240 | AccountSupervisorService_notifyEmailConfirmationResult_result.prototype.write = function(output) { 241 | output.writeStructBegin('AccountSupervisorService_notifyEmailConfirmationResult_result'); 242 | if (this.e !== null && this.e !== undefined) { 243 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 244 | this.e.write(output); 245 | output.writeFieldEnd(); 246 | } 247 | output.writeFieldStop(); 248 | output.writeStructEnd(); 249 | return; 250 | }; 251 | 252 | AccountSupervisorService_registerVirtualAccount_args = function(args) { 253 | this.locale = null; 254 | this.encryptedVirtualUserId = null; 255 | this.encryptedPassword = null; 256 | if (args) { 257 | if (args.locale !== undefined) { 258 | this.locale = args.locale; 259 | } 260 | if (args.encryptedVirtualUserId !== undefined) { 261 | this.encryptedVirtualUserId = args.encryptedVirtualUserId; 262 | } 263 | if (args.encryptedPassword !== undefined) { 264 | this.encryptedPassword = args.encryptedPassword; 265 | } 266 | } 267 | }; 268 | AccountSupervisorService_registerVirtualAccount_args.prototype = {}; 269 | AccountSupervisorService_registerVirtualAccount_args.prototype.read = function(input) { 270 | input.readStructBegin(); 271 | while (true) 272 | { 273 | var ret = input.readFieldBegin(); 274 | var fname = ret.fname; 275 | var ftype = ret.ftype; 276 | var fid = ret.fid; 277 | if (ftype == Thrift.Type.STOP) { 278 | break; 279 | } 280 | switch (fid) 281 | { 282 | case 2: 283 | if (ftype == Thrift.Type.STRING) { 284 | this.locale = input.readString(); 285 | } else { 286 | input.skip(ftype); 287 | } 288 | break; 289 | case 3: 290 | if (ftype == Thrift.Type.STRING) { 291 | this.encryptedVirtualUserId = input.readString(); 292 | } else { 293 | input.skip(ftype); 294 | } 295 | break; 296 | case 4: 297 | if (ftype == Thrift.Type.STRING) { 298 | this.encryptedPassword = input.readString(); 299 | } else { 300 | input.skip(ftype); 301 | } 302 | break; 303 | default: 304 | input.skip(ftype); 305 | } 306 | input.readFieldEnd(); 307 | } 308 | input.readStructEnd(); 309 | return; 310 | }; 311 | 312 | AccountSupervisorService_registerVirtualAccount_args.prototype.write = function(output) { 313 | output.writeStructBegin('AccountSupervisorService_registerVirtualAccount_args'); 314 | if (this.locale !== null && this.locale !== undefined) { 315 | output.writeFieldBegin('locale', Thrift.Type.STRING, 2); 316 | output.writeString(this.locale); 317 | output.writeFieldEnd(); 318 | } 319 | if (this.encryptedVirtualUserId !== null && this.encryptedVirtualUserId !== undefined) { 320 | output.writeFieldBegin('encryptedVirtualUserId', Thrift.Type.STRING, 3); 321 | output.writeString(this.encryptedVirtualUserId); 322 | output.writeFieldEnd(); 323 | } 324 | if (this.encryptedPassword !== null && this.encryptedPassword !== undefined) { 325 | output.writeFieldBegin('encryptedPassword', Thrift.Type.STRING, 4); 326 | output.writeString(this.encryptedPassword); 327 | output.writeFieldEnd(); 328 | } 329 | output.writeFieldStop(); 330 | output.writeStructEnd(); 331 | return; 332 | }; 333 | 334 | AccountSupervisorService_registerVirtualAccount_result = function(args) { 335 | this.success = null; 336 | this.e = null; 337 | if (args instanceof ttypes.TalkException) { 338 | this.e = args; 339 | return; 340 | } 341 | if (args) { 342 | if (args.success !== undefined) { 343 | this.success = args.success; 344 | } 345 | if (args.e !== undefined) { 346 | this.e = args.e; 347 | } 348 | } 349 | }; 350 | AccountSupervisorService_registerVirtualAccount_result.prototype = {}; 351 | AccountSupervisorService_registerVirtualAccount_result.prototype.read = function(input) { 352 | input.readStructBegin(); 353 | while (true) 354 | { 355 | var ret = input.readFieldBegin(); 356 | var fname = ret.fname; 357 | var ftype = ret.ftype; 358 | var fid = ret.fid; 359 | if (ftype == Thrift.Type.STOP) { 360 | break; 361 | } 362 | switch (fid) 363 | { 364 | case 0: 365 | if (ftype == Thrift.Type.STRING) { 366 | this.success = input.readString(); 367 | } else { 368 | input.skip(ftype); 369 | } 370 | break; 371 | case 1: 372 | if (ftype == Thrift.Type.STRUCT) { 373 | this.e = new ttypes.TalkException(); 374 | this.e.read(input); 375 | } else { 376 | input.skip(ftype); 377 | } 378 | break; 379 | default: 380 | input.skip(ftype); 381 | } 382 | input.readFieldEnd(); 383 | } 384 | input.readStructEnd(); 385 | return; 386 | }; 387 | 388 | AccountSupervisorService_registerVirtualAccount_result.prototype.write = function(output) { 389 | output.writeStructBegin('AccountSupervisorService_registerVirtualAccount_result'); 390 | if (this.success !== null && this.success !== undefined) { 391 | output.writeFieldBegin('success', Thrift.Type.STRING, 0); 392 | output.writeString(this.success); 393 | output.writeFieldEnd(); 394 | } 395 | if (this.e !== null && this.e !== undefined) { 396 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 397 | this.e.write(output); 398 | output.writeFieldEnd(); 399 | } 400 | output.writeFieldStop(); 401 | output.writeStructEnd(); 402 | return; 403 | }; 404 | 405 | AccountSupervisorService_requestVirtualAccountPasswordChange_args = function(args) { 406 | this.virtualMid = null; 407 | this.encryptedVirtualUserId = null; 408 | this.encryptedOldPassword = null; 409 | this.encryptedNewPassword = null; 410 | if (args) { 411 | if (args.virtualMid !== undefined) { 412 | this.virtualMid = args.virtualMid; 413 | } 414 | if (args.encryptedVirtualUserId !== undefined) { 415 | this.encryptedVirtualUserId = args.encryptedVirtualUserId; 416 | } 417 | if (args.encryptedOldPassword !== undefined) { 418 | this.encryptedOldPassword = args.encryptedOldPassword; 419 | } 420 | if (args.encryptedNewPassword !== undefined) { 421 | this.encryptedNewPassword = args.encryptedNewPassword; 422 | } 423 | } 424 | }; 425 | AccountSupervisorService_requestVirtualAccountPasswordChange_args.prototype = {}; 426 | AccountSupervisorService_requestVirtualAccountPasswordChange_args.prototype.read = function(input) { 427 | input.readStructBegin(); 428 | while (true) 429 | { 430 | var ret = input.readFieldBegin(); 431 | var fname = ret.fname; 432 | var ftype = ret.ftype; 433 | var fid = ret.fid; 434 | if (ftype == Thrift.Type.STOP) { 435 | break; 436 | } 437 | switch (fid) 438 | { 439 | case 2: 440 | if (ftype == Thrift.Type.STRING) { 441 | this.virtualMid = input.readString(); 442 | } else { 443 | input.skip(ftype); 444 | } 445 | break; 446 | case 3: 447 | if (ftype == Thrift.Type.STRING) { 448 | this.encryptedVirtualUserId = input.readString(); 449 | } else { 450 | input.skip(ftype); 451 | } 452 | break; 453 | case 4: 454 | if (ftype == Thrift.Type.STRING) { 455 | this.encryptedOldPassword = input.readString(); 456 | } else { 457 | input.skip(ftype); 458 | } 459 | break; 460 | case 5: 461 | if (ftype == Thrift.Type.STRING) { 462 | this.encryptedNewPassword = input.readString(); 463 | } else { 464 | input.skip(ftype); 465 | } 466 | break; 467 | default: 468 | input.skip(ftype); 469 | } 470 | input.readFieldEnd(); 471 | } 472 | input.readStructEnd(); 473 | return; 474 | }; 475 | 476 | AccountSupervisorService_requestVirtualAccountPasswordChange_args.prototype.write = function(output) { 477 | output.writeStructBegin('AccountSupervisorService_requestVirtualAccountPasswordChange_args'); 478 | if (this.virtualMid !== null && this.virtualMid !== undefined) { 479 | output.writeFieldBegin('virtualMid', Thrift.Type.STRING, 2); 480 | output.writeString(this.virtualMid); 481 | output.writeFieldEnd(); 482 | } 483 | if (this.encryptedVirtualUserId !== null && this.encryptedVirtualUserId !== undefined) { 484 | output.writeFieldBegin('encryptedVirtualUserId', Thrift.Type.STRING, 3); 485 | output.writeString(this.encryptedVirtualUserId); 486 | output.writeFieldEnd(); 487 | } 488 | if (this.encryptedOldPassword !== null && this.encryptedOldPassword !== undefined) { 489 | output.writeFieldBegin('encryptedOldPassword', Thrift.Type.STRING, 4); 490 | output.writeString(this.encryptedOldPassword); 491 | output.writeFieldEnd(); 492 | } 493 | if (this.encryptedNewPassword !== null && this.encryptedNewPassword !== undefined) { 494 | output.writeFieldBegin('encryptedNewPassword', Thrift.Type.STRING, 5); 495 | output.writeString(this.encryptedNewPassword); 496 | output.writeFieldEnd(); 497 | } 498 | output.writeFieldStop(); 499 | output.writeStructEnd(); 500 | return; 501 | }; 502 | 503 | AccountSupervisorService_requestVirtualAccountPasswordChange_result = function(args) { 504 | this.e = null; 505 | if (args instanceof ttypes.TalkException) { 506 | this.e = args; 507 | return; 508 | } 509 | if (args) { 510 | if (args.e !== undefined) { 511 | this.e = args.e; 512 | } 513 | } 514 | }; 515 | AccountSupervisorService_requestVirtualAccountPasswordChange_result.prototype = {}; 516 | AccountSupervisorService_requestVirtualAccountPasswordChange_result.prototype.read = function(input) { 517 | input.readStructBegin(); 518 | while (true) 519 | { 520 | var ret = input.readFieldBegin(); 521 | var fname = ret.fname; 522 | var ftype = ret.ftype; 523 | var fid = ret.fid; 524 | if (ftype == Thrift.Type.STOP) { 525 | break; 526 | } 527 | switch (fid) 528 | { 529 | case 1: 530 | if (ftype == Thrift.Type.STRUCT) { 531 | this.e = new ttypes.TalkException(); 532 | this.e.read(input); 533 | } else { 534 | input.skip(ftype); 535 | } 536 | break; 537 | case 0: 538 | input.skip(ftype); 539 | break; 540 | default: 541 | input.skip(ftype); 542 | } 543 | input.readFieldEnd(); 544 | } 545 | input.readStructEnd(); 546 | return; 547 | }; 548 | 549 | AccountSupervisorService_requestVirtualAccountPasswordChange_result.prototype.write = function(output) { 550 | output.writeStructBegin('AccountSupervisorService_requestVirtualAccountPasswordChange_result'); 551 | if (this.e !== null && this.e !== undefined) { 552 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 553 | this.e.write(output); 554 | output.writeFieldEnd(); 555 | } 556 | output.writeFieldStop(); 557 | output.writeStructEnd(); 558 | return; 559 | }; 560 | 561 | AccountSupervisorService_requestVirtualAccountPasswordSet_args = function(args) { 562 | this.virtualMid = null; 563 | this.encryptedVirtualUserId = null; 564 | this.encryptedNewPassword = null; 565 | if (args) { 566 | if (args.virtualMid !== undefined) { 567 | this.virtualMid = args.virtualMid; 568 | } 569 | if (args.encryptedVirtualUserId !== undefined) { 570 | this.encryptedVirtualUserId = args.encryptedVirtualUserId; 571 | } 572 | if (args.encryptedNewPassword !== undefined) { 573 | this.encryptedNewPassword = args.encryptedNewPassword; 574 | } 575 | } 576 | }; 577 | AccountSupervisorService_requestVirtualAccountPasswordSet_args.prototype = {}; 578 | AccountSupervisorService_requestVirtualAccountPasswordSet_args.prototype.read = function(input) { 579 | input.readStructBegin(); 580 | while (true) 581 | { 582 | var ret = input.readFieldBegin(); 583 | var fname = ret.fname; 584 | var ftype = ret.ftype; 585 | var fid = ret.fid; 586 | if (ftype == Thrift.Type.STOP) { 587 | break; 588 | } 589 | switch (fid) 590 | { 591 | case 2: 592 | if (ftype == Thrift.Type.STRING) { 593 | this.virtualMid = input.readString(); 594 | } else { 595 | input.skip(ftype); 596 | } 597 | break; 598 | case 3: 599 | if (ftype == Thrift.Type.STRING) { 600 | this.encryptedVirtualUserId = input.readString(); 601 | } else { 602 | input.skip(ftype); 603 | } 604 | break; 605 | case 4: 606 | if (ftype == Thrift.Type.STRING) { 607 | this.encryptedNewPassword = input.readString(); 608 | } else { 609 | input.skip(ftype); 610 | } 611 | break; 612 | default: 613 | input.skip(ftype); 614 | } 615 | input.readFieldEnd(); 616 | } 617 | input.readStructEnd(); 618 | return; 619 | }; 620 | 621 | AccountSupervisorService_requestVirtualAccountPasswordSet_args.prototype.write = function(output) { 622 | output.writeStructBegin('AccountSupervisorService_requestVirtualAccountPasswordSet_args'); 623 | if (this.virtualMid !== null && this.virtualMid !== undefined) { 624 | output.writeFieldBegin('virtualMid', Thrift.Type.STRING, 2); 625 | output.writeString(this.virtualMid); 626 | output.writeFieldEnd(); 627 | } 628 | if (this.encryptedVirtualUserId !== null && this.encryptedVirtualUserId !== undefined) { 629 | output.writeFieldBegin('encryptedVirtualUserId', Thrift.Type.STRING, 3); 630 | output.writeString(this.encryptedVirtualUserId); 631 | output.writeFieldEnd(); 632 | } 633 | if (this.encryptedNewPassword !== null && this.encryptedNewPassword !== undefined) { 634 | output.writeFieldBegin('encryptedNewPassword', Thrift.Type.STRING, 4); 635 | output.writeString(this.encryptedNewPassword); 636 | output.writeFieldEnd(); 637 | } 638 | output.writeFieldStop(); 639 | output.writeStructEnd(); 640 | return; 641 | }; 642 | 643 | AccountSupervisorService_requestVirtualAccountPasswordSet_result = function(args) { 644 | this.e = null; 645 | if (args instanceof ttypes.TalkException) { 646 | this.e = args; 647 | return; 648 | } 649 | if (args) { 650 | if (args.e !== undefined) { 651 | this.e = args.e; 652 | } 653 | } 654 | }; 655 | AccountSupervisorService_requestVirtualAccountPasswordSet_result.prototype = {}; 656 | AccountSupervisorService_requestVirtualAccountPasswordSet_result.prototype.read = function(input) { 657 | input.readStructBegin(); 658 | while (true) 659 | { 660 | var ret = input.readFieldBegin(); 661 | var fname = ret.fname; 662 | var ftype = ret.ftype; 663 | var fid = ret.fid; 664 | if (ftype == Thrift.Type.STOP) { 665 | break; 666 | } 667 | switch (fid) 668 | { 669 | case 1: 670 | if (ftype == Thrift.Type.STRUCT) { 671 | this.e = new ttypes.TalkException(); 672 | this.e.read(input); 673 | } else { 674 | input.skip(ftype); 675 | } 676 | break; 677 | case 0: 678 | input.skip(ftype); 679 | break; 680 | default: 681 | input.skip(ftype); 682 | } 683 | input.readFieldEnd(); 684 | } 685 | input.readStructEnd(); 686 | return; 687 | }; 688 | 689 | AccountSupervisorService_requestVirtualAccountPasswordSet_result.prototype.write = function(output) { 690 | output.writeStructBegin('AccountSupervisorService_requestVirtualAccountPasswordSet_result'); 691 | if (this.e !== null && this.e !== undefined) { 692 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 693 | this.e.write(output); 694 | output.writeFieldEnd(); 695 | } 696 | output.writeFieldStop(); 697 | output.writeStructEnd(); 698 | return; 699 | }; 700 | 701 | AccountSupervisorService_unregisterVirtualAccount_args = function(args) { 702 | this.virtualMid = null; 703 | if (args) { 704 | if (args.virtualMid !== undefined) { 705 | this.virtualMid = args.virtualMid; 706 | } 707 | } 708 | }; 709 | AccountSupervisorService_unregisterVirtualAccount_args.prototype = {}; 710 | AccountSupervisorService_unregisterVirtualAccount_args.prototype.read = function(input) { 711 | input.readStructBegin(); 712 | while (true) 713 | { 714 | var ret = input.readFieldBegin(); 715 | var fname = ret.fname; 716 | var ftype = ret.ftype; 717 | var fid = ret.fid; 718 | if (ftype == Thrift.Type.STOP) { 719 | break; 720 | } 721 | switch (fid) 722 | { 723 | case 2: 724 | if (ftype == Thrift.Type.STRING) { 725 | this.virtualMid = input.readString(); 726 | } else { 727 | input.skip(ftype); 728 | } 729 | break; 730 | case 0: 731 | input.skip(ftype); 732 | break; 733 | default: 734 | input.skip(ftype); 735 | } 736 | input.readFieldEnd(); 737 | } 738 | input.readStructEnd(); 739 | return; 740 | }; 741 | 742 | AccountSupervisorService_unregisterVirtualAccount_args.prototype.write = function(output) { 743 | output.writeStructBegin('AccountSupervisorService_unregisterVirtualAccount_args'); 744 | if (this.virtualMid !== null && this.virtualMid !== undefined) { 745 | output.writeFieldBegin('virtualMid', Thrift.Type.STRING, 2); 746 | output.writeString(this.virtualMid); 747 | output.writeFieldEnd(); 748 | } 749 | output.writeFieldStop(); 750 | output.writeStructEnd(); 751 | return; 752 | }; 753 | 754 | AccountSupervisorService_unregisterVirtualAccount_result = function(args) { 755 | this.e = null; 756 | if (args instanceof ttypes.TalkException) { 757 | this.e = args; 758 | return; 759 | } 760 | if (args) { 761 | if (args.e !== undefined) { 762 | this.e = args.e; 763 | } 764 | } 765 | }; 766 | AccountSupervisorService_unregisterVirtualAccount_result.prototype = {}; 767 | AccountSupervisorService_unregisterVirtualAccount_result.prototype.read = function(input) { 768 | input.readStructBegin(); 769 | while (true) 770 | { 771 | var ret = input.readFieldBegin(); 772 | var fname = ret.fname; 773 | var ftype = ret.ftype; 774 | var fid = ret.fid; 775 | if (ftype == Thrift.Type.STOP) { 776 | break; 777 | } 778 | switch (fid) 779 | { 780 | case 1: 781 | if (ftype == Thrift.Type.STRUCT) { 782 | this.e = new ttypes.TalkException(); 783 | this.e.read(input); 784 | } else { 785 | input.skip(ftype); 786 | } 787 | break; 788 | case 0: 789 | input.skip(ftype); 790 | break; 791 | default: 792 | input.skip(ftype); 793 | } 794 | input.readFieldEnd(); 795 | } 796 | input.readStructEnd(); 797 | return; 798 | }; 799 | 800 | AccountSupervisorService_unregisterVirtualAccount_result.prototype.write = function(output) { 801 | output.writeStructBegin('AccountSupervisorService_unregisterVirtualAccount_result'); 802 | if (this.e !== null && this.e !== undefined) { 803 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 804 | this.e.write(output); 805 | output.writeFieldEnd(); 806 | } 807 | output.writeFieldStop(); 808 | output.writeStructEnd(); 809 | return; 810 | }; 811 | 812 | AccountSupervisorServiceClient = exports.Client = function(output, pClass) { 813 | this.output = output; 814 | this.pClass = pClass; 815 | this._seqid = 0; 816 | this._reqs = {}; 817 | }; 818 | AccountSupervisorServiceClient.prototype = {}; 819 | AccountSupervisorServiceClient.prototype.seqid = function() { return this._seqid; } 820 | AccountSupervisorServiceClient.prototype.new_seqid = function() { return this._seqid += 1; } 821 | AccountSupervisorServiceClient.prototype.getRSAKey = function(callback) { 822 | this._seqid = this.new_seqid(); 823 | if (callback === undefined) { 824 | var _defer = Q.defer(); 825 | this._reqs[this.seqid()] = function(error, result) { 826 | if (error) { 827 | _defer.reject(error); 828 | } else { 829 | _defer.resolve(result); 830 | } 831 | }; 832 | this.send_getRSAKey(); 833 | return _defer.promise; 834 | } else { 835 | this._reqs[this.seqid()] = callback; 836 | this.send_getRSAKey(); 837 | } 838 | }; 839 | 840 | AccountSupervisorServiceClient.prototype.send_getRSAKey = function() { 841 | var output = new this.pClass(this.output); 842 | output.writeMessageBegin('getRSAKey', Thrift.MessageType.CALL, this.seqid()); 843 | var args = new AccountSupervisorService_getRSAKey_args(); 844 | args.write(output); 845 | output.writeMessageEnd(); 846 | return this.output.flush(); 847 | }; 848 | 849 | AccountSupervisorServiceClient.prototype.recv_getRSAKey = function(input,mtype,rseqid) { 850 | var callback = this._reqs[rseqid] || function() {}; 851 | delete this._reqs[rseqid]; 852 | if (mtype == Thrift.MessageType.EXCEPTION) { 853 | var x = new Thrift.TApplicationException(); 854 | x.read(input); 855 | input.readMessageEnd(); 856 | return callback(x); 857 | } 858 | var result = new AccountSupervisorService_getRSAKey_result(); 859 | result.read(input); 860 | input.readMessageEnd(); 861 | 862 | if (null !== result.e) { 863 | return callback(result.e); 864 | } 865 | if (null !== result.success) { 866 | return callback(null, result.success); 867 | } 868 | return callback('getRSAKey failed: unknown result'); 869 | }; 870 | AccountSupervisorServiceClient.prototype.notifyEmailConfirmationResult = function(parameterMap, callback) { 871 | this._seqid = this.new_seqid(); 872 | if (callback === undefined) { 873 | var _defer = Q.defer(); 874 | this._reqs[this.seqid()] = function(error, result) { 875 | if (error) { 876 | _defer.reject(error); 877 | } else { 878 | _defer.resolve(result); 879 | } 880 | }; 881 | this.send_notifyEmailConfirmationResult(parameterMap); 882 | return _defer.promise; 883 | } else { 884 | this._reqs[this.seqid()] = callback; 885 | this.send_notifyEmailConfirmationResult(parameterMap); 886 | } 887 | }; 888 | 889 | AccountSupervisorServiceClient.prototype.send_notifyEmailConfirmationResult = function(parameterMap) { 890 | var output = new this.pClass(this.output); 891 | output.writeMessageBegin('notifyEmailConfirmationResult', Thrift.MessageType.CALL, this.seqid()); 892 | var args = new AccountSupervisorService_notifyEmailConfirmationResult_args(); 893 | args.parameterMap = parameterMap; 894 | args.write(output); 895 | output.writeMessageEnd(); 896 | return this.output.flush(); 897 | }; 898 | 899 | AccountSupervisorServiceClient.prototype.recv_notifyEmailConfirmationResult = function(input,mtype,rseqid) { 900 | var callback = this._reqs[rseqid] || function() {}; 901 | delete this._reqs[rseqid]; 902 | if (mtype == Thrift.MessageType.EXCEPTION) { 903 | var x = new Thrift.TApplicationException(); 904 | x.read(input); 905 | input.readMessageEnd(); 906 | return callback(x); 907 | } 908 | var result = new AccountSupervisorService_notifyEmailConfirmationResult_result(); 909 | result.read(input); 910 | input.readMessageEnd(); 911 | 912 | if (null !== result.e) { 913 | return callback(result.e); 914 | } 915 | callback(null) 916 | }; 917 | AccountSupervisorServiceClient.prototype.registerVirtualAccount = function(locale, encryptedVirtualUserId, encryptedPassword, callback) { 918 | this._seqid = this.new_seqid(); 919 | if (callback === undefined) { 920 | var _defer = Q.defer(); 921 | this._reqs[this.seqid()] = function(error, result) { 922 | if (error) { 923 | _defer.reject(error); 924 | } else { 925 | _defer.resolve(result); 926 | } 927 | }; 928 | this.send_registerVirtualAccount(locale, encryptedVirtualUserId, encryptedPassword); 929 | return _defer.promise; 930 | } else { 931 | this._reqs[this.seqid()] = callback; 932 | this.send_registerVirtualAccount(locale, encryptedVirtualUserId, encryptedPassword); 933 | } 934 | }; 935 | 936 | AccountSupervisorServiceClient.prototype.send_registerVirtualAccount = function(locale, encryptedVirtualUserId, encryptedPassword) { 937 | var output = new this.pClass(this.output); 938 | output.writeMessageBegin('registerVirtualAccount', Thrift.MessageType.CALL, this.seqid()); 939 | var args = new AccountSupervisorService_registerVirtualAccount_args(); 940 | args.locale = locale; 941 | args.encryptedVirtualUserId = encryptedVirtualUserId; 942 | args.encryptedPassword = encryptedPassword; 943 | args.write(output); 944 | output.writeMessageEnd(); 945 | return this.output.flush(); 946 | }; 947 | 948 | AccountSupervisorServiceClient.prototype.recv_registerVirtualAccount = function(input,mtype,rseqid) { 949 | var callback = this._reqs[rseqid] || function() {}; 950 | delete this._reqs[rseqid]; 951 | if (mtype == Thrift.MessageType.EXCEPTION) { 952 | var x = new Thrift.TApplicationException(); 953 | x.read(input); 954 | input.readMessageEnd(); 955 | return callback(x); 956 | } 957 | var result = new AccountSupervisorService_registerVirtualAccount_result(); 958 | result.read(input); 959 | input.readMessageEnd(); 960 | 961 | if (null !== result.e) { 962 | return callback(result.e); 963 | } 964 | if (null !== result.success) { 965 | return callback(null, result.success); 966 | } 967 | return callback('registerVirtualAccount failed: unknown result'); 968 | }; 969 | AccountSupervisorServiceClient.prototype.requestVirtualAccountPasswordChange = function(virtualMid, encryptedVirtualUserId, encryptedOldPassword, encryptedNewPassword, callback) { 970 | this._seqid = this.new_seqid(); 971 | if (callback === undefined) { 972 | var _defer = Q.defer(); 973 | this._reqs[this.seqid()] = function(error, result) { 974 | if (error) { 975 | _defer.reject(error); 976 | } else { 977 | _defer.resolve(result); 978 | } 979 | }; 980 | this.send_requestVirtualAccountPasswordChange(virtualMid, encryptedVirtualUserId, encryptedOldPassword, encryptedNewPassword); 981 | return _defer.promise; 982 | } else { 983 | this._reqs[this.seqid()] = callback; 984 | this.send_requestVirtualAccountPasswordChange(virtualMid, encryptedVirtualUserId, encryptedOldPassword, encryptedNewPassword); 985 | } 986 | }; 987 | 988 | AccountSupervisorServiceClient.prototype.send_requestVirtualAccountPasswordChange = function(virtualMid, encryptedVirtualUserId, encryptedOldPassword, encryptedNewPassword) { 989 | var output = new this.pClass(this.output); 990 | output.writeMessageBegin('requestVirtualAccountPasswordChange', Thrift.MessageType.CALL, this.seqid()); 991 | var args = new AccountSupervisorService_requestVirtualAccountPasswordChange_args(); 992 | args.virtualMid = virtualMid; 993 | args.encryptedVirtualUserId = encryptedVirtualUserId; 994 | args.encryptedOldPassword = encryptedOldPassword; 995 | args.encryptedNewPassword = encryptedNewPassword; 996 | args.write(output); 997 | output.writeMessageEnd(); 998 | return this.output.flush(); 999 | }; 1000 | 1001 | AccountSupervisorServiceClient.prototype.recv_requestVirtualAccountPasswordChange = function(input,mtype,rseqid) { 1002 | var callback = this._reqs[rseqid] || function() {}; 1003 | delete this._reqs[rseqid]; 1004 | if (mtype == Thrift.MessageType.EXCEPTION) { 1005 | var x = new Thrift.TApplicationException(); 1006 | x.read(input); 1007 | input.readMessageEnd(); 1008 | return callback(x); 1009 | } 1010 | var result = new AccountSupervisorService_requestVirtualAccountPasswordChange_result(); 1011 | result.read(input); 1012 | input.readMessageEnd(); 1013 | 1014 | if (null !== result.e) { 1015 | return callback(result.e); 1016 | } 1017 | callback(null) 1018 | }; 1019 | AccountSupervisorServiceClient.prototype.requestVirtualAccountPasswordSet = function(virtualMid, encryptedVirtualUserId, encryptedNewPassword, callback) { 1020 | this._seqid = this.new_seqid(); 1021 | if (callback === undefined) { 1022 | var _defer = Q.defer(); 1023 | this._reqs[this.seqid()] = function(error, result) { 1024 | if (error) { 1025 | _defer.reject(error); 1026 | } else { 1027 | _defer.resolve(result); 1028 | } 1029 | }; 1030 | this.send_requestVirtualAccountPasswordSet(virtualMid, encryptedVirtualUserId, encryptedNewPassword); 1031 | return _defer.promise; 1032 | } else { 1033 | this._reqs[this.seqid()] = callback; 1034 | this.send_requestVirtualAccountPasswordSet(virtualMid, encryptedVirtualUserId, encryptedNewPassword); 1035 | } 1036 | }; 1037 | 1038 | AccountSupervisorServiceClient.prototype.send_requestVirtualAccountPasswordSet = function(virtualMid, encryptedVirtualUserId, encryptedNewPassword) { 1039 | var output = new this.pClass(this.output); 1040 | output.writeMessageBegin('requestVirtualAccountPasswordSet', Thrift.MessageType.CALL, this.seqid()); 1041 | var args = new AccountSupervisorService_requestVirtualAccountPasswordSet_args(); 1042 | args.virtualMid = virtualMid; 1043 | args.encryptedVirtualUserId = encryptedVirtualUserId; 1044 | args.encryptedNewPassword = encryptedNewPassword; 1045 | args.write(output); 1046 | output.writeMessageEnd(); 1047 | return this.output.flush(); 1048 | }; 1049 | 1050 | AccountSupervisorServiceClient.prototype.recv_requestVirtualAccountPasswordSet = function(input,mtype,rseqid) { 1051 | var callback = this._reqs[rseqid] || function() {}; 1052 | delete this._reqs[rseqid]; 1053 | if (mtype == Thrift.MessageType.EXCEPTION) { 1054 | var x = new Thrift.TApplicationException(); 1055 | x.read(input); 1056 | input.readMessageEnd(); 1057 | return callback(x); 1058 | } 1059 | var result = new AccountSupervisorService_requestVirtualAccountPasswordSet_result(); 1060 | result.read(input); 1061 | input.readMessageEnd(); 1062 | 1063 | if (null !== result.e) { 1064 | return callback(result.e); 1065 | } 1066 | callback(null) 1067 | }; 1068 | AccountSupervisorServiceClient.prototype.unregisterVirtualAccount = function(virtualMid, callback) { 1069 | this._seqid = this.new_seqid(); 1070 | if (callback === undefined) { 1071 | var _defer = Q.defer(); 1072 | this._reqs[this.seqid()] = function(error, result) { 1073 | if (error) { 1074 | _defer.reject(error); 1075 | } else { 1076 | _defer.resolve(result); 1077 | } 1078 | }; 1079 | this.send_unregisterVirtualAccount(virtualMid); 1080 | return _defer.promise; 1081 | } else { 1082 | this._reqs[this.seqid()] = callback; 1083 | this.send_unregisterVirtualAccount(virtualMid); 1084 | } 1085 | }; 1086 | 1087 | AccountSupervisorServiceClient.prototype.send_unregisterVirtualAccount = function(virtualMid) { 1088 | var output = new this.pClass(this.output); 1089 | output.writeMessageBegin('unregisterVirtualAccount', Thrift.MessageType.CALL, this.seqid()); 1090 | var args = new AccountSupervisorService_unregisterVirtualAccount_args(); 1091 | args.virtualMid = virtualMid; 1092 | args.write(output); 1093 | output.writeMessageEnd(); 1094 | return this.output.flush(); 1095 | }; 1096 | 1097 | AccountSupervisorServiceClient.prototype.recv_unregisterVirtualAccount = function(input,mtype,rseqid) { 1098 | var callback = this._reqs[rseqid] || function() {}; 1099 | delete this._reqs[rseqid]; 1100 | if (mtype == Thrift.MessageType.EXCEPTION) { 1101 | var x = new Thrift.TApplicationException(); 1102 | x.read(input); 1103 | input.readMessageEnd(); 1104 | return callback(x); 1105 | } 1106 | var result = new AccountSupervisorService_unregisterVirtualAccount_result(); 1107 | result.read(input); 1108 | input.readMessageEnd(); 1109 | 1110 | if (null !== result.e) { 1111 | return callback(result.e); 1112 | } 1113 | callback(null) 1114 | }; 1115 | AccountSupervisorServiceProcessor = exports.Processor = function(handler) { 1116 | this._handler = handler 1117 | } 1118 | AccountSupervisorServiceProcessor.prototype.process = function(input, output) { 1119 | var r = input.readMessageBegin(); 1120 | if (this['process_' + r.fname]) { 1121 | return this['process_' + r.fname].call(this, r.rseqid, input, output); 1122 | } else { 1123 | input.skip(Thrift.Type.STRUCT); 1124 | input.readMessageEnd(); 1125 | var x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname); 1126 | output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid); 1127 | x.write(output); 1128 | output.writeMessageEnd(); 1129 | output.flush(); 1130 | } 1131 | } 1132 | 1133 | AccountSupervisorServiceProcessor.prototype.process_getRSAKey = function(seqid, input, output) { 1134 | var args = new AccountSupervisorService_getRSAKey_args(); 1135 | args.read(input); 1136 | input.readMessageEnd(); 1137 | if (this._handler.getRSAKey.length === 0) { 1138 | Q.fcall(this._handler.getRSAKey) 1139 | .then(function(result) { 1140 | var result = new AccountSupervisorService_getRSAKey_result({success: result}); 1141 | output.writeMessageBegin("getRSAKey", Thrift.MessageType.REPLY, seqid); 1142 | result.write(output); 1143 | output.writeMessageEnd(); 1144 | output.flush(); 1145 | }, function (err) { 1146 | var result = new AccountSupervisorService_getRSAKey_result(err); 1147 | output.writeMessageBegin("getRSAKey", Thrift.MessageType.REPLY, seqid); 1148 | result.write(output); 1149 | output.writeMessageEnd(); 1150 | output.flush(); 1151 | }); 1152 | } else { 1153 | this._handler.getRSAKey( function (err, result) { 1154 | var result = new AccountSupervisorService_getRSAKey_result((err != null ? err : {success: result})); 1155 | output.writeMessageBegin("getRSAKey", Thrift.MessageType.REPLY, seqid); 1156 | result.write(output); 1157 | output.writeMessageEnd(); 1158 | output.flush(); 1159 | }); 1160 | } 1161 | } 1162 | 1163 | AccountSupervisorServiceProcessor.prototype.process_notifyEmailConfirmationResult = function(seqid, input, output) { 1164 | var args = new AccountSupervisorService_notifyEmailConfirmationResult_args(); 1165 | args.read(input); 1166 | input.readMessageEnd(); 1167 | if (this._handler.notifyEmailConfirmationResult.length === 1) { 1168 | Q.fcall(this._handler.notifyEmailConfirmationResult, args.parameterMap) 1169 | .then(function(result) { 1170 | var result = new AccountSupervisorService_notifyEmailConfirmationResult_result({success: result}); 1171 | output.writeMessageBegin("notifyEmailConfirmationResult", Thrift.MessageType.REPLY, seqid); 1172 | result.write(output); 1173 | output.writeMessageEnd(); 1174 | output.flush(); 1175 | }, function (err) { 1176 | var result = new AccountSupervisorService_notifyEmailConfirmationResult_result(err); 1177 | output.writeMessageBegin("notifyEmailConfirmationResult", Thrift.MessageType.REPLY, seqid); 1178 | result.write(output); 1179 | output.writeMessageEnd(); 1180 | output.flush(); 1181 | }); 1182 | } else { 1183 | this._handler.notifyEmailConfirmationResult(args.parameterMap, function (err, result) { 1184 | var result = new AccountSupervisorService_notifyEmailConfirmationResult_result((err != null ? err : {success: result})); 1185 | output.writeMessageBegin("notifyEmailConfirmationResult", Thrift.MessageType.REPLY, seqid); 1186 | result.write(output); 1187 | output.writeMessageEnd(); 1188 | output.flush(); 1189 | }); 1190 | } 1191 | } 1192 | 1193 | AccountSupervisorServiceProcessor.prototype.process_registerVirtualAccount = function(seqid, input, output) { 1194 | var args = new AccountSupervisorService_registerVirtualAccount_args(); 1195 | args.read(input); 1196 | input.readMessageEnd(); 1197 | if (this._handler.registerVirtualAccount.length === 3) { 1198 | Q.fcall(this._handler.registerVirtualAccount, args.locale, args.encryptedVirtualUserId, args.encryptedPassword) 1199 | .then(function(result) { 1200 | var result = new AccountSupervisorService_registerVirtualAccount_result({success: result}); 1201 | output.writeMessageBegin("registerVirtualAccount", Thrift.MessageType.REPLY, seqid); 1202 | result.write(output); 1203 | output.writeMessageEnd(); 1204 | output.flush(); 1205 | }, function (err) { 1206 | var result = new AccountSupervisorService_registerVirtualAccount_result(err); 1207 | output.writeMessageBegin("registerVirtualAccount", Thrift.MessageType.REPLY, seqid); 1208 | result.write(output); 1209 | output.writeMessageEnd(); 1210 | output.flush(); 1211 | }); 1212 | } else { 1213 | this._handler.registerVirtualAccount(args.locale, args.encryptedVirtualUserId, args.encryptedPassword, function (err, result) { 1214 | var result = new AccountSupervisorService_registerVirtualAccount_result((err != null ? err : {success: result})); 1215 | output.writeMessageBegin("registerVirtualAccount", Thrift.MessageType.REPLY, seqid); 1216 | result.write(output); 1217 | output.writeMessageEnd(); 1218 | output.flush(); 1219 | }); 1220 | } 1221 | } 1222 | 1223 | AccountSupervisorServiceProcessor.prototype.process_requestVirtualAccountPasswordChange = function(seqid, input, output) { 1224 | var args = new AccountSupervisorService_requestVirtualAccountPasswordChange_args(); 1225 | args.read(input); 1226 | input.readMessageEnd(); 1227 | if (this._handler.requestVirtualAccountPasswordChange.length === 4) { 1228 | Q.fcall(this._handler.requestVirtualAccountPasswordChange, args.virtualMid, args.encryptedVirtualUserId, args.encryptedOldPassword, args.encryptedNewPassword) 1229 | .then(function(result) { 1230 | var result = new AccountSupervisorService_requestVirtualAccountPasswordChange_result({success: result}); 1231 | output.writeMessageBegin("requestVirtualAccountPasswordChange", Thrift.MessageType.REPLY, seqid); 1232 | result.write(output); 1233 | output.writeMessageEnd(); 1234 | output.flush(); 1235 | }, function (err) { 1236 | var result = new AccountSupervisorService_requestVirtualAccountPasswordChange_result(err); 1237 | output.writeMessageBegin("requestVirtualAccountPasswordChange", Thrift.MessageType.REPLY, seqid); 1238 | result.write(output); 1239 | output.writeMessageEnd(); 1240 | output.flush(); 1241 | }); 1242 | } else { 1243 | this._handler.requestVirtualAccountPasswordChange(args.virtualMid, args.encryptedVirtualUserId, args.encryptedOldPassword, args.encryptedNewPassword, function (err, result) { 1244 | var result = new AccountSupervisorService_requestVirtualAccountPasswordChange_result((err != null ? err : {success: result})); 1245 | output.writeMessageBegin("requestVirtualAccountPasswordChange", Thrift.MessageType.REPLY, seqid); 1246 | result.write(output); 1247 | output.writeMessageEnd(); 1248 | output.flush(); 1249 | }); 1250 | } 1251 | } 1252 | 1253 | AccountSupervisorServiceProcessor.prototype.process_requestVirtualAccountPasswordSet = function(seqid, input, output) { 1254 | var args = new AccountSupervisorService_requestVirtualAccountPasswordSet_args(); 1255 | args.read(input); 1256 | input.readMessageEnd(); 1257 | if (this._handler.requestVirtualAccountPasswordSet.length === 3) { 1258 | Q.fcall(this._handler.requestVirtualAccountPasswordSet, args.virtualMid, args.encryptedVirtualUserId, args.encryptedNewPassword) 1259 | .then(function(result) { 1260 | var result = new AccountSupervisorService_requestVirtualAccountPasswordSet_result({success: result}); 1261 | output.writeMessageBegin("requestVirtualAccountPasswordSet", Thrift.MessageType.REPLY, seqid); 1262 | result.write(output); 1263 | output.writeMessageEnd(); 1264 | output.flush(); 1265 | }, function (err) { 1266 | var result = new AccountSupervisorService_requestVirtualAccountPasswordSet_result(err); 1267 | output.writeMessageBegin("requestVirtualAccountPasswordSet", Thrift.MessageType.REPLY, seqid); 1268 | result.write(output); 1269 | output.writeMessageEnd(); 1270 | output.flush(); 1271 | }); 1272 | } else { 1273 | this._handler.requestVirtualAccountPasswordSet(args.virtualMid, args.encryptedVirtualUserId, args.encryptedNewPassword, function (err, result) { 1274 | var result = new AccountSupervisorService_requestVirtualAccountPasswordSet_result((err != null ? err : {success: result})); 1275 | output.writeMessageBegin("requestVirtualAccountPasswordSet", Thrift.MessageType.REPLY, seqid); 1276 | result.write(output); 1277 | output.writeMessageEnd(); 1278 | output.flush(); 1279 | }); 1280 | } 1281 | } 1282 | 1283 | AccountSupervisorServiceProcessor.prototype.process_unregisterVirtualAccount = function(seqid, input, output) { 1284 | var args = new AccountSupervisorService_unregisterVirtualAccount_args(); 1285 | args.read(input); 1286 | input.readMessageEnd(); 1287 | if (this._handler.unregisterVirtualAccount.length === 1) { 1288 | Q.fcall(this._handler.unregisterVirtualAccount, args.virtualMid) 1289 | .then(function(result) { 1290 | var result = new AccountSupervisorService_unregisterVirtualAccount_result({success: result}); 1291 | output.writeMessageBegin("unregisterVirtualAccount", Thrift.MessageType.REPLY, seqid); 1292 | result.write(output); 1293 | output.writeMessageEnd(); 1294 | output.flush(); 1295 | }, function (err) { 1296 | var result = new AccountSupervisorService_unregisterVirtualAccount_result(err); 1297 | output.writeMessageBegin("unregisterVirtualAccount", Thrift.MessageType.REPLY, seqid); 1298 | result.write(output); 1299 | output.writeMessageEnd(); 1300 | output.flush(); 1301 | }); 1302 | } else { 1303 | this._handler.unregisterVirtualAccount(args.virtualMid, function (err, result) { 1304 | var result = new AccountSupervisorService_unregisterVirtualAccount_result((err != null ? err : {success: result})); 1305 | output.writeMessageBegin("unregisterVirtualAccount", Thrift.MessageType.REPLY, seqid); 1306 | result.write(output); 1307 | output.writeMessageEnd(); 1308 | output.flush(); 1309 | }); 1310 | } 1311 | } 1312 | 1313 | -------------------------------------------------------------------------------- /lib/gen-nodejs/AgeCheckService.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift Compiler (0.9.2) 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | var thrift = require('thrift'); 7 | var Thrift = thrift.Thrift; 8 | var Q = thrift.Q; 9 | 10 | 11 | var ttypes = require('./line_types'); 12 | //HELPER FUNCTIONS AND STRUCTURES 13 | 14 | AgeCheckService_checkUserAge_args = function(args) { 15 | this.carrier = null; 16 | this.sessionId = null; 17 | this.verifier = null; 18 | this.standardAge = null; 19 | if (args) { 20 | if (args.carrier !== undefined) { 21 | this.carrier = args.carrier; 22 | } 23 | if (args.sessionId !== undefined) { 24 | this.sessionId = args.sessionId; 25 | } 26 | if (args.verifier !== undefined) { 27 | this.verifier = args.verifier; 28 | } 29 | if (args.standardAge !== undefined) { 30 | this.standardAge = args.standardAge; 31 | } 32 | } 33 | }; 34 | AgeCheckService_checkUserAge_args.prototype = {}; 35 | AgeCheckService_checkUserAge_args.prototype.read = function(input) { 36 | input.readStructBegin(); 37 | while (true) 38 | { 39 | var ret = input.readFieldBegin(); 40 | var fname = ret.fname; 41 | var ftype = ret.ftype; 42 | var fid = ret.fid; 43 | if (ftype == Thrift.Type.STOP) { 44 | break; 45 | } 46 | switch (fid) 47 | { 48 | case 2: 49 | if (ftype == Thrift.Type.I32) { 50 | this.carrier = input.readI32(); 51 | } else { 52 | input.skip(ftype); 53 | } 54 | break; 55 | case 3: 56 | if (ftype == Thrift.Type.STRING) { 57 | this.sessionId = input.readString(); 58 | } else { 59 | input.skip(ftype); 60 | } 61 | break; 62 | case 4: 63 | if (ftype == Thrift.Type.STRING) { 64 | this.verifier = input.readString(); 65 | } else { 66 | input.skip(ftype); 67 | } 68 | break; 69 | case 5: 70 | if (ftype == Thrift.Type.I32) { 71 | this.standardAge = input.readI32(); 72 | } else { 73 | input.skip(ftype); 74 | } 75 | break; 76 | default: 77 | input.skip(ftype); 78 | } 79 | input.readFieldEnd(); 80 | } 81 | input.readStructEnd(); 82 | return; 83 | }; 84 | 85 | AgeCheckService_checkUserAge_args.prototype.write = function(output) { 86 | output.writeStructBegin('AgeCheckService_checkUserAge_args'); 87 | if (this.carrier !== null && this.carrier !== undefined) { 88 | output.writeFieldBegin('carrier', Thrift.Type.I32, 2); 89 | output.writeI32(this.carrier); 90 | output.writeFieldEnd(); 91 | } 92 | if (this.sessionId !== null && this.sessionId !== undefined) { 93 | output.writeFieldBegin('sessionId', Thrift.Type.STRING, 3); 94 | output.writeString(this.sessionId); 95 | output.writeFieldEnd(); 96 | } 97 | if (this.verifier !== null && this.verifier !== undefined) { 98 | output.writeFieldBegin('verifier', Thrift.Type.STRING, 4); 99 | output.writeString(this.verifier); 100 | output.writeFieldEnd(); 101 | } 102 | if (this.standardAge !== null && this.standardAge !== undefined) { 103 | output.writeFieldBegin('standardAge', Thrift.Type.I32, 5); 104 | output.writeI32(this.standardAge); 105 | output.writeFieldEnd(); 106 | } 107 | output.writeFieldStop(); 108 | output.writeStructEnd(); 109 | return; 110 | }; 111 | 112 | AgeCheckService_checkUserAge_result = function(args) { 113 | this.success = null; 114 | this.e = null; 115 | if (args instanceof ttypes.TalkException) { 116 | this.e = args; 117 | return; 118 | } 119 | if (args) { 120 | if (args.success !== undefined) { 121 | this.success = args.success; 122 | } 123 | if (args.e !== undefined) { 124 | this.e = args.e; 125 | } 126 | } 127 | }; 128 | AgeCheckService_checkUserAge_result.prototype = {}; 129 | AgeCheckService_checkUserAge_result.prototype.read = function(input) { 130 | input.readStructBegin(); 131 | while (true) 132 | { 133 | var ret = input.readFieldBegin(); 134 | var fname = ret.fname; 135 | var ftype = ret.ftype; 136 | var fid = ret.fid; 137 | if (ftype == Thrift.Type.STOP) { 138 | break; 139 | } 140 | switch (fid) 141 | { 142 | case 0: 143 | if (ftype == Thrift.Type.I32) { 144 | this.success = input.readI32(); 145 | } else { 146 | input.skip(ftype); 147 | } 148 | break; 149 | case 1: 150 | if (ftype == Thrift.Type.STRUCT) { 151 | this.e = new ttypes.TalkException(); 152 | this.e.read(input); 153 | } else { 154 | input.skip(ftype); 155 | } 156 | break; 157 | default: 158 | input.skip(ftype); 159 | } 160 | input.readFieldEnd(); 161 | } 162 | input.readStructEnd(); 163 | return; 164 | }; 165 | 166 | AgeCheckService_checkUserAge_result.prototype.write = function(output) { 167 | output.writeStructBegin('AgeCheckService_checkUserAge_result'); 168 | if (this.success !== null && this.success !== undefined) { 169 | output.writeFieldBegin('success', Thrift.Type.I32, 0); 170 | output.writeI32(this.success); 171 | output.writeFieldEnd(); 172 | } 173 | if (this.e !== null && this.e !== undefined) { 174 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 175 | this.e.write(output); 176 | output.writeFieldEnd(); 177 | } 178 | output.writeFieldStop(); 179 | output.writeStructEnd(); 180 | return; 181 | }; 182 | 183 | AgeCheckService_checkUserAgeWithDocomo_args = function(args) { 184 | this.openIdRedirectUrl = null; 185 | this.standardAge = null; 186 | this.verifier = null; 187 | if (args) { 188 | if (args.openIdRedirectUrl !== undefined) { 189 | this.openIdRedirectUrl = args.openIdRedirectUrl; 190 | } 191 | if (args.standardAge !== undefined) { 192 | this.standardAge = args.standardAge; 193 | } 194 | if (args.verifier !== undefined) { 195 | this.verifier = args.verifier; 196 | } 197 | } 198 | }; 199 | AgeCheckService_checkUserAgeWithDocomo_args.prototype = {}; 200 | AgeCheckService_checkUserAgeWithDocomo_args.prototype.read = function(input) { 201 | input.readStructBegin(); 202 | while (true) 203 | { 204 | var ret = input.readFieldBegin(); 205 | var fname = ret.fname; 206 | var ftype = ret.ftype; 207 | var fid = ret.fid; 208 | if (ftype == Thrift.Type.STOP) { 209 | break; 210 | } 211 | switch (fid) 212 | { 213 | case 2: 214 | if (ftype == Thrift.Type.STRING) { 215 | this.openIdRedirectUrl = input.readString(); 216 | } else { 217 | input.skip(ftype); 218 | } 219 | break; 220 | case 3: 221 | if (ftype == Thrift.Type.I32) { 222 | this.standardAge = input.readI32(); 223 | } else { 224 | input.skip(ftype); 225 | } 226 | break; 227 | case 4: 228 | if (ftype == Thrift.Type.STRING) { 229 | this.verifier = input.readString(); 230 | } else { 231 | input.skip(ftype); 232 | } 233 | break; 234 | default: 235 | input.skip(ftype); 236 | } 237 | input.readFieldEnd(); 238 | } 239 | input.readStructEnd(); 240 | return; 241 | }; 242 | 243 | AgeCheckService_checkUserAgeWithDocomo_args.prototype.write = function(output) { 244 | output.writeStructBegin('AgeCheckService_checkUserAgeWithDocomo_args'); 245 | if (this.openIdRedirectUrl !== null && this.openIdRedirectUrl !== undefined) { 246 | output.writeFieldBegin('openIdRedirectUrl', Thrift.Type.STRING, 2); 247 | output.writeString(this.openIdRedirectUrl); 248 | output.writeFieldEnd(); 249 | } 250 | if (this.standardAge !== null && this.standardAge !== undefined) { 251 | output.writeFieldBegin('standardAge', Thrift.Type.I32, 3); 252 | output.writeI32(this.standardAge); 253 | output.writeFieldEnd(); 254 | } 255 | if (this.verifier !== null && this.verifier !== undefined) { 256 | output.writeFieldBegin('verifier', Thrift.Type.STRING, 4); 257 | output.writeString(this.verifier); 258 | output.writeFieldEnd(); 259 | } 260 | output.writeFieldStop(); 261 | output.writeStructEnd(); 262 | return; 263 | }; 264 | 265 | AgeCheckService_checkUserAgeWithDocomo_result = function(args) { 266 | this.success = null; 267 | this.e = null; 268 | if (args instanceof ttypes.TalkException) { 269 | this.e = args; 270 | return; 271 | } 272 | if (args) { 273 | if (args.success !== undefined) { 274 | this.success = args.success; 275 | } 276 | if (args.e !== undefined) { 277 | this.e = args.e; 278 | } 279 | } 280 | }; 281 | AgeCheckService_checkUserAgeWithDocomo_result.prototype = {}; 282 | AgeCheckService_checkUserAgeWithDocomo_result.prototype.read = function(input) { 283 | input.readStructBegin(); 284 | while (true) 285 | { 286 | var ret = input.readFieldBegin(); 287 | var fname = ret.fname; 288 | var ftype = ret.ftype; 289 | var fid = ret.fid; 290 | if (ftype == Thrift.Type.STOP) { 291 | break; 292 | } 293 | switch (fid) 294 | { 295 | case 0: 296 | if (ftype == Thrift.Type.STRUCT) { 297 | this.success = new ttypes.AgeCheckDocomoResult(); 298 | this.success.read(input); 299 | } else { 300 | input.skip(ftype); 301 | } 302 | break; 303 | case 1: 304 | if (ftype == Thrift.Type.STRUCT) { 305 | this.e = new ttypes.TalkException(); 306 | this.e.read(input); 307 | } else { 308 | input.skip(ftype); 309 | } 310 | break; 311 | default: 312 | input.skip(ftype); 313 | } 314 | input.readFieldEnd(); 315 | } 316 | input.readStructEnd(); 317 | return; 318 | }; 319 | 320 | AgeCheckService_checkUserAgeWithDocomo_result.prototype.write = function(output) { 321 | output.writeStructBegin('AgeCheckService_checkUserAgeWithDocomo_result'); 322 | if (this.success !== null && this.success !== undefined) { 323 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0); 324 | this.success.write(output); 325 | output.writeFieldEnd(); 326 | } 327 | if (this.e !== null && this.e !== undefined) { 328 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 329 | this.e.write(output); 330 | output.writeFieldEnd(); 331 | } 332 | output.writeFieldStop(); 333 | output.writeStructEnd(); 334 | return; 335 | }; 336 | 337 | AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_args = function(args) { 338 | }; 339 | AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_args.prototype = {}; 340 | AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_args.prototype.read = function(input) { 341 | input.readStructBegin(); 342 | while (true) 343 | { 344 | var ret = input.readFieldBegin(); 345 | var fname = ret.fname; 346 | var ftype = ret.ftype; 347 | var fid = ret.fid; 348 | if (ftype == Thrift.Type.STOP) { 349 | break; 350 | } 351 | input.skip(ftype); 352 | input.readFieldEnd(); 353 | } 354 | input.readStructEnd(); 355 | return; 356 | }; 357 | 358 | AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_args.prototype.write = function(output) { 359 | output.writeStructBegin('AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_args'); 360 | output.writeFieldStop(); 361 | output.writeStructEnd(); 362 | return; 363 | }; 364 | 365 | AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_result = function(args) { 366 | this.success = null; 367 | this.e = null; 368 | if (args instanceof ttypes.TalkException) { 369 | this.e = args; 370 | return; 371 | } 372 | if (args) { 373 | if (args.success !== undefined) { 374 | this.success = args.success; 375 | } 376 | if (args.e !== undefined) { 377 | this.e = args.e; 378 | } 379 | } 380 | }; 381 | AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_result.prototype = {}; 382 | AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_result.prototype.read = function(input) { 383 | input.readStructBegin(); 384 | while (true) 385 | { 386 | var ret = input.readFieldBegin(); 387 | var fname = ret.fname; 388 | var ftype = ret.ftype; 389 | var fid = ret.fid; 390 | if (ftype == Thrift.Type.STOP) { 391 | break; 392 | } 393 | switch (fid) 394 | { 395 | case 0: 396 | if (ftype == Thrift.Type.STRING) { 397 | this.success = input.readString(); 398 | } else { 399 | input.skip(ftype); 400 | } 401 | break; 402 | case 1: 403 | if (ftype == Thrift.Type.STRUCT) { 404 | this.e = new ttypes.TalkException(); 405 | this.e.read(input); 406 | } else { 407 | input.skip(ftype); 408 | } 409 | break; 410 | default: 411 | input.skip(ftype); 412 | } 413 | input.readFieldEnd(); 414 | } 415 | input.readStructEnd(); 416 | return; 417 | }; 418 | 419 | AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_result.prototype.write = function(output) { 420 | output.writeStructBegin('AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_result'); 421 | if (this.success !== null && this.success !== undefined) { 422 | output.writeFieldBegin('success', Thrift.Type.STRING, 0); 423 | output.writeString(this.success); 424 | output.writeFieldEnd(); 425 | } 426 | if (this.e !== null && this.e !== undefined) { 427 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 428 | this.e.write(output); 429 | output.writeFieldEnd(); 430 | } 431 | output.writeFieldStop(); 432 | output.writeStructEnd(); 433 | return; 434 | }; 435 | 436 | AgeCheckService_retrieveRequestToken_args = function(args) { 437 | this.carrier = null; 438 | if (args) { 439 | if (args.carrier !== undefined) { 440 | this.carrier = args.carrier; 441 | } 442 | } 443 | }; 444 | AgeCheckService_retrieveRequestToken_args.prototype = {}; 445 | AgeCheckService_retrieveRequestToken_args.prototype.read = function(input) { 446 | input.readStructBegin(); 447 | while (true) 448 | { 449 | var ret = input.readFieldBegin(); 450 | var fname = ret.fname; 451 | var ftype = ret.ftype; 452 | var fid = ret.fid; 453 | if (ftype == Thrift.Type.STOP) { 454 | break; 455 | } 456 | switch (fid) 457 | { 458 | case 2: 459 | if (ftype == Thrift.Type.I32) { 460 | this.carrier = input.readI32(); 461 | } else { 462 | input.skip(ftype); 463 | } 464 | break; 465 | case 0: 466 | input.skip(ftype); 467 | break; 468 | default: 469 | input.skip(ftype); 470 | } 471 | input.readFieldEnd(); 472 | } 473 | input.readStructEnd(); 474 | return; 475 | }; 476 | 477 | AgeCheckService_retrieveRequestToken_args.prototype.write = function(output) { 478 | output.writeStructBegin('AgeCheckService_retrieveRequestToken_args'); 479 | if (this.carrier !== null && this.carrier !== undefined) { 480 | output.writeFieldBegin('carrier', Thrift.Type.I32, 2); 481 | output.writeI32(this.carrier); 482 | output.writeFieldEnd(); 483 | } 484 | output.writeFieldStop(); 485 | output.writeStructEnd(); 486 | return; 487 | }; 488 | 489 | AgeCheckService_retrieveRequestToken_result = function(args) { 490 | this.success = null; 491 | this.e = null; 492 | if (args instanceof ttypes.TalkException) { 493 | this.e = args; 494 | return; 495 | } 496 | if (args) { 497 | if (args.success !== undefined) { 498 | this.success = args.success; 499 | } 500 | if (args.e !== undefined) { 501 | this.e = args.e; 502 | } 503 | } 504 | }; 505 | AgeCheckService_retrieveRequestToken_result.prototype = {}; 506 | AgeCheckService_retrieveRequestToken_result.prototype.read = function(input) { 507 | input.readStructBegin(); 508 | while (true) 509 | { 510 | var ret = input.readFieldBegin(); 511 | var fname = ret.fname; 512 | var ftype = ret.ftype; 513 | var fid = ret.fid; 514 | if (ftype == Thrift.Type.STOP) { 515 | break; 516 | } 517 | switch (fid) 518 | { 519 | case 0: 520 | if (ftype == Thrift.Type.STRUCT) { 521 | this.success = new ttypes.AgeCheckRequestResult(); 522 | this.success.read(input); 523 | } else { 524 | input.skip(ftype); 525 | } 526 | break; 527 | case 1: 528 | if (ftype == Thrift.Type.STRUCT) { 529 | this.e = new ttypes.TalkException(); 530 | this.e.read(input); 531 | } else { 532 | input.skip(ftype); 533 | } 534 | break; 535 | default: 536 | input.skip(ftype); 537 | } 538 | input.readFieldEnd(); 539 | } 540 | input.readStructEnd(); 541 | return; 542 | }; 543 | 544 | AgeCheckService_retrieveRequestToken_result.prototype.write = function(output) { 545 | output.writeStructBegin('AgeCheckService_retrieveRequestToken_result'); 546 | if (this.success !== null && this.success !== undefined) { 547 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0); 548 | this.success.write(output); 549 | output.writeFieldEnd(); 550 | } 551 | if (this.e !== null && this.e !== undefined) { 552 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 553 | this.e.write(output); 554 | output.writeFieldEnd(); 555 | } 556 | output.writeFieldStop(); 557 | output.writeStructEnd(); 558 | return; 559 | }; 560 | 561 | AgeCheckServiceClient = exports.Client = function(output, pClass) { 562 | this.output = output; 563 | this.pClass = pClass; 564 | this._seqid = 0; 565 | this._reqs = {}; 566 | }; 567 | AgeCheckServiceClient.prototype = {}; 568 | AgeCheckServiceClient.prototype.seqid = function() { return this._seqid; } 569 | AgeCheckServiceClient.prototype.new_seqid = function() { return this._seqid += 1; } 570 | AgeCheckServiceClient.prototype.checkUserAge = function(carrier, sessionId, verifier, standardAge, callback) { 571 | this._seqid = this.new_seqid(); 572 | if (callback === undefined) { 573 | var _defer = Q.defer(); 574 | this._reqs[this.seqid()] = function(error, result) { 575 | if (error) { 576 | _defer.reject(error); 577 | } else { 578 | _defer.resolve(result); 579 | } 580 | }; 581 | this.send_checkUserAge(carrier, sessionId, verifier, standardAge); 582 | return _defer.promise; 583 | } else { 584 | this._reqs[this.seqid()] = callback; 585 | this.send_checkUserAge(carrier, sessionId, verifier, standardAge); 586 | } 587 | }; 588 | 589 | AgeCheckServiceClient.prototype.send_checkUserAge = function(carrier, sessionId, verifier, standardAge) { 590 | var output = new this.pClass(this.output); 591 | output.writeMessageBegin('checkUserAge', Thrift.MessageType.CALL, this.seqid()); 592 | var args = new AgeCheckService_checkUserAge_args(); 593 | args.carrier = carrier; 594 | args.sessionId = sessionId; 595 | args.verifier = verifier; 596 | args.standardAge = standardAge; 597 | args.write(output); 598 | output.writeMessageEnd(); 599 | return this.output.flush(); 600 | }; 601 | 602 | AgeCheckServiceClient.prototype.recv_checkUserAge = function(input,mtype,rseqid) { 603 | var callback = this._reqs[rseqid] || function() {}; 604 | delete this._reqs[rseqid]; 605 | if (mtype == Thrift.MessageType.EXCEPTION) { 606 | var x = new Thrift.TApplicationException(); 607 | x.read(input); 608 | input.readMessageEnd(); 609 | return callback(x); 610 | } 611 | var result = new AgeCheckService_checkUserAge_result(); 612 | result.read(input); 613 | input.readMessageEnd(); 614 | 615 | if (null !== result.e) { 616 | return callback(result.e); 617 | } 618 | if (null !== result.success) { 619 | return callback(null, result.success); 620 | } 621 | return callback('checkUserAge failed: unknown result'); 622 | }; 623 | AgeCheckServiceClient.prototype.checkUserAgeWithDocomo = function(openIdRedirectUrl, standardAge, verifier, callback) { 624 | this._seqid = this.new_seqid(); 625 | if (callback === undefined) { 626 | var _defer = Q.defer(); 627 | this._reqs[this.seqid()] = function(error, result) { 628 | if (error) { 629 | _defer.reject(error); 630 | } else { 631 | _defer.resolve(result); 632 | } 633 | }; 634 | this.send_checkUserAgeWithDocomo(openIdRedirectUrl, standardAge, verifier); 635 | return _defer.promise; 636 | } else { 637 | this._reqs[this.seqid()] = callback; 638 | this.send_checkUserAgeWithDocomo(openIdRedirectUrl, standardAge, verifier); 639 | } 640 | }; 641 | 642 | AgeCheckServiceClient.prototype.send_checkUserAgeWithDocomo = function(openIdRedirectUrl, standardAge, verifier) { 643 | var output = new this.pClass(this.output); 644 | output.writeMessageBegin('checkUserAgeWithDocomo', Thrift.MessageType.CALL, this.seqid()); 645 | var args = new AgeCheckService_checkUserAgeWithDocomo_args(); 646 | args.openIdRedirectUrl = openIdRedirectUrl; 647 | args.standardAge = standardAge; 648 | args.verifier = verifier; 649 | args.write(output); 650 | output.writeMessageEnd(); 651 | return this.output.flush(); 652 | }; 653 | 654 | AgeCheckServiceClient.prototype.recv_checkUserAgeWithDocomo = function(input,mtype,rseqid) { 655 | var callback = this._reqs[rseqid] || function() {}; 656 | delete this._reqs[rseqid]; 657 | if (mtype == Thrift.MessageType.EXCEPTION) { 658 | var x = new Thrift.TApplicationException(); 659 | x.read(input); 660 | input.readMessageEnd(); 661 | return callback(x); 662 | } 663 | var result = new AgeCheckService_checkUserAgeWithDocomo_result(); 664 | result.read(input); 665 | input.readMessageEnd(); 666 | 667 | if (null !== result.e) { 668 | return callback(result.e); 669 | } 670 | if (null !== result.success) { 671 | return callback(null, result.success); 672 | } 673 | return callback('checkUserAgeWithDocomo failed: unknown result'); 674 | }; 675 | AgeCheckServiceClient.prototype.retrieveOpenIdAuthUrlWithDocomo = function(callback) { 676 | this._seqid = this.new_seqid(); 677 | if (callback === undefined) { 678 | var _defer = Q.defer(); 679 | this._reqs[this.seqid()] = function(error, result) { 680 | if (error) { 681 | _defer.reject(error); 682 | } else { 683 | _defer.resolve(result); 684 | } 685 | }; 686 | this.send_retrieveOpenIdAuthUrlWithDocomo(); 687 | return _defer.promise; 688 | } else { 689 | this._reqs[this.seqid()] = callback; 690 | this.send_retrieveOpenIdAuthUrlWithDocomo(); 691 | } 692 | }; 693 | 694 | AgeCheckServiceClient.prototype.send_retrieveOpenIdAuthUrlWithDocomo = function() { 695 | var output = new this.pClass(this.output); 696 | output.writeMessageBegin('retrieveOpenIdAuthUrlWithDocomo', Thrift.MessageType.CALL, this.seqid()); 697 | var args = new AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_args(); 698 | args.write(output); 699 | output.writeMessageEnd(); 700 | return this.output.flush(); 701 | }; 702 | 703 | AgeCheckServiceClient.prototype.recv_retrieveOpenIdAuthUrlWithDocomo = function(input,mtype,rseqid) { 704 | var callback = this._reqs[rseqid] || function() {}; 705 | delete this._reqs[rseqid]; 706 | if (mtype == Thrift.MessageType.EXCEPTION) { 707 | var x = new Thrift.TApplicationException(); 708 | x.read(input); 709 | input.readMessageEnd(); 710 | return callback(x); 711 | } 712 | var result = new AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_result(); 713 | result.read(input); 714 | input.readMessageEnd(); 715 | 716 | if (null !== result.e) { 717 | return callback(result.e); 718 | } 719 | if (null !== result.success) { 720 | return callback(null, result.success); 721 | } 722 | return callback('retrieveOpenIdAuthUrlWithDocomo failed: unknown result'); 723 | }; 724 | AgeCheckServiceClient.prototype.retrieveRequestToken = function(carrier, callback) { 725 | this._seqid = this.new_seqid(); 726 | if (callback === undefined) { 727 | var _defer = Q.defer(); 728 | this._reqs[this.seqid()] = function(error, result) { 729 | if (error) { 730 | _defer.reject(error); 731 | } else { 732 | _defer.resolve(result); 733 | } 734 | }; 735 | this.send_retrieveRequestToken(carrier); 736 | return _defer.promise; 737 | } else { 738 | this._reqs[this.seqid()] = callback; 739 | this.send_retrieveRequestToken(carrier); 740 | } 741 | }; 742 | 743 | AgeCheckServiceClient.prototype.send_retrieveRequestToken = function(carrier) { 744 | var output = new this.pClass(this.output); 745 | output.writeMessageBegin('retrieveRequestToken', Thrift.MessageType.CALL, this.seqid()); 746 | var args = new AgeCheckService_retrieveRequestToken_args(); 747 | args.carrier = carrier; 748 | args.write(output); 749 | output.writeMessageEnd(); 750 | return this.output.flush(); 751 | }; 752 | 753 | AgeCheckServiceClient.prototype.recv_retrieveRequestToken = function(input,mtype,rseqid) { 754 | var callback = this._reqs[rseqid] || function() {}; 755 | delete this._reqs[rseqid]; 756 | if (mtype == Thrift.MessageType.EXCEPTION) { 757 | var x = new Thrift.TApplicationException(); 758 | x.read(input); 759 | input.readMessageEnd(); 760 | return callback(x); 761 | } 762 | var result = new AgeCheckService_retrieveRequestToken_result(); 763 | result.read(input); 764 | input.readMessageEnd(); 765 | 766 | if (null !== result.e) { 767 | return callback(result.e); 768 | } 769 | if (null !== result.success) { 770 | return callback(null, result.success); 771 | } 772 | return callback('retrieveRequestToken failed: unknown result'); 773 | }; 774 | AgeCheckServiceProcessor = exports.Processor = function(handler) { 775 | this._handler = handler 776 | } 777 | AgeCheckServiceProcessor.prototype.process = function(input, output) { 778 | var r = input.readMessageBegin(); 779 | if (this['process_' + r.fname]) { 780 | return this['process_' + r.fname].call(this, r.rseqid, input, output); 781 | } else { 782 | input.skip(Thrift.Type.STRUCT); 783 | input.readMessageEnd(); 784 | var x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname); 785 | output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid); 786 | x.write(output); 787 | output.writeMessageEnd(); 788 | output.flush(); 789 | } 790 | } 791 | 792 | AgeCheckServiceProcessor.prototype.process_checkUserAge = function(seqid, input, output) { 793 | var args = new AgeCheckService_checkUserAge_args(); 794 | args.read(input); 795 | input.readMessageEnd(); 796 | if (this._handler.checkUserAge.length === 4) { 797 | Q.fcall(this._handler.checkUserAge, args.carrier, args.sessionId, args.verifier, args.standardAge) 798 | .then(function(result) { 799 | var result = new AgeCheckService_checkUserAge_result({success: result}); 800 | output.writeMessageBegin("checkUserAge", Thrift.MessageType.REPLY, seqid); 801 | result.write(output); 802 | output.writeMessageEnd(); 803 | output.flush(); 804 | }, function (err) { 805 | var result = new AgeCheckService_checkUserAge_result(err); 806 | output.writeMessageBegin("checkUserAge", Thrift.MessageType.REPLY, seqid); 807 | result.write(output); 808 | output.writeMessageEnd(); 809 | output.flush(); 810 | }); 811 | } else { 812 | this._handler.checkUserAge(args.carrier, args.sessionId, args.verifier, args.standardAge, function (err, result) { 813 | var result = new AgeCheckService_checkUserAge_result((err != null ? err : {success: result})); 814 | output.writeMessageBegin("checkUserAge", Thrift.MessageType.REPLY, seqid); 815 | result.write(output); 816 | output.writeMessageEnd(); 817 | output.flush(); 818 | }); 819 | } 820 | } 821 | 822 | AgeCheckServiceProcessor.prototype.process_checkUserAgeWithDocomo = function(seqid, input, output) { 823 | var args = new AgeCheckService_checkUserAgeWithDocomo_args(); 824 | args.read(input); 825 | input.readMessageEnd(); 826 | if (this._handler.checkUserAgeWithDocomo.length === 3) { 827 | Q.fcall(this._handler.checkUserAgeWithDocomo, args.openIdRedirectUrl, args.standardAge, args.verifier) 828 | .then(function(result) { 829 | var result = new AgeCheckService_checkUserAgeWithDocomo_result({success: result}); 830 | output.writeMessageBegin("checkUserAgeWithDocomo", Thrift.MessageType.REPLY, seqid); 831 | result.write(output); 832 | output.writeMessageEnd(); 833 | output.flush(); 834 | }, function (err) { 835 | var result = new AgeCheckService_checkUserAgeWithDocomo_result(err); 836 | output.writeMessageBegin("checkUserAgeWithDocomo", Thrift.MessageType.REPLY, seqid); 837 | result.write(output); 838 | output.writeMessageEnd(); 839 | output.flush(); 840 | }); 841 | } else { 842 | this._handler.checkUserAgeWithDocomo(args.openIdRedirectUrl, args.standardAge, args.verifier, function (err, result) { 843 | var result = new AgeCheckService_checkUserAgeWithDocomo_result((err != null ? err : {success: result})); 844 | output.writeMessageBegin("checkUserAgeWithDocomo", Thrift.MessageType.REPLY, seqid); 845 | result.write(output); 846 | output.writeMessageEnd(); 847 | output.flush(); 848 | }); 849 | } 850 | } 851 | 852 | AgeCheckServiceProcessor.prototype.process_retrieveOpenIdAuthUrlWithDocomo = function(seqid, input, output) { 853 | var args = new AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_args(); 854 | args.read(input); 855 | input.readMessageEnd(); 856 | if (this._handler.retrieveOpenIdAuthUrlWithDocomo.length === 0) { 857 | Q.fcall(this._handler.retrieveOpenIdAuthUrlWithDocomo) 858 | .then(function(result) { 859 | var result = new AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_result({success: result}); 860 | output.writeMessageBegin("retrieveOpenIdAuthUrlWithDocomo", Thrift.MessageType.REPLY, seqid); 861 | result.write(output); 862 | output.writeMessageEnd(); 863 | output.flush(); 864 | }, function (err) { 865 | var result = new AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_result(err); 866 | output.writeMessageBegin("retrieveOpenIdAuthUrlWithDocomo", Thrift.MessageType.REPLY, seqid); 867 | result.write(output); 868 | output.writeMessageEnd(); 869 | output.flush(); 870 | }); 871 | } else { 872 | this._handler.retrieveOpenIdAuthUrlWithDocomo( function (err, result) { 873 | var result = new AgeCheckService_retrieveOpenIdAuthUrlWithDocomo_result((err != null ? err : {success: result})); 874 | output.writeMessageBegin("retrieveOpenIdAuthUrlWithDocomo", Thrift.MessageType.REPLY, seqid); 875 | result.write(output); 876 | output.writeMessageEnd(); 877 | output.flush(); 878 | }); 879 | } 880 | } 881 | 882 | AgeCheckServiceProcessor.prototype.process_retrieveRequestToken = function(seqid, input, output) { 883 | var args = new AgeCheckService_retrieveRequestToken_args(); 884 | args.read(input); 885 | input.readMessageEnd(); 886 | if (this._handler.retrieveRequestToken.length === 1) { 887 | Q.fcall(this._handler.retrieveRequestToken, args.carrier) 888 | .then(function(result) { 889 | var result = new AgeCheckService_retrieveRequestToken_result({success: result}); 890 | output.writeMessageBegin("retrieveRequestToken", Thrift.MessageType.REPLY, seqid); 891 | result.write(output); 892 | output.writeMessageEnd(); 893 | output.flush(); 894 | }, function (err) { 895 | var result = new AgeCheckService_retrieveRequestToken_result(err); 896 | output.writeMessageBegin("retrieveRequestToken", Thrift.MessageType.REPLY, seqid); 897 | result.write(output); 898 | output.writeMessageEnd(); 899 | output.flush(); 900 | }); 901 | } else { 902 | this._handler.retrieveRequestToken(args.carrier, function (err, result) { 903 | var result = new AgeCheckService_retrieveRequestToken_result((err != null ? err : {success: result})); 904 | output.writeMessageBegin("retrieveRequestToken", Thrift.MessageType.REPLY, seqid); 905 | result.write(output); 906 | output.writeMessageEnd(); 907 | output.flush(); 908 | }); 909 | } 910 | } 911 | 912 | -------------------------------------------------------------------------------- /lib/gen-nodejs/MessageService.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift Compiler (0.9.2) 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | var thrift = require('thrift'); 7 | var Thrift = thrift.Thrift; 8 | var Q = thrift.Q; 9 | 10 | 11 | var ttypes = require('./line_types'); 12 | //HELPER FUNCTIONS AND STRUCTURES 13 | 14 | MessageService_fetchMessageOperations_args = function(args) { 15 | this.localRevision = null; 16 | this.lastOpTimestamp = null; 17 | this.count = null; 18 | if (args) { 19 | if (args.localRevision !== undefined) { 20 | this.localRevision = args.localRevision; 21 | } 22 | if (args.lastOpTimestamp !== undefined) { 23 | this.lastOpTimestamp = args.lastOpTimestamp; 24 | } 25 | if (args.count !== undefined) { 26 | this.count = args.count; 27 | } 28 | } 29 | }; 30 | MessageService_fetchMessageOperations_args.prototype = {}; 31 | MessageService_fetchMessageOperations_args.prototype.read = function(input) { 32 | input.readStructBegin(); 33 | while (true) 34 | { 35 | var ret = input.readFieldBegin(); 36 | var fname = ret.fname; 37 | var ftype = ret.ftype; 38 | var fid = ret.fid; 39 | if (ftype == Thrift.Type.STOP) { 40 | break; 41 | } 42 | switch (fid) 43 | { 44 | case 2: 45 | if (ftype == Thrift.Type.I64) { 46 | this.localRevision = input.readI64(); 47 | } else { 48 | input.skip(ftype); 49 | } 50 | break; 51 | case 3: 52 | if (ftype == Thrift.Type.I64) { 53 | this.lastOpTimestamp = input.readI64(); 54 | } else { 55 | input.skip(ftype); 56 | } 57 | break; 58 | case 4: 59 | if (ftype == Thrift.Type.I32) { 60 | this.count = input.readI32(); 61 | } else { 62 | input.skip(ftype); 63 | } 64 | break; 65 | default: 66 | input.skip(ftype); 67 | } 68 | input.readFieldEnd(); 69 | } 70 | input.readStructEnd(); 71 | return; 72 | }; 73 | 74 | MessageService_fetchMessageOperations_args.prototype.write = function(output) { 75 | output.writeStructBegin('MessageService_fetchMessageOperations_args'); 76 | if (this.localRevision !== null && this.localRevision !== undefined) { 77 | output.writeFieldBegin('localRevision', Thrift.Type.I64, 2); 78 | output.writeI64(this.localRevision); 79 | output.writeFieldEnd(); 80 | } 81 | if (this.lastOpTimestamp !== null && this.lastOpTimestamp !== undefined) { 82 | output.writeFieldBegin('lastOpTimestamp', Thrift.Type.I64, 3); 83 | output.writeI64(this.lastOpTimestamp); 84 | output.writeFieldEnd(); 85 | } 86 | if (this.count !== null && this.count !== undefined) { 87 | output.writeFieldBegin('count', Thrift.Type.I32, 4); 88 | output.writeI32(this.count); 89 | output.writeFieldEnd(); 90 | } 91 | output.writeFieldStop(); 92 | output.writeStructEnd(); 93 | return; 94 | }; 95 | 96 | MessageService_fetchMessageOperations_result = function(args) { 97 | this.success = null; 98 | this.e = null; 99 | if (args instanceof ttypes.TalkException) { 100 | this.e = args; 101 | return; 102 | } 103 | if (args) { 104 | if (args.success !== undefined) { 105 | this.success = args.success; 106 | } 107 | if (args.e !== undefined) { 108 | this.e = args.e; 109 | } 110 | } 111 | }; 112 | MessageService_fetchMessageOperations_result.prototype = {}; 113 | MessageService_fetchMessageOperations_result.prototype.read = function(input) { 114 | input.readStructBegin(); 115 | while (true) 116 | { 117 | var ret = input.readFieldBegin(); 118 | var fname = ret.fname; 119 | var ftype = ret.ftype; 120 | var fid = ret.fid; 121 | if (ftype == Thrift.Type.STOP) { 122 | break; 123 | } 124 | switch (fid) 125 | { 126 | case 0: 127 | if (ftype == Thrift.Type.STRUCT) { 128 | this.success = new ttypes.MessageOperations(); 129 | this.success.read(input); 130 | } else { 131 | input.skip(ftype); 132 | } 133 | break; 134 | case 1: 135 | if (ftype == Thrift.Type.STRUCT) { 136 | this.e = new ttypes.TalkException(); 137 | this.e.read(input); 138 | } else { 139 | input.skip(ftype); 140 | } 141 | break; 142 | default: 143 | input.skip(ftype); 144 | } 145 | input.readFieldEnd(); 146 | } 147 | input.readStructEnd(); 148 | return; 149 | }; 150 | 151 | MessageService_fetchMessageOperations_result.prototype.write = function(output) { 152 | output.writeStructBegin('MessageService_fetchMessageOperations_result'); 153 | if (this.success !== null && this.success !== undefined) { 154 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0); 155 | this.success.write(output); 156 | output.writeFieldEnd(); 157 | } 158 | if (this.e !== null && this.e !== undefined) { 159 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 160 | this.e.write(output); 161 | output.writeFieldEnd(); 162 | } 163 | output.writeFieldStop(); 164 | output.writeStructEnd(); 165 | return; 166 | }; 167 | 168 | MessageService_getLastReadMessageIds_args = function(args) { 169 | this.chatId = null; 170 | if (args) { 171 | if (args.chatId !== undefined) { 172 | this.chatId = args.chatId; 173 | } 174 | } 175 | }; 176 | MessageService_getLastReadMessageIds_args.prototype = {}; 177 | MessageService_getLastReadMessageIds_args.prototype.read = function(input) { 178 | input.readStructBegin(); 179 | while (true) 180 | { 181 | var ret = input.readFieldBegin(); 182 | var fname = ret.fname; 183 | var ftype = ret.ftype; 184 | var fid = ret.fid; 185 | if (ftype == Thrift.Type.STOP) { 186 | break; 187 | } 188 | switch (fid) 189 | { 190 | case 2: 191 | if (ftype == Thrift.Type.STRING) { 192 | this.chatId = input.readString(); 193 | } else { 194 | input.skip(ftype); 195 | } 196 | break; 197 | case 0: 198 | input.skip(ftype); 199 | break; 200 | default: 201 | input.skip(ftype); 202 | } 203 | input.readFieldEnd(); 204 | } 205 | input.readStructEnd(); 206 | return; 207 | }; 208 | 209 | MessageService_getLastReadMessageIds_args.prototype.write = function(output) { 210 | output.writeStructBegin('MessageService_getLastReadMessageIds_args'); 211 | if (this.chatId !== null && this.chatId !== undefined) { 212 | output.writeFieldBegin('chatId', Thrift.Type.STRING, 2); 213 | output.writeString(this.chatId); 214 | output.writeFieldEnd(); 215 | } 216 | output.writeFieldStop(); 217 | output.writeStructEnd(); 218 | return; 219 | }; 220 | 221 | MessageService_getLastReadMessageIds_result = function(args) { 222 | this.success = null; 223 | this.e = null; 224 | if (args instanceof ttypes.TalkException) { 225 | this.e = args; 226 | return; 227 | } 228 | if (args) { 229 | if (args.success !== undefined) { 230 | this.success = args.success; 231 | } 232 | if (args.e !== undefined) { 233 | this.e = args.e; 234 | } 235 | } 236 | }; 237 | MessageService_getLastReadMessageIds_result.prototype = {}; 238 | MessageService_getLastReadMessageIds_result.prototype.read = function(input) { 239 | input.readStructBegin(); 240 | while (true) 241 | { 242 | var ret = input.readFieldBegin(); 243 | var fname = ret.fname; 244 | var ftype = ret.ftype; 245 | var fid = ret.fid; 246 | if (ftype == Thrift.Type.STOP) { 247 | break; 248 | } 249 | switch (fid) 250 | { 251 | case 0: 252 | if (ftype == Thrift.Type.STRUCT) { 253 | this.success = new ttypes.LastReadMessageIds(); 254 | this.success.read(input); 255 | } else { 256 | input.skip(ftype); 257 | } 258 | break; 259 | case 1: 260 | if (ftype == Thrift.Type.STRUCT) { 261 | this.e = new ttypes.TalkException(); 262 | this.e.read(input); 263 | } else { 264 | input.skip(ftype); 265 | } 266 | break; 267 | default: 268 | input.skip(ftype); 269 | } 270 | input.readFieldEnd(); 271 | } 272 | input.readStructEnd(); 273 | return; 274 | }; 275 | 276 | MessageService_getLastReadMessageIds_result.prototype.write = function(output) { 277 | output.writeStructBegin('MessageService_getLastReadMessageIds_result'); 278 | if (this.success !== null && this.success !== undefined) { 279 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0); 280 | this.success.write(output); 281 | output.writeFieldEnd(); 282 | } 283 | if (this.e !== null && this.e !== undefined) { 284 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 285 | this.e.write(output); 286 | output.writeFieldEnd(); 287 | } 288 | output.writeFieldStop(); 289 | output.writeStructEnd(); 290 | return; 291 | }; 292 | 293 | MessageService_multiGetLastReadMessageIds_args = function(args) { 294 | this.chatIds = null; 295 | if (args) { 296 | if (args.chatIds !== undefined) { 297 | this.chatIds = args.chatIds; 298 | } 299 | } 300 | }; 301 | MessageService_multiGetLastReadMessageIds_args.prototype = {}; 302 | MessageService_multiGetLastReadMessageIds_args.prototype.read = function(input) { 303 | input.readStructBegin(); 304 | while (true) 305 | { 306 | var ret = input.readFieldBegin(); 307 | var fname = ret.fname; 308 | var ftype = ret.ftype; 309 | var fid = ret.fid; 310 | if (ftype == Thrift.Type.STOP) { 311 | break; 312 | } 313 | switch (fid) 314 | { 315 | case 2: 316 | if (ftype == Thrift.Type.LIST) { 317 | var _size752 = 0; 318 | var _rtmp3756; 319 | this.chatIds = []; 320 | var _etype755 = 0; 321 | _rtmp3756 = input.readListBegin(); 322 | _etype755 = _rtmp3756.etype; 323 | _size752 = _rtmp3756.size; 324 | for (var _i757 = 0; _i757 < _size752; ++_i757) 325 | { 326 | var elem758 = null; 327 | elem758 = input.readString(); 328 | this.chatIds.push(elem758); 329 | } 330 | input.readListEnd(); 331 | } else { 332 | input.skip(ftype); 333 | } 334 | break; 335 | case 0: 336 | input.skip(ftype); 337 | break; 338 | default: 339 | input.skip(ftype); 340 | } 341 | input.readFieldEnd(); 342 | } 343 | input.readStructEnd(); 344 | return; 345 | }; 346 | 347 | MessageService_multiGetLastReadMessageIds_args.prototype.write = function(output) { 348 | output.writeStructBegin('MessageService_multiGetLastReadMessageIds_args'); 349 | if (this.chatIds !== null && this.chatIds !== undefined) { 350 | output.writeFieldBegin('chatIds', Thrift.Type.LIST, 2); 351 | output.writeListBegin(Thrift.Type.STRING, this.chatIds.length); 352 | for (var iter759 in this.chatIds) 353 | { 354 | if (this.chatIds.hasOwnProperty(iter759)) 355 | { 356 | iter759 = this.chatIds[iter759]; 357 | output.writeString(iter759); 358 | } 359 | } 360 | output.writeListEnd(); 361 | output.writeFieldEnd(); 362 | } 363 | output.writeFieldStop(); 364 | output.writeStructEnd(); 365 | return; 366 | }; 367 | 368 | MessageService_multiGetLastReadMessageIds_result = function(args) { 369 | this.success = null; 370 | this.e = null; 371 | if (args instanceof ttypes.TalkException) { 372 | this.e = args; 373 | return; 374 | } 375 | if (args) { 376 | if (args.success !== undefined) { 377 | this.success = args.success; 378 | } 379 | if (args.e !== undefined) { 380 | this.e = args.e; 381 | } 382 | } 383 | }; 384 | MessageService_multiGetLastReadMessageIds_result.prototype = {}; 385 | MessageService_multiGetLastReadMessageIds_result.prototype.read = function(input) { 386 | input.readStructBegin(); 387 | while (true) 388 | { 389 | var ret = input.readFieldBegin(); 390 | var fname = ret.fname; 391 | var ftype = ret.ftype; 392 | var fid = ret.fid; 393 | if (ftype == Thrift.Type.STOP) { 394 | break; 395 | } 396 | switch (fid) 397 | { 398 | case 0: 399 | if (ftype == Thrift.Type.LIST) { 400 | var _size760 = 0; 401 | var _rtmp3764; 402 | this.success = []; 403 | var _etype763 = 0; 404 | _rtmp3764 = input.readListBegin(); 405 | _etype763 = _rtmp3764.etype; 406 | _size760 = _rtmp3764.size; 407 | for (var _i765 = 0; _i765 < _size760; ++_i765) 408 | { 409 | var elem766 = null; 410 | elem766 = new ttypes.LastReadMessageIds(); 411 | elem766.read(input); 412 | this.success.push(elem766); 413 | } 414 | input.readListEnd(); 415 | } else { 416 | input.skip(ftype); 417 | } 418 | break; 419 | case 1: 420 | if (ftype == Thrift.Type.STRUCT) { 421 | this.e = new ttypes.TalkException(); 422 | this.e.read(input); 423 | } else { 424 | input.skip(ftype); 425 | } 426 | break; 427 | default: 428 | input.skip(ftype); 429 | } 430 | input.readFieldEnd(); 431 | } 432 | input.readStructEnd(); 433 | return; 434 | }; 435 | 436 | MessageService_multiGetLastReadMessageIds_result.prototype.write = function(output) { 437 | output.writeStructBegin('MessageService_multiGetLastReadMessageIds_result'); 438 | if (this.success !== null && this.success !== undefined) { 439 | output.writeFieldBegin('success', Thrift.Type.LIST, 0); 440 | output.writeListBegin(Thrift.Type.STRUCT, this.success.length); 441 | for (var iter767 in this.success) 442 | { 443 | if (this.success.hasOwnProperty(iter767)) 444 | { 445 | iter767 = this.success[iter767]; 446 | iter767.write(output); 447 | } 448 | } 449 | output.writeListEnd(); 450 | output.writeFieldEnd(); 451 | } 452 | if (this.e !== null && this.e !== undefined) { 453 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 454 | this.e.write(output); 455 | output.writeFieldEnd(); 456 | } 457 | output.writeFieldStop(); 458 | output.writeStructEnd(); 459 | return; 460 | }; 461 | 462 | MessageServiceClient = exports.Client = function(output, pClass) { 463 | this.output = output; 464 | this.pClass = pClass; 465 | this._seqid = 0; 466 | this._reqs = {}; 467 | }; 468 | MessageServiceClient.prototype = {}; 469 | MessageServiceClient.prototype.seqid = function() { return this._seqid; } 470 | MessageServiceClient.prototype.new_seqid = function() { return this._seqid += 1; } 471 | MessageServiceClient.prototype.fetchMessageOperations = function(localRevision, lastOpTimestamp, count, callback) { 472 | this._seqid = this.new_seqid(); 473 | if (callback === undefined) { 474 | var _defer = Q.defer(); 475 | this._reqs[this.seqid()] = function(error, result) { 476 | if (error) { 477 | _defer.reject(error); 478 | } else { 479 | _defer.resolve(result); 480 | } 481 | }; 482 | this.send_fetchMessageOperations(localRevision, lastOpTimestamp, count); 483 | return _defer.promise; 484 | } else { 485 | this._reqs[this.seqid()] = callback; 486 | this.send_fetchMessageOperations(localRevision, lastOpTimestamp, count); 487 | } 488 | }; 489 | 490 | MessageServiceClient.prototype.send_fetchMessageOperations = function(localRevision, lastOpTimestamp, count) { 491 | var output = new this.pClass(this.output); 492 | output.writeMessageBegin('fetchMessageOperations', Thrift.MessageType.CALL, this.seqid()); 493 | var args = new MessageService_fetchMessageOperations_args(); 494 | args.localRevision = localRevision; 495 | args.lastOpTimestamp = lastOpTimestamp; 496 | args.count = count; 497 | args.write(output); 498 | output.writeMessageEnd(); 499 | return this.output.flush(); 500 | }; 501 | 502 | MessageServiceClient.prototype.recv_fetchMessageOperations = function(input,mtype,rseqid) { 503 | var callback = this._reqs[rseqid] || function() {}; 504 | delete this._reqs[rseqid]; 505 | if (mtype == Thrift.MessageType.EXCEPTION) { 506 | var x = new Thrift.TApplicationException(); 507 | x.read(input); 508 | input.readMessageEnd(); 509 | return callback(x); 510 | } 511 | var result = new MessageService_fetchMessageOperations_result(); 512 | result.read(input); 513 | input.readMessageEnd(); 514 | 515 | if (null !== result.e) { 516 | return callback(result.e); 517 | } 518 | if (null !== result.success) { 519 | return callback(null, result.success); 520 | } 521 | return callback('fetchMessageOperations failed: unknown result'); 522 | }; 523 | MessageServiceClient.prototype.getLastReadMessageIds = function(chatId, callback) { 524 | this._seqid = this.new_seqid(); 525 | if (callback === undefined) { 526 | var _defer = Q.defer(); 527 | this._reqs[this.seqid()] = function(error, result) { 528 | if (error) { 529 | _defer.reject(error); 530 | } else { 531 | _defer.resolve(result); 532 | } 533 | }; 534 | this.send_getLastReadMessageIds(chatId); 535 | return _defer.promise; 536 | } else { 537 | this._reqs[this.seqid()] = callback; 538 | this.send_getLastReadMessageIds(chatId); 539 | } 540 | }; 541 | 542 | MessageServiceClient.prototype.send_getLastReadMessageIds = function(chatId) { 543 | var output = new this.pClass(this.output); 544 | output.writeMessageBegin('getLastReadMessageIds', Thrift.MessageType.CALL, this.seqid()); 545 | var args = new MessageService_getLastReadMessageIds_args(); 546 | args.chatId = chatId; 547 | args.write(output); 548 | output.writeMessageEnd(); 549 | return this.output.flush(); 550 | }; 551 | 552 | MessageServiceClient.prototype.recv_getLastReadMessageIds = function(input,mtype,rseqid) { 553 | var callback = this._reqs[rseqid] || function() {}; 554 | delete this._reqs[rseqid]; 555 | if (mtype == Thrift.MessageType.EXCEPTION) { 556 | var x = new Thrift.TApplicationException(); 557 | x.read(input); 558 | input.readMessageEnd(); 559 | return callback(x); 560 | } 561 | var result = new MessageService_getLastReadMessageIds_result(); 562 | result.read(input); 563 | input.readMessageEnd(); 564 | 565 | if (null !== result.e) { 566 | return callback(result.e); 567 | } 568 | if (null !== result.success) { 569 | return callback(null, result.success); 570 | } 571 | return callback('getLastReadMessageIds failed: unknown result'); 572 | }; 573 | MessageServiceClient.prototype.multiGetLastReadMessageIds = function(chatIds, callback) { 574 | this._seqid = this.new_seqid(); 575 | if (callback === undefined) { 576 | var _defer = Q.defer(); 577 | this._reqs[this.seqid()] = function(error, result) { 578 | if (error) { 579 | _defer.reject(error); 580 | } else { 581 | _defer.resolve(result); 582 | } 583 | }; 584 | this.send_multiGetLastReadMessageIds(chatIds); 585 | return _defer.promise; 586 | } else { 587 | this._reqs[this.seqid()] = callback; 588 | this.send_multiGetLastReadMessageIds(chatIds); 589 | } 590 | }; 591 | 592 | MessageServiceClient.prototype.send_multiGetLastReadMessageIds = function(chatIds) { 593 | var output = new this.pClass(this.output); 594 | output.writeMessageBegin('multiGetLastReadMessageIds', Thrift.MessageType.CALL, this.seqid()); 595 | var args = new MessageService_multiGetLastReadMessageIds_args(); 596 | args.chatIds = chatIds; 597 | args.write(output); 598 | output.writeMessageEnd(); 599 | return this.output.flush(); 600 | }; 601 | 602 | MessageServiceClient.prototype.recv_multiGetLastReadMessageIds = function(input,mtype,rseqid) { 603 | var callback = this._reqs[rseqid] || function() {}; 604 | delete this._reqs[rseqid]; 605 | if (mtype == Thrift.MessageType.EXCEPTION) { 606 | var x = new Thrift.TApplicationException(); 607 | x.read(input); 608 | input.readMessageEnd(); 609 | return callback(x); 610 | } 611 | var result = new MessageService_multiGetLastReadMessageIds_result(); 612 | result.read(input); 613 | input.readMessageEnd(); 614 | 615 | if (null !== result.e) { 616 | return callback(result.e); 617 | } 618 | if (null !== result.success) { 619 | return callback(null, result.success); 620 | } 621 | return callback('multiGetLastReadMessageIds failed: unknown result'); 622 | }; 623 | MessageServiceProcessor = exports.Processor = function(handler) { 624 | this._handler = handler 625 | } 626 | MessageServiceProcessor.prototype.process = function(input, output) { 627 | var r = input.readMessageBegin(); 628 | if (this['process_' + r.fname]) { 629 | return this['process_' + r.fname].call(this, r.rseqid, input, output); 630 | } else { 631 | input.skip(Thrift.Type.STRUCT); 632 | input.readMessageEnd(); 633 | var x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname); 634 | output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid); 635 | x.write(output); 636 | output.writeMessageEnd(); 637 | output.flush(); 638 | } 639 | } 640 | 641 | MessageServiceProcessor.prototype.process_fetchMessageOperations = function(seqid, input, output) { 642 | var args = new MessageService_fetchMessageOperations_args(); 643 | args.read(input); 644 | input.readMessageEnd(); 645 | if (this._handler.fetchMessageOperations.length === 3) { 646 | Q.fcall(this._handler.fetchMessageOperations, args.localRevision, args.lastOpTimestamp, args.count) 647 | .then(function(result) { 648 | var result = new MessageService_fetchMessageOperations_result({success: result}); 649 | output.writeMessageBegin("fetchMessageOperations", Thrift.MessageType.REPLY, seqid); 650 | result.write(output); 651 | output.writeMessageEnd(); 652 | output.flush(); 653 | }, function (err) { 654 | var result = new MessageService_fetchMessageOperations_result(err); 655 | output.writeMessageBegin("fetchMessageOperations", Thrift.MessageType.REPLY, seqid); 656 | result.write(output); 657 | output.writeMessageEnd(); 658 | output.flush(); 659 | }); 660 | } else { 661 | this._handler.fetchMessageOperations(args.localRevision, args.lastOpTimestamp, args.count, function (err, result) { 662 | var result = new MessageService_fetchMessageOperations_result((err != null ? err : {success: result})); 663 | output.writeMessageBegin("fetchMessageOperations", Thrift.MessageType.REPLY, seqid); 664 | result.write(output); 665 | output.writeMessageEnd(); 666 | output.flush(); 667 | }); 668 | } 669 | } 670 | 671 | MessageServiceProcessor.prototype.process_getLastReadMessageIds = function(seqid, input, output) { 672 | var args = new MessageService_getLastReadMessageIds_args(); 673 | args.read(input); 674 | input.readMessageEnd(); 675 | if (this._handler.getLastReadMessageIds.length === 1) { 676 | Q.fcall(this._handler.getLastReadMessageIds, args.chatId) 677 | .then(function(result) { 678 | var result = new MessageService_getLastReadMessageIds_result({success: result}); 679 | output.writeMessageBegin("getLastReadMessageIds", Thrift.MessageType.REPLY, seqid); 680 | result.write(output); 681 | output.writeMessageEnd(); 682 | output.flush(); 683 | }, function (err) { 684 | var result = new MessageService_getLastReadMessageIds_result(err); 685 | output.writeMessageBegin("getLastReadMessageIds", Thrift.MessageType.REPLY, seqid); 686 | result.write(output); 687 | output.writeMessageEnd(); 688 | output.flush(); 689 | }); 690 | } else { 691 | this._handler.getLastReadMessageIds(args.chatId, function (err, result) { 692 | var result = new MessageService_getLastReadMessageIds_result((err != null ? err : {success: result})); 693 | output.writeMessageBegin("getLastReadMessageIds", Thrift.MessageType.REPLY, seqid); 694 | result.write(output); 695 | output.writeMessageEnd(); 696 | output.flush(); 697 | }); 698 | } 699 | } 700 | 701 | MessageServiceProcessor.prototype.process_multiGetLastReadMessageIds = function(seqid, input, output) { 702 | var args = new MessageService_multiGetLastReadMessageIds_args(); 703 | args.read(input); 704 | input.readMessageEnd(); 705 | if (this._handler.multiGetLastReadMessageIds.length === 1) { 706 | Q.fcall(this._handler.multiGetLastReadMessageIds, args.chatIds) 707 | .then(function(result) { 708 | var result = new MessageService_multiGetLastReadMessageIds_result({success: result}); 709 | output.writeMessageBegin("multiGetLastReadMessageIds", Thrift.MessageType.REPLY, seqid); 710 | result.write(output); 711 | output.writeMessageEnd(); 712 | output.flush(); 713 | }, function (err) { 714 | var result = new MessageService_multiGetLastReadMessageIds_result(err); 715 | output.writeMessageBegin("multiGetLastReadMessageIds", Thrift.MessageType.REPLY, seqid); 716 | result.write(output); 717 | output.writeMessageEnd(); 718 | output.flush(); 719 | }); 720 | } else { 721 | this._handler.multiGetLastReadMessageIds(args.chatIds, function (err, result) { 722 | var result = new MessageService_multiGetLastReadMessageIds_result((err != null ? err : {success: result})); 723 | output.writeMessageBegin("multiGetLastReadMessageIds", Thrift.MessageType.REPLY, seqid); 724 | result.write(output); 725 | output.writeMessageEnd(); 726 | output.flush(); 727 | }); 728 | } 729 | } 730 | 731 | -------------------------------------------------------------------------------- /lib/gen-nodejs/SnsAdaptorService.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift Compiler (0.9.2) 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | var thrift = require('thrift'); 7 | var Thrift = thrift.Thrift; 8 | var Q = thrift.Q; 9 | 10 | 11 | var ttypes = require('./line_types'); 12 | //HELPER FUNCTIONS AND STRUCTURES 13 | 14 | SnsAdaptorService_getSnsFriends_args = function(args) { 15 | this.snsIdType = null; 16 | this.snsAccessToken = null; 17 | this.startIdx = null; 18 | this.limit = null; 19 | if (args) { 20 | if (args.snsIdType !== undefined) { 21 | this.snsIdType = args.snsIdType; 22 | } 23 | if (args.snsAccessToken !== undefined) { 24 | this.snsAccessToken = args.snsAccessToken; 25 | } 26 | if (args.startIdx !== undefined) { 27 | this.startIdx = args.startIdx; 28 | } 29 | if (args.limit !== undefined) { 30 | this.limit = args.limit; 31 | } 32 | } 33 | }; 34 | SnsAdaptorService_getSnsFriends_args.prototype = {}; 35 | SnsAdaptorService_getSnsFriends_args.prototype.read = function(input) { 36 | input.readStructBegin(); 37 | while (true) 38 | { 39 | var ret = input.readFieldBegin(); 40 | var fname = ret.fname; 41 | var ftype = ret.ftype; 42 | var fid = ret.fid; 43 | if (ftype == Thrift.Type.STOP) { 44 | break; 45 | } 46 | switch (fid) 47 | { 48 | case 2: 49 | if (ftype == Thrift.Type.I32) { 50 | this.snsIdType = input.readI32(); 51 | } else { 52 | input.skip(ftype); 53 | } 54 | break; 55 | case 3: 56 | if (ftype == Thrift.Type.STRING) { 57 | this.snsAccessToken = input.readString(); 58 | } else { 59 | input.skip(ftype); 60 | } 61 | break; 62 | case 4: 63 | if (ftype == Thrift.Type.I32) { 64 | this.startIdx = input.readI32(); 65 | } else { 66 | input.skip(ftype); 67 | } 68 | break; 69 | case 5: 70 | if (ftype == Thrift.Type.I32) { 71 | this.limit = input.readI32(); 72 | } else { 73 | input.skip(ftype); 74 | } 75 | break; 76 | default: 77 | input.skip(ftype); 78 | } 79 | input.readFieldEnd(); 80 | } 81 | input.readStructEnd(); 82 | return; 83 | }; 84 | 85 | SnsAdaptorService_getSnsFriends_args.prototype.write = function(output) { 86 | output.writeStructBegin('SnsAdaptorService_getSnsFriends_args'); 87 | if (this.snsIdType !== null && this.snsIdType !== undefined) { 88 | output.writeFieldBegin('snsIdType', Thrift.Type.I32, 2); 89 | output.writeI32(this.snsIdType); 90 | output.writeFieldEnd(); 91 | } 92 | if (this.snsAccessToken !== null && this.snsAccessToken !== undefined) { 93 | output.writeFieldBegin('snsAccessToken', Thrift.Type.STRING, 3); 94 | output.writeString(this.snsAccessToken); 95 | output.writeFieldEnd(); 96 | } 97 | if (this.startIdx !== null && this.startIdx !== undefined) { 98 | output.writeFieldBegin('startIdx', Thrift.Type.I32, 4); 99 | output.writeI32(this.startIdx); 100 | output.writeFieldEnd(); 101 | } 102 | if (this.limit !== null && this.limit !== undefined) { 103 | output.writeFieldBegin('limit', Thrift.Type.I32, 5); 104 | output.writeI32(this.limit); 105 | output.writeFieldEnd(); 106 | } 107 | output.writeFieldStop(); 108 | output.writeStructEnd(); 109 | return; 110 | }; 111 | 112 | SnsAdaptorService_getSnsFriends_result = function(args) { 113 | this.success = null; 114 | this.e = null; 115 | if (args instanceof ttypes.TalkException) { 116 | this.e = args; 117 | return; 118 | } 119 | if (args) { 120 | if (args.success !== undefined) { 121 | this.success = args.success; 122 | } 123 | if (args.e !== undefined) { 124 | this.e = args.e; 125 | } 126 | } 127 | }; 128 | SnsAdaptorService_getSnsFriends_result.prototype = {}; 129 | SnsAdaptorService_getSnsFriends_result.prototype.read = function(input) { 130 | input.readStructBegin(); 131 | while (true) 132 | { 133 | var ret = input.readFieldBegin(); 134 | var fname = ret.fname; 135 | var ftype = ret.ftype; 136 | var fid = ret.fid; 137 | if (ftype == Thrift.Type.STOP) { 138 | break; 139 | } 140 | switch (fid) 141 | { 142 | case 0: 143 | if (ftype == Thrift.Type.STRUCT) { 144 | this.success = new ttypes.SnsFriends(); 145 | this.success.read(input); 146 | } else { 147 | input.skip(ftype); 148 | } 149 | break; 150 | case 1: 151 | if (ftype == Thrift.Type.STRUCT) { 152 | this.e = new ttypes.TalkException(); 153 | this.e.read(input); 154 | } else { 155 | input.skip(ftype); 156 | } 157 | break; 158 | default: 159 | input.skip(ftype); 160 | } 161 | input.readFieldEnd(); 162 | } 163 | input.readStructEnd(); 164 | return; 165 | }; 166 | 167 | SnsAdaptorService_getSnsFriends_result.prototype.write = function(output) { 168 | output.writeStructBegin('SnsAdaptorService_getSnsFriends_result'); 169 | if (this.success !== null && this.success !== undefined) { 170 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0); 171 | this.success.write(output); 172 | output.writeFieldEnd(); 173 | } 174 | if (this.e !== null && this.e !== undefined) { 175 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 176 | this.e.write(output); 177 | output.writeFieldEnd(); 178 | } 179 | output.writeFieldStop(); 180 | output.writeStructEnd(); 181 | return; 182 | }; 183 | 184 | SnsAdaptorService_getSnsMyProfile_args = function(args) { 185 | this.snsIdType = null; 186 | this.snsAccessToken = null; 187 | if (args) { 188 | if (args.snsIdType !== undefined) { 189 | this.snsIdType = args.snsIdType; 190 | } 191 | if (args.snsAccessToken !== undefined) { 192 | this.snsAccessToken = args.snsAccessToken; 193 | } 194 | } 195 | }; 196 | SnsAdaptorService_getSnsMyProfile_args.prototype = {}; 197 | SnsAdaptorService_getSnsMyProfile_args.prototype.read = function(input) { 198 | input.readStructBegin(); 199 | while (true) 200 | { 201 | var ret = input.readFieldBegin(); 202 | var fname = ret.fname; 203 | var ftype = ret.ftype; 204 | var fid = ret.fid; 205 | if (ftype == Thrift.Type.STOP) { 206 | break; 207 | } 208 | switch (fid) 209 | { 210 | case 2: 211 | if (ftype == Thrift.Type.I32) { 212 | this.snsIdType = input.readI32(); 213 | } else { 214 | input.skip(ftype); 215 | } 216 | break; 217 | case 3: 218 | if (ftype == Thrift.Type.STRING) { 219 | this.snsAccessToken = input.readString(); 220 | } else { 221 | input.skip(ftype); 222 | } 223 | break; 224 | default: 225 | input.skip(ftype); 226 | } 227 | input.readFieldEnd(); 228 | } 229 | input.readStructEnd(); 230 | return; 231 | }; 232 | 233 | SnsAdaptorService_getSnsMyProfile_args.prototype.write = function(output) { 234 | output.writeStructBegin('SnsAdaptorService_getSnsMyProfile_args'); 235 | if (this.snsIdType !== null && this.snsIdType !== undefined) { 236 | output.writeFieldBegin('snsIdType', Thrift.Type.I32, 2); 237 | output.writeI32(this.snsIdType); 238 | output.writeFieldEnd(); 239 | } 240 | if (this.snsAccessToken !== null && this.snsAccessToken !== undefined) { 241 | output.writeFieldBegin('snsAccessToken', Thrift.Type.STRING, 3); 242 | output.writeString(this.snsAccessToken); 243 | output.writeFieldEnd(); 244 | } 245 | output.writeFieldStop(); 246 | output.writeStructEnd(); 247 | return; 248 | }; 249 | 250 | SnsAdaptorService_getSnsMyProfile_result = function(args) { 251 | this.success = null; 252 | this.e = null; 253 | if (args instanceof ttypes.TalkException) { 254 | this.e = args; 255 | return; 256 | } 257 | if (args) { 258 | if (args.success !== undefined) { 259 | this.success = args.success; 260 | } 261 | if (args.e !== undefined) { 262 | this.e = args.e; 263 | } 264 | } 265 | }; 266 | SnsAdaptorService_getSnsMyProfile_result.prototype = {}; 267 | SnsAdaptorService_getSnsMyProfile_result.prototype.read = function(input) { 268 | input.readStructBegin(); 269 | while (true) 270 | { 271 | var ret = input.readFieldBegin(); 272 | var fname = ret.fname; 273 | var ftype = ret.ftype; 274 | var fid = ret.fid; 275 | if (ftype == Thrift.Type.STOP) { 276 | break; 277 | } 278 | switch (fid) 279 | { 280 | case 0: 281 | if (ftype == Thrift.Type.STRUCT) { 282 | this.success = new ttypes.SnsProfile(); 283 | this.success.read(input); 284 | } else { 285 | input.skip(ftype); 286 | } 287 | break; 288 | case 1: 289 | if (ftype == Thrift.Type.STRUCT) { 290 | this.e = new ttypes.TalkException(); 291 | this.e.read(input); 292 | } else { 293 | input.skip(ftype); 294 | } 295 | break; 296 | default: 297 | input.skip(ftype); 298 | } 299 | input.readFieldEnd(); 300 | } 301 | input.readStructEnd(); 302 | return; 303 | }; 304 | 305 | SnsAdaptorService_getSnsMyProfile_result.prototype.write = function(output) { 306 | output.writeStructBegin('SnsAdaptorService_getSnsMyProfile_result'); 307 | if (this.success !== null && this.success !== undefined) { 308 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0); 309 | this.success.write(output); 310 | output.writeFieldEnd(); 311 | } 312 | if (this.e !== null && this.e !== undefined) { 313 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 314 | this.e.write(output); 315 | output.writeFieldEnd(); 316 | } 317 | output.writeFieldStop(); 318 | output.writeStructEnd(); 319 | return; 320 | }; 321 | 322 | SnsAdaptorService_postSnsInvitationMessage_args = function(args) { 323 | this.snsIdType = null; 324 | this.snsAccessToken = null; 325 | this.toSnsUserId = null; 326 | if (args) { 327 | if (args.snsIdType !== undefined) { 328 | this.snsIdType = args.snsIdType; 329 | } 330 | if (args.snsAccessToken !== undefined) { 331 | this.snsAccessToken = args.snsAccessToken; 332 | } 333 | if (args.toSnsUserId !== undefined) { 334 | this.toSnsUserId = args.toSnsUserId; 335 | } 336 | } 337 | }; 338 | SnsAdaptorService_postSnsInvitationMessage_args.prototype = {}; 339 | SnsAdaptorService_postSnsInvitationMessage_args.prototype.read = function(input) { 340 | input.readStructBegin(); 341 | while (true) 342 | { 343 | var ret = input.readFieldBegin(); 344 | var fname = ret.fname; 345 | var ftype = ret.ftype; 346 | var fid = ret.fid; 347 | if (ftype == Thrift.Type.STOP) { 348 | break; 349 | } 350 | switch (fid) 351 | { 352 | case 2: 353 | if (ftype == Thrift.Type.I32) { 354 | this.snsIdType = input.readI32(); 355 | } else { 356 | input.skip(ftype); 357 | } 358 | break; 359 | case 3: 360 | if (ftype == Thrift.Type.STRING) { 361 | this.snsAccessToken = input.readString(); 362 | } else { 363 | input.skip(ftype); 364 | } 365 | break; 366 | case 4: 367 | if (ftype == Thrift.Type.STRING) { 368 | this.toSnsUserId = input.readString(); 369 | } else { 370 | input.skip(ftype); 371 | } 372 | break; 373 | default: 374 | input.skip(ftype); 375 | } 376 | input.readFieldEnd(); 377 | } 378 | input.readStructEnd(); 379 | return; 380 | }; 381 | 382 | SnsAdaptorService_postSnsInvitationMessage_args.prototype.write = function(output) { 383 | output.writeStructBegin('SnsAdaptorService_postSnsInvitationMessage_args'); 384 | if (this.snsIdType !== null && this.snsIdType !== undefined) { 385 | output.writeFieldBegin('snsIdType', Thrift.Type.I32, 2); 386 | output.writeI32(this.snsIdType); 387 | output.writeFieldEnd(); 388 | } 389 | if (this.snsAccessToken !== null && this.snsAccessToken !== undefined) { 390 | output.writeFieldBegin('snsAccessToken', Thrift.Type.STRING, 3); 391 | output.writeString(this.snsAccessToken); 392 | output.writeFieldEnd(); 393 | } 394 | if (this.toSnsUserId !== null && this.toSnsUserId !== undefined) { 395 | output.writeFieldBegin('toSnsUserId', Thrift.Type.STRING, 4); 396 | output.writeString(this.toSnsUserId); 397 | output.writeFieldEnd(); 398 | } 399 | output.writeFieldStop(); 400 | output.writeStructEnd(); 401 | return; 402 | }; 403 | 404 | SnsAdaptorService_postSnsInvitationMessage_result = function(args) { 405 | this.e = null; 406 | if (args instanceof ttypes.TalkException) { 407 | this.e = args; 408 | return; 409 | } 410 | if (args) { 411 | if (args.e !== undefined) { 412 | this.e = args.e; 413 | } 414 | } 415 | }; 416 | SnsAdaptorService_postSnsInvitationMessage_result.prototype = {}; 417 | SnsAdaptorService_postSnsInvitationMessage_result.prototype.read = function(input) { 418 | input.readStructBegin(); 419 | while (true) 420 | { 421 | var ret = input.readFieldBegin(); 422 | var fname = ret.fname; 423 | var ftype = ret.ftype; 424 | var fid = ret.fid; 425 | if (ftype == Thrift.Type.STOP) { 426 | break; 427 | } 428 | switch (fid) 429 | { 430 | case 1: 431 | if (ftype == Thrift.Type.STRUCT) { 432 | this.e = new ttypes.TalkException(); 433 | this.e.read(input); 434 | } else { 435 | input.skip(ftype); 436 | } 437 | break; 438 | case 0: 439 | input.skip(ftype); 440 | break; 441 | default: 442 | input.skip(ftype); 443 | } 444 | input.readFieldEnd(); 445 | } 446 | input.readStructEnd(); 447 | return; 448 | }; 449 | 450 | SnsAdaptorService_postSnsInvitationMessage_result.prototype.write = function(output) { 451 | output.writeStructBegin('SnsAdaptorService_postSnsInvitationMessage_result'); 452 | if (this.e !== null && this.e !== undefined) { 453 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 454 | this.e.write(output); 455 | output.writeFieldEnd(); 456 | } 457 | output.writeFieldStop(); 458 | output.writeStructEnd(); 459 | return; 460 | }; 461 | 462 | SnsAdaptorServiceClient = exports.Client = function(output, pClass) { 463 | this.output = output; 464 | this.pClass = pClass; 465 | this._seqid = 0; 466 | this._reqs = {}; 467 | }; 468 | SnsAdaptorServiceClient.prototype = {}; 469 | SnsAdaptorServiceClient.prototype.seqid = function() { return this._seqid; } 470 | SnsAdaptorServiceClient.prototype.new_seqid = function() { return this._seqid += 1; } 471 | SnsAdaptorServiceClient.prototype.getSnsFriends = function(snsIdType, snsAccessToken, startIdx, limit, callback) { 472 | this._seqid = this.new_seqid(); 473 | if (callback === undefined) { 474 | var _defer = Q.defer(); 475 | this._reqs[this.seqid()] = function(error, result) { 476 | if (error) { 477 | _defer.reject(error); 478 | } else { 479 | _defer.resolve(result); 480 | } 481 | }; 482 | this.send_getSnsFriends(snsIdType, snsAccessToken, startIdx, limit); 483 | return _defer.promise; 484 | } else { 485 | this._reqs[this.seqid()] = callback; 486 | this.send_getSnsFriends(snsIdType, snsAccessToken, startIdx, limit); 487 | } 488 | }; 489 | 490 | SnsAdaptorServiceClient.prototype.send_getSnsFriends = function(snsIdType, snsAccessToken, startIdx, limit) { 491 | var output = new this.pClass(this.output); 492 | output.writeMessageBegin('getSnsFriends', Thrift.MessageType.CALL, this.seqid()); 493 | var args = new SnsAdaptorService_getSnsFriends_args(); 494 | args.snsIdType = snsIdType; 495 | args.snsAccessToken = snsAccessToken; 496 | args.startIdx = startIdx; 497 | args.limit = limit; 498 | args.write(output); 499 | output.writeMessageEnd(); 500 | return this.output.flush(); 501 | }; 502 | 503 | SnsAdaptorServiceClient.prototype.recv_getSnsFriends = function(input,mtype,rseqid) { 504 | var callback = this._reqs[rseqid] || function() {}; 505 | delete this._reqs[rseqid]; 506 | if (mtype == Thrift.MessageType.EXCEPTION) { 507 | var x = new Thrift.TApplicationException(); 508 | x.read(input); 509 | input.readMessageEnd(); 510 | return callback(x); 511 | } 512 | var result = new SnsAdaptorService_getSnsFriends_result(); 513 | result.read(input); 514 | input.readMessageEnd(); 515 | 516 | if (null !== result.e) { 517 | return callback(result.e); 518 | } 519 | if (null !== result.success) { 520 | return callback(null, result.success); 521 | } 522 | return callback('getSnsFriends failed: unknown result'); 523 | }; 524 | SnsAdaptorServiceClient.prototype.getSnsMyProfile = function(snsIdType, snsAccessToken, callback) { 525 | this._seqid = this.new_seqid(); 526 | if (callback === undefined) { 527 | var _defer = Q.defer(); 528 | this._reqs[this.seqid()] = function(error, result) { 529 | if (error) { 530 | _defer.reject(error); 531 | } else { 532 | _defer.resolve(result); 533 | } 534 | }; 535 | this.send_getSnsMyProfile(snsIdType, snsAccessToken); 536 | return _defer.promise; 537 | } else { 538 | this._reqs[this.seqid()] = callback; 539 | this.send_getSnsMyProfile(snsIdType, snsAccessToken); 540 | } 541 | }; 542 | 543 | SnsAdaptorServiceClient.prototype.send_getSnsMyProfile = function(snsIdType, snsAccessToken) { 544 | var output = new this.pClass(this.output); 545 | output.writeMessageBegin('getSnsMyProfile', Thrift.MessageType.CALL, this.seqid()); 546 | var args = new SnsAdaptorService_getSnsMyProfile_args(); 547 | args.snsIdType = snsIdType; 548 | args.snsAccessToken = snsAccessToken; 549 | args.write(output); 550 | output.writeMessageEnd(); 551 | return this.output.flush(); 552 | }; 553 | 554 | SnsAdaptorServiceClient.prototype.recv_getSnsMyProfile = function(input,mtype,rseqid) { 555 | var callback = this._reqs[rseqid] || function() {}; 556 | delete this._reqs[rseqid]; 557 | if (mtype == Thrift.MessageType.EXCEPTION) { 558 | var x = new Thrift.TApplicationException(); 559 | x.read(input); 560 | input.readMessageEnd(); 561 | return callback(x); 562 | } 563 | var result = new SnsAdaptorService_getSnsMyProfile_result(); 564 | result.read(input); 565 | input.readMessageEnd(); 566 | 567 | if (null !== result.e) { 568 | return callback(result.e); 569 | } 570 | if (null !== result.success) { 571 | return callback(null, result.success); 572 | } 573 | return callback('getSnsMyProfile failed: unknown result'); 574 | }; 575 | SnsAdaptorServiceClient.prototype.postSnsInvitationMessage = function(snsIdType, snsAccessToken, toSnsUserId, callback) { 576 | this._seqid = this.new_seqid(); 577 | if (callback === undefined) { 578 | var _defer = Q.defer(); 579 | this._reqs[this.seqid()] = function(error, result) { 580 | if (error) { 581 | _defer.reject(error); 582 | } else { 583 | _defer.resolve(result); 584 | } 585 | }; 586 | this.send_postSnsInvitationMessage(snsIdType, snsAccessToken, toSnsUserId); 587 | return _defer.promise; 588 | } else { 589 | this._reqs[this.seqid()] = callback; 590 | this.send_postSnsInvitationMessage(snsIdType, snsAccessToken, toSnsUserId); 591 | } 592 | }; 593 | 594 | SnsAdaptorServiceClient.prototype.send_postSnsInvitationMessage = function(snsIdType, snsAccessToken, toSnsUserId) { 595 | var output = new this.pClass(this.output); 596 | output.writeMessageBegin('postSnsInvitationMessage', Thrift.MessageType.CALL, this.seqid()); 597 | var args = new SnsAdaptorService_postSnsInvitationMessage_args(); 598 | args.snsIdType = snsIdType; 599 | args.snsAccessToken = snsAccessToken; 600 | args.toSnsUserId = toSnsUserId; 601 | args.write(output); 602 | output.writeMessageEnd(); 603 | return this.output.flush(); 604 | }; 605 | 606 | SnsAdaptorServiceClient.prototype.recv_postSnsInvitationMessage = function(input,mtype,rseqid) { 607 | var callback = this._reqs[rseqid] || function() {}; 608 | delete this._reqs[rseqid]; 609 | if (mtype == Thrift.MessageType.EXCEPTION) { 610 | var x = new Thrift.TApplicationException(); 611 | x.read(input); 612 | input.readMessageEnd(); 613 | return callback(x); 614 | } 615 | var result = new SnsAdaptorService_postSnsInvitationMessage_result(); 616 | result.read(input); 617 | input.readMessageEnd(); 618 | 619 | if (null !== result.e) { 620 | return callback(result.e); 621 | } 622 | callback(null) 623 | }; 624 | SnsAdaptorServiceProcessor = exports.Processor = function(handler) { 625 | this._handler = handler 626 | } 627 | SnsAdaptorServiceProcessor.prototype.process = function(input, output) { 628 | var r = input.readMessageBegin(); 629 | if (this['process_' + r.fname]) { 630 | return this['process_' + r.fname].call(this, r.rseqid, input, output); 631 | } else { 632 | input.skip(Thrift.Type.STRUCT); 633 | input.readMessageEnd(); 634 | var x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname); 635 | output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid); 636 | x.write(output); 637 | output.writeMessageEnd(); 638 | output.flush(); 639 | } 640 | } 641 | 642 | SnsAdaptorServiceProcessor.prototype.process_getSnsFriends = function(seqid, input, output) { 643 | var args = new SnsAdaptorService_getSnsFriends_args(); 644 | args.read(input); 645 | input.readMessageEnd(); 646 | if (this._handler.getSnsFriends.length === 4) { 647 | Q.fcall(this._handler.getSnsFriends, args.snsIdType, args.snsAccessToken, args.startIdx, args.limit) 648 | .then(function(result) { 649 | var result = new SnsAdaptorService_getSnsFriends_result({success: result}); 650 | output.writeMessageBegin("getSnsFriends", Thrift.MessageType.REPLY, seqid); 651 | result.write(output); 652 | output.writeMessageEnd(); 653 | output.flush(); 654 | }, function (err) { 655 | var result = new SnsAdaptorService_getSnsFriends_result(err); 656 | output.writeMessageBegin("getSnsFriends", Thrift.MessageType.REPLY, seqid); 657 | result.write(output); 658 | output.writeMessageEnd(); 659 | output.flush(); 660 | }); 661 | } else { 662 | this._handler.getSnsFriends(args.snsIdType, args.snsAccessToken, args.startIdx, args.limit, function (err, result) { 663 | var result = new SnsAdaptorService_getSnsFriends_result((err != null ? err : {success: result})); 664 | output.writeMessageBegin("getSnsFriends", Thrift.MessageType.REPLY, seqid); 665 | result.write(output); 666 | output.writeMessageEnd(); 667 | output.flush(); 668 | }); 669 | } 670 | } 671 | 672 | SnsAdaptorServiceProcessor.prototype.process_getSnsMyProfile = function(seqid, input, output) { 673 | var args = new SnsAdaptorService_getSnsMyProfile_args(); 674 | args.read(input); 675 | input.readMessageEnd(); 676 | if (this._handler.getSnsMyProfile.length === 2) { 677 | Q.fcall(this._handler.getSnsMyProfile, args.snsIdType, args.snsAccessToken) 678 | .then(function(result) { 679 | var result = new SnsAdaptorService_getSnsMyProfile_result({success: result}); 680 | output.writeMessageBegin("getSnsMyProfile", Thrift.MessageType.REPLY, seqid); 681 | result.write(output); 682 | output.writeMessageEnd(); 683 | output.flush(); 684 | }, function (err) { 685 | var result = new SnsAdaptorService_getSnsMyProfile_result(err); 686 | output.writeMessageBegin("getSnsMyProfile", Thrift.MessageType.REPLY, seqid); 687 | result.write(output); 688 | output.writeMessageEnd(); 689 | output.flush(); 690 | }); 691 | } else { 692 | this._handler.getSnsMyProfile(args.snsIdType, args.snsAccessToken, function (err, result) { 693 | var result = new SnsAdaptorService_getSnsMyProfile_result((err != null ? err : {success: result})); 694 | output.writeMessageBegin("getSnsMyProfile", Thrift.MessageType.REPLY, seqid); 695 | result.write(output); 696 | output.writeMessageEnd(); 697 | output.flush(); 698 | }); 699 | } 700 | } 701 | 702 | SnsAdaptorServiceProcessor.prototype.process_postSnsInvitationMessage = function(seqid, input, output) { 703 | var args = new SnsAdaptorService_postSnsInvitationMessage_args(); 704 | args.read(input); 705 | input.readMessageEnd(); 706 | if (this._handler.postSnsInvitationMessage.length === 3) { 707 | Q.fcall(this._handler.postSnsInvitationMessage, args.snsIdType, args.snsAccessToken, args.toSnsUserId) 708 | .then(function(result) { 709 | var result = new SnsAdaptorService_postSnsInvitationMessage_result({success: result}); 710 | output.writeMessageBegin("postSnsInvitationMessage", Thrift.MessageType.REPLY, seqid); 711 | result.write(output); 712 | output.writeMessageEnd(); 713 | output.flush(); 714 | }, function (err) { 715 | var result = new SnsAdaptorService_postSnsInvitationMessage_result(err); 716 | output.writeMessageBegin("postSnsInvitationMessage", Thrift.MessageType.REPLY, seqid); 717 | result.write(output); 718 | output.writeMessageEnd(); 719 | output.flush(); 720 | }); 721 | } else { 722 | this._handler.postSnsInvitationMessage(args.snsIdType, args.snsAccessToken, args.toSnsUserId, function (err, result) { 723 | var result = new SnsAdaptorService_postSnsInvitationMessage_result((err != null ? err : {success: result})); 724 | output.writeMessageBegin("postSnsInvitationMessage", Thrift.MessageType.REPLY, seqid); 725 | result.write(output); 726 | output.writeMessageEnd(); 727 | output.flush(); 728 | }); 729 | } 730 | } 731 | 732 | -------------------------------------------------------------------------------- /lib/gen-nodejs/UniversalNotificationService.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift Compiler (0.9.2) 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | var thrift = require('thrift'); 7 | var Thrift = thrift.Thrift; 8 | var Q = thrift.Q; 9 | 10 | 11 | var ttypes = require('./line_types'); 12 | //HELPER FUNCTIONS AND STRUCTURES 13 | 14 | UniversalNotificationService_notify_args = function(args) { 15 | this.event = null; 16 | if (args) { 17 | if (args.event !== undefined) { 18 | this.event = args.event; 19 | } 20 | } 21 | }; 22 | UniversalNotificationService_notify_args.prototype = {}; 23 | UniversalNotificationService_notify_args.prototype.read = function(input) { 24 | input.readStructBegin(); 25 | while (true) 26 | { 27 | var ret = input.readFieldBegin(); 28 | var fname = ret.fname; 29 | var ftype = ret.ftype; 30 | var fid = ret.fid; 31 | if (ftype == Thrift.Type.STOP) { 32 | break; 33 | } 34 | switch (fid) 35 | { 36 | case 2: 37 | if (ftype == Thrift.Type.STRUCT) { 38 | this.event = new ttypes.GlobalEvent(); 39 | this.event.read(input); 40 | } else { 41 | input.skip(ftype); 42 | } 43 | break; 44 | case 0: 45 | input.skip(ftype); 46 | break; 47 | default: 48 | input.skip(ftype); 49 | } 50 | input.readFieldEnd(); 51 | } 52 | input.readStructEnd(); 53 | return; 54 | }; 55 | 56 | UniversalNotificationService_notify_args.prototype.write = function(output) { 57 | output.writeStructBegin('UniversalNotificationService_notify_args'); 58 | if (this.event !== null && this.event !== undefined) { 59 | output.writeFieldBegin('event', Thrift.Type.STRUCT, 2); 60 | this.event.write(output); 61 | output.writeFieldEnd(); 62 | } 63 | output.writeFieldStop(); 64 | output.writeStructEnd(); 65 | return; 66 | }; 67 | 68 | UniversalNotificationService_notify_result = function(args) { 69 | this.e = null; 70 | if (args instanceof ttypes.UniversalNotificationServiceException) { 71 | this.e = args; 72 | return; 73 | } 74 | if (args) { 75 | if (args.e !== undefined) { 76 | this.e = args.e; 77 | } 78 | } 79 | }; 80 | UniversalNotificationService_notify_result.prototype = {}; 81 | UniversalNotificationService_notify_result.prototype.read = function(input) { 82 | input.readStructBegin(); 83 | while (true) 84 | { 85 | var ret = input.readFieldBegin(); 86 | var fname = ret.fname; 87 | var ftype = ret.ftype; 88 | var fid = ret.fid; 89 | if (ftype == Thrift.Type.STOP) { 90 | break; 91 | } 92 | switch (fid) 93 | { 94 | case 1: 95 | if (ftype == Thrift.Type.STRUCT) { 96 | this.e = new ttypes.UniversalNotificationServiceException(); 97 | this.e.read(input); 98 | } else { 99 | input.skip(ftype); 100 | } 101 | break; 102 | case 0: 103 | input.skip(ftype); 104 | break; 105 | default: 106 | input.skip(ftype); 107 | } 108 | input.readFieldEnd(); 109 | } 110 | input.readStructEnd(); 111 | return; 112 | }; 113 | 114 | UniversalNotificationService_notify_result.prototype.write = function(output) { 115 | output.writeStructBegin('UniversalNotificationService_notify_result'); 116 | if (this.e !== null && this.e !== undefined) { 117 | output.writeFieldBegin('e', Thrift.Type.STRUCT, 1); 118 | this.e.write(output); 119 | output.writeFieldEnd(); 120 | } 121 | output.writeFieldStop(); 122 | output.writeStructEnd(); 123 | return; 124 | }; 125 | 126 | UniversalNotificationServiceClient = exports.Client = function(output, pClass) { 127 | this.output = output; 128 | this.pClass = pClass; 129 | this._seqid = 0; 130 | this._reqs = {}; 131 | }; 132 | UniversalNotificationServiceClient.prototype = {}; 133 | UniversalNotificationServiceClient.prototype.seqid = function() { return this._seqid; } 134 | UniversalNotificationServiceClient.prototype.new_seqid = function() { return this._seqid += 1; } 135 | UniversalNotificationServiceClient.prototype.notify = function(event, callback) { 136 | this._seqid = this.new_seqid(); 137 | if (callback === undefined) { 138 | var _defer = Q.defer(); 139 | this._reqs[this.seqid()] = function(error, result) { 140 | if (error) { 141 | _defer.reject(error); 142 | } else { 143 | _defer.resolve(result); 144 | } 145 | }; 146 | this.send_notify(event); 147 | return _defer.promise; 148 | } else { 149 | this._reqs[this.seqid()] = callback; 150 | this.send_notify(event); 151 | } 152 | }; 153 | 154 | UniversalNotificationServiceClient.prototype.send_notify = function(event) { 155 | var output = new this.pClass(this.output); 156 | output.writeMessageBegin('notify', Thrift.MessageType.CALL, this.seqid()); 157 | var args = new UniversalNotificationService_notify_args(); 158 | args.event = event; 159 | args.write(output); 160 | output.writeMessageEnd(); 161 | return this.output.flush(); 162 | }; 163 | 164 | UniversalNotificationServiceClient.prototype.recv_notify = function(input,mtype,rseqid) { 165 | var callback = this._reqs[rseqid] || function() {}; 166 | delete this._reqs[rseqid]; 167 | if (mtype == Thrift.MessageType.EXCEPTION) { 168 | var x = new Thrift.TApplicationException(); 169 | x.read(input); 170 | input.readMessageEnd(); 171 | return callback(x); 172 | } 173 | var result = new UniversalNotificationService_notify_result(); 174 | result.read(input); 175 | input.readMessageEnd(); 176 | 177 | if (null !== result.e) { 178 | return callback(result.e); 179 | } 180 | callback(null) 181 | }; 182 | UniversalNotificationServiceProcessor = exports.Processor = function(handler) { 183 | this._handler = handler 184 | } 185 | UniversalNotificationServiceProcessor.prototype.process = function(input, output) { 186 | var r = input.readMessageBegin(); 187 | if (this['process_' + r.fname]) { 188 | return this['process_' + r.fname].call(this, r.rseqid, input, output); 189 | } else { 190 | input.skip(Thrift.Type.STRUCT); 191 | input.readMessageEnd(); 192 | var x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname); 193 | output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid); 194 | x.write(output); 195 | output.writeMessageEnd(); 196 | output.flush(); 197 | } 198 | } 199 | 200 | UniversalNotificationServiceProcessor.prototype.process_notify = function(seqid, input, output) { 201 | var args = new UniversalNotificationService_notify_args(); 202 | args.read(input); 203 | input.readMessageEnd(); 204 | if (this._handler.notify.length === 1) { 205 | Q.fcall(this._handler.notify, args.event) 206 | .then(function(result) { 207 | var result = new UniversalNotificationService_notify_result({success: result}); 208 | output.writeMessageBegin("notify", Thrift.MessageType.REPLY, seqid); 209 | result.write(output); 210 | output.writeMessageEnd(); 211 | output.flush(); 212 | }, function (err) { 213 | var result = new UniversalNotificationService_notify_result(err); 214 | output.writeMessageBegin("notify", Thrift.MessageType.REPLY, seqid); 215 | result.write(output); 216 | output.writeMessageEnd(); 217 | output.flush(); 218 | }); 219 | } else { 220 | this._handler.notify(args.event, function (err, result) { 221 | var result = new UniversalNotificationService_notify_result((err != null ? err : {success: result})); 222 | output.writeMessageBegin("notify", Thrift.MessageType.REPLY, seqid); 223 | result.write(output); 224 | output.writeMessageEnd(); 225 | output.flush(); 226 | }); 227 | } 228 | } 229 | 230 | -------------------------------------------------------------------------------- /lib/line_client.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var thrift = require('thrift'), 4 | line_types = require('./gen-nodejs/line_types'), 5 | talk_service = require('./gen-nodejs/TalkService'); 6 | 7 | var request = require('request'); 8 | 9 | var Message = line_types.Message, 10 | ContentType = line_types.ContentType, 11 | OperationType = line_types.OperationType; 12 | 13 | // Constant 14 | var LINE_DOMAIN = 'gd2.line.naver.jp', 15 | LINE_PATH = '/api/v4/TalkService.do', 16 | LINE_IN_PATH = '/P4', 17 | LINE_CERTIFICATE_PATH = '/Q', 18 | LINE_SESSION_LINE_PATH = '/authct/v1/keys/line', 19 | LINE_SESSION_NAVER_PATH = '/authct/v1/keys/naver'; 20 | 21 | // Line Config 22 | var ip = '127.0.0.1', 23 | version = '3.7.0', 24 | com_name = 'webline', 25 | revision = 0; 26 | 27 | // LineClient 28 | var LineClient = function(email, password) { 29 | this._userInfo = { 30 | email: email, 31 | password: password 32 | }; 33 | this._header = { 34 | 'Content-Type': 'application/x-thrift', 35 | 'X-Line-Application': 'DESKTOPMAC\t3.7.0\tMAC\t10.9.4-MAVERICKS-x64' 36 | }; 37 | this._thrift_options = null; 38 | this._revision = null; 39 | 40 | this._connection = null; 41 | this._client = null; 42 | }; 43 | 44 | LineClient.prototype.initConnection = function() { 45 | // Line Thrift Config 46 | this._thrift_options = { 47 | transport: thrift.TBufferedTransport, 48 | protocol: thrift.TCompactProtocol, 49 | path: LINE_PATH, 50 | headers: this._header, 51 | https: false 52 | }; 53 | 54 | this._connection = thrift.createHttpConnection(LINE_DOMAIN, 80, this._thrift_options); 55 | this._client = thrift.createHttpClient(TalkServiceClient, this._connection); 56 | 57 | this._connection.on('error', function(err) { 58 | console.log(err); 59 | }); 60 | }; 61 | 62 | LineClient.prototype.login = function(_callback_options) { 63 | var lc = this; 64 | lc.initConnection(); 65 | lc._client.loginWithIdentityCredentialForCertificate(1, 66 | lc._userInfo.email, lc._userInfo.password, 67 | true, ip, com_name, '', function(err, result) { 68 | 69 | var request_options, verifier_code; 70 | if (!err && _callback_options.success) { 71 | if (_callback_options.waiting) { 72 | _callback_options.waiting(err, result); 73 | } 74 | 75 | verifier_code = result.verifier; 76 | request_options = { 77 | url: 'http://' + LINE_DOMAIN + LINE_CERTIFICATE_PATH, 78 | headers: { 79 | 'X-Line-Access': verifier_code 80 | } 81 | }; 82 | 83 | // Wait for verify http get block 84 | request(request_options, function (err, response, body) { 85 | 86 | if (!err) { 87 | // Get authToken 88 | lc._client.loginWithVerifierForCertificate(verifier_code, function(err, auth_info) { 89 | 90 | if (!err) { 91 | // Add authToken to header 92 | lc._header['X-Line-Access'] = auth_info.authToken; 93 | 94 | // Update Revision 95 | lc._client.getLastOpRevision(function(err, revision) { 96 | lc._revision = revision; 97 | _callback_options.success(err, revision); 98 | }); 99 | } else if (_callback_options.error) { 100 | _callback_options.error(err); 101 | console.log(err); 102 | } 103 | }); 104 | } else if (_callback_options.error) { 105 | _callback_options.error(err); 106 | console.log(err); 107 | } 108 | }); 109 | } else if(_callback_options.error) { 110 | _callback_options.error(err); 111 | console.log(err); 112 | } 113 | }); 114 | }; 115 | 116 | LineClient.prototype.getProfile = function(_callback) { 117 | this._client.getProfile(function(err, result) { 118 | _callback(err, result); 119 | }); 120 | }; 121 | 122 | LineClient.prototype.getAllContactIds = function(_callback) { 123 | this._client.getAllContactIds(function(err, result) { 124 | _callback(err, result); 125 | }); 126 | }; 127 | 128 | LineClient.prototype.getContacts = function(ids, _callback) { 129 | this._client.getContacts(ids, function(err, result) { 130 | _callback(err, result); 131 | }); 132 | }; 133 | 134 | LineClient.prototype.getRecentMessages = function(id, count, _callback) { 135 | this._client.getRecentMessages(id, count, function(err, result) { 136 | 137 | // Convert contentPreview to Base64 138 | for (var i = 0; i < result.length ; i++) { 139 | if ( result[i].contentPreview != null ) { 140 | result[i].contentPreview = new Buffer(result[i].contentPreview, 'binary').toString('base64'); 141 | console.log(result[i].contentPreview); 142 | } 143 | } 144 | 145 | _callback(err, result); 146 | }); 147 | }; 148 | 149 | LineClient.prototype.sendSticker = function(id, contentMetadata, _callback) { 150 | var message = new Message({ 151 | to: id, 152 | text: '', 153 | contentType: ContentType.STICKER, 154 | contentMetadata: contentMetadata 155 | }); 156 | 157 | this._client.sendMessage(id, message, function(error, result) { 158 | _callback(error, result); 159 | }); 160 | }; 161 | 162 | 163 | LineClient.prototype.sendMessage = function(id, message, _callback) { 164 | var message = new Message({ 165 | to: id, 166 | text: message 167 | }); 168 | 169 | this._client.sendMessage(id, message, function(error, result) { 170 | _callback(error, result); 171 | }); 172 | }; 173 | 174 | LineClient.prototype.longPoll = function(size, _callback) { 175 | var lc = this; 176 | lc._client.fetchOperations(lc._revision, size, function(err, operations) { 177 | if (!err) { 178 | for (var i = 0; i < operations.length; i++) { 179 | lc._revision = (operations[i].revision > lc._revision) ? operations[i].revision : lc._revision; 180 | } 181 | _callback(err, operations); 182 | } else { 183 | console.log(err); 184 | } 185 | }); 186 | }; 187 | 188 | module.exports = LineClient; 189 | -------------------------------------------------------------------------------- /lib/socket_client.js: -------------------------------------------------------------------------------- 1 | //'use strict'; Disable strict mode to delete Object when user disconnect. 2 | 3 | var LineClient = require('../lib/line_client'); 4 | 5 | // SocketClient 6 | var SocketClient = function(channel_name) { 7 | this._io = this.io; 8 | this._socketlock = false; 9 | 10 | var sc = this; 11 | sc._channel = sc._io.of('/' + channel_name); 12 | sc._channel.on('connection', function(socket) { 13 | if (sc._socketlock) { 14 | // Avoid duplicate user 15 | socket.disconnect(); 16 | return; 17 | } else { 18 | sc._socketlock = true; 19 | } 20 | 21 | var line_client = null; 22 | socket.on('login', function(user) { 23 | line_client = new LineClient(user.id, user.password); 24 | line_client.login({ 25 | waiting: function(err, result) { 26 | sc._channel.emit('login_waiting', { 27 | err: err, 28 | result: result 29 | }); 30 | }, 31 | success: function(err, result) { 32 | sc._channel.emit('login_success', { 33 | err: err, 34 | result: result 35 | }); 36 | 37 | // Start polling 38 | sc.polling(line_client); 39 | }, 40 | error: function(err, result) { 41 | sc._channel.emit('login_error', { 42 | err: err, 43 | result: result 44 | }); 45 | }, 46 | }); 47 | }); 48 | 49 | socket.on('getProfile', function() { 50 | line_client.getProfile(function(err, result) { 51 | sc._channel.emit('getProfile_response', { 52 | err: err, 53 | result: result 54 | }); 55 | }); 56 | }); 57 | 58 | socket.on('getContacts', function() { 59 | line_client.getAllContactIds(function(err, ids) { 60 | line_client.getContacts(ids, function(err, result) { 61 | sc._channel.emit('getContacts_response', { 62 | err: err, 63 | result: result 64 | }); 65 | }); 66 | }); 67 | }); 68 | 69 | socket.on('getRecentMessages', function(option) { 70 | line_client.getRecentMessages(option.id, option.size, function(err, result) { 71 | sc._channel.emit('getRecentMessages_response', { 72 | err: err, 73 | result: result 74 | }); 75 | }); 76 | }); 77 | 78 | socket.on('sendMessage', function(option) { 79 | line_client.sendMessage(option.id, option.message, function(err, result) { 80 | sc._channel.emit('sendMessage_response', { 81 | err: err, 82 | result: result 83 | }); 84 | }); 85 | }); 86 | 87 | socket.on('disconnect', function(){ 88 | var connections = sc._channel.sockets.length; 89 | 90 | // Release SockectClient and clean socket.io namespace 91 | if (connections == 0) { 92 | delete sc._channel; 93 | delete sc; 94 | } 95 | }); 96 | }); 97 | }; 98 | 99 | SocketClient.prototype.polling = function(line_client) { 100 | var sc = this, 101 | interval = 1200; 102 | 103 | setInterval(function() { 104 | line_client.longPoll(50, function(err, result) { 105 | console.log('polling'); 106 | if (result) { 107 | sc._channel.emit('polling', { 108 | err: err, 109 | result: result 110 | }); 111 | } 112 | }); 113 | }, interval); 114 | }; 115 | 116 | SocketClient.prototype.io = null 117 | 118 | module.exports = SocketClient; 119 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web-LINE", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node ./bin/www", 7 | "postinstall": "export HOME=$HOME/app-root/runtime/repo; ./node_modules/bower/bin/bower install" 8 | }, 9 | "main": "./bin/www", 10 | "dependencies": { 11 | "MD5": "^1.2.1", 12 | "body-parser": "~1.12.0", 13 | "bower": "^1.4.1", 14 | "cookie-parser": "~1.3.3", 15 | "debug": "~2.1.0", 16 | "ejs": "~2.3.1", 17 | "express": "~4.12.0", 18 | "morgan": "~1.5.0", 19 | "node-int64": "^0.4.0", 20 | "request": "^2.55.0", 21 | "serve-favicon": "~2.2.0", 22 | "socket.io": "^1.3.5", 23 | "thrift": "^0.9.2" 24 | }, 25 | "devDependencies": { 26 | "grunt": "~0.4.5", 27 | "grunt-develop": "~0.4.0", 28 | "grunt-sass": "~0.18.0", 29 | "grunt-contrib-watch": "~0.6.1", 30 | "request": "~2.55.0", 31 | "time-grunt": "~1.1.0", 32 | "load-grunt-tasks": "~3.1.0" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /public/css/style.css: -------------------------------------------------------------------------------- 1 | body, html, .container { 2 | height: 100%; } 3 | 4 | .container { 5 | width: 970px !important; } 6 | 7 | #chat { 8 | overflow: hidden; } 9 | 10 | .buddy-container { 11 | position: relative; 12 | width: 100%; 13 | height: 100%; } 14 | 15 | .search-buddy { 16 | position: absolute; 17 | top: 0; 18 | margin: 10px 0 10px 0; } 19 | 20 | .buddy-list { 21 | position: absolute; 22 | padding-top: 54px; 23 | height: 100%; 24 | width: 100%; } 25 | .buddy-list .contact { 26 | display: inline-block; 27 | width: 100%; } 28 | .buddy-list .contact .avatar { 29 | float: left; 30 | width: 50px; 31 | height: 50px; } 32 | .buddy-list .contact .description { 33 | float: left; 34 | padding-left: 10px; } 35 | .buddy-list .contact .description .list-group-item-text { 36 | width: 150px; 37 | overflow: hidden; 38 | text-overflow: ellipsis; } 39 | 40 | #chat { 41 | height: 100%; 42 | overflow: scroll; } 43 | 44 | .buddy-frame, .chat-frame { 45 | position: relative; 46 | height: 100%; } 47 | 48 | .scroller { 49 | height: 100%; 50 | overflow-y: hidden; 51 | position: relative; } 52 | 53 | .panel-default { 54 | position: relative; 55 | height: 100%; 56 | margin: 0; } 57 | 58 | .navbar-messagebox { 59 | position: absolute; 60 | padding: 10px; 61 | margin: 0; 62 | bottom: 0; 63 | width: 100%; 64 | height: 56px; } 65 | 66 | .messagebox-frame { 67 | position: absolute; 68 | top: 0; 69 | height: 100%; 70 | width: 100%; 71 | padding-bottom: 56px; } 72 | 73 | .messagebox { 74 | position: relative; 75 | height: 100%; } 76 | 77 | .messagelist { 78 | position: absolute; 79 | bottom: 0; 80 | max-height: 100%; } 81 | 82 | .message { 83 | display: inline-block; 84 | width: 100%; 85 | padding: 0px 5px; 86 | z-index: 300; } 87 | .message .bubble { 88 | max-width: 60%; 89 | font-size: 16px; 90 | background-color: #F2F2F2; 91 | border-radius: 10px; 92 | display: inline-block; 93 | padding: 10px 18px; 94 | position: relative; 95 | vertical-align: top; } 96 | .message .bubble img, .message .bubble iframe { 97 | width: 100%; } 98 | .message .bubble::before { 99 | background-color: #F2F2F2; 100 | content: "\00a0"; 101 | display: block; 102 | height: 16px; 103 | position: absolute; 104 | top: 11px; 105 | transform: rotate(29deg) skew(-35deg); 106 | -moz-transform: rotate(29deg) skew(-35deg); 107 | -ms-transform: rotate(29deg) skew(-35deg); 108 | -o-transform: rotate(29deg) skew(-35deg); 109 | -webkit-transform: rotate(29deg) skew(-35deg); 110 | width: 20px; } 111 | .message .you { 112 | float: left; 113 | margin: 5px 10px 5px 20px; } 114 | .message .you::before { 115 | left: -9px; } 116 | .message .me { 117 | float: right; 118 | margin: 5px 20px 5px 10px; 119 | background-color: #1bb200; 120 | color: white; } 121 | .message .me a { 122 | color: #ddd; } 123 | .message .me::before { 124 | right: -9px; 125 | background-color: #1bb200; } 126 | .message .typing { 127 | opacity: 0.7; 128 | font-size: 14px; 129 | color: #888; } 130 | .message .typing::before { 131 | display: none; } 132 | .message .time { 133 | margin: 0 0; 134 | margin-top: 25px; 135 | background-color: transparent; 136 | color: #666; 137 | font-weight: 500; 138 | font-size: 12px; 139 | font-style: italic; } 140 | .message .time.me { 141 | float: right; } 142 | .message .time.you { 143 | float: left; } 144 | .message .avatar { 145 | width: 40px; 146 | height: 40px; 147 | margin: 5px 0; } 148 | .message .avatar.me { 149 | float: right; } 150 | .message .avatar.you { 151 | float: left; } 152 | .message .alert-disconnect { 153 | margin-top: 20px; } 154 | -------------------------------------------------------------------------------- /public/css/style.scss: -------------------------------------------------------------------------------- 1 | body, html, .container { 2 | height: 100%; 3 | } 4 | 5 | .container { 6 | width: 970px !important; 7 | } 8 | 9 | #chat { 10 | overflow: hidden; 11 | } 12 | 13 | .buddy-container { 14 | position: relative; 15 | width: 100%; 16 | height: 100%; 17 | } 18 | 19 | .search-buddy { 20 | position: absolute; 21 | top: 0; 22 | margin: 10px 0 10px 0; 23 | } 24 | 25 | .buddy-list { 26 | position: absolute; 27 | padding-top: 54px; 28 | height: 100%; 29 | width: 100%; 30 | 31 | .contact { 32 | display: inline-block; 33 | width: 100%; 34 | .avatar { 35 | float: left; 36 | width: 50px; 37 | height: 50px; 38 | } 39 | .description { 40 | float: left; 41 | padding-left: 10px; 42 | .list-group-item-text { 43 | width: 150px; 44 | overflow: hidden; 45 | text-overflow: ellipsis; 46 | } 47 | } 48 | } 49 | } 50 | 51 | #chat { 52 | height: 100%; 53 | overflow: scroll; 54 | } 55 | 56 | .buddy-frame, .chat-frame { 57 | position: relative; 58 | height: 100%; 59 | } 60 | 61 | .scroller { 62 | height: 100%; 63 | overflow-y: hidden; 64 | position: relative; 65 | } 66 | 67 | .panel-default { 68 | position: relative; 69 | height: 100%; 70 | margin: 0; 71 | } 72 | 73 | .navbar-messagebox { 74 | position: absolute; 75 | padding: 10px; 76 | margin: 0; 77 | bottom: 0; 78 | width: 100%; 79 | height: 56px; 80 | } 81 | 82 | .messagebox-frame { 83 | position: absolute; 84 | top: 0; 85 | height: 100%; 86 | width: 100%; 87 | padding-bottom: 56px; 88 | } 89 | 90 | .messagebox { 91 | position: relative; 92 | height: 100%; 93 | } 94 | 95 | .messagelist { 96 | position: absolute; 97 | bottom: 0; 98 | max-height: 100%; 99 | } 100 | 101 | .message { 102 | display: inline-block; 103 | width: 100%; 104 | padding: 0px 5px; 105 | z-index: 300; 106 | 107 | .bubble{ 108 | max-width: 60%; 109 | font-size: 16px; 110 | background-color: #F2F2F2; 111 | border-radius: 10px; 112 | display: inline-block; 113 | padding: 10px 18px; 114 | position: relative; 115 | vertical-align: top; 116 | 117 | img, iframe { 118 | width: 100%; 119 | } 120 | } 121 | 122 | .bubble::before { 123 | background-color: #F2F2F2; 124 | content: "\00a0"; 125 | display: block; 126 | height: 16px; 127 | position: absolute; 128 | top: 11px; 129 | transform: rotate( 29deg ) skew( -35deg ); 130 | -moz-transform: rotate( 29deg ) skew( -35deg ); 131 | -ms-transform: rotate( 29deg ) skew( -35deg ); 132 | -o-transform: rotate( 29deg ) skew( -35deg ); 133 | -webkit-transform: rotate( 29deg ) skew( -35deg ); 134 | width: 20px; 135 | } 136 | 137 | .you { 138 | float: left; 139 | margin: 5px 10px 5px 20px; 140 | } 141 | 142 | .you::before { 143 | left: -9px; 144 | } 145 | 146 | .me{ 147 | float: right; 148 | margin: 5px 20px 5px 10px; 149 | 150 | background-color: rgba(27, 178, 0, 1); 151 | color: white; 152 | 153 | a { 154 | color: #ddd; 155 | } 156 | } 157 | 158 | .me::before { 159 | right: -9px; 160 | background-color: rgba(27, 178, 0, 1); 161 | } 162 | 163 | .typing { 164 | opacity: 0.7; 165 | font-size: 14px; 166 | color: #888; 167 | } 168 | 169 | .typing::before { 170 | display: none; 171 | } 172 | 173 | .time { 174 | margin: 0 0; 175 | margin-top: 25px; 176 | background-color: rgba(0,0,0,0); 177 | color: #666; 178 | font-weight: 500; 179 | font-size: 12px; 180 | font-style: italic; 181 | } 182 | 183 | .time.me { 184 | float: right; 185 | } 186 | 187 | .time.you { 188 | float: left; 189 | } 190 | 191 | .avatar { 192 | width: 40px; 193 | height: 40px; 194 | margin: 5px 0; 195 | } 196 | 197 | .avatar.me { 198 | float: right; 199 | } 200 | 201 | .avatar.you { 202 | float: left; 203 | } 204 | 205 | .alert-disconnect { 206 | margin-top: 20px; 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /public/img/no-avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swallowcc/Web-LINE/4c2ec80dedbc89d651e116ef4d5aa66dea9f6e66/public/img/no-avatar.png -------------------------------------------------------------------------------- /public/js/app.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | angular.module('webLineApp', 3 | ['ngAnimate', 'angularMoment', 'btford.socket-io', 4 | 'perfect_scrollbar', 'luegg.directives']) 5 | 6 | .run(function(amMoment) { 7 | amMoment.changeLocale('zh-tw'); 8 | }) 9 | 10 | .factory('socket', function (socketFactory) { 11 | return socketFactory({ 12 | ioSocket: io.connect(Host + '/' + ChannelName) 13 | }) 14 | }) 15 | 16 | .controller('mainCtrl', function ($scope, $http, socket) { 17 | // State: login -> chat 18 | $scope.appStatus = 'login'; 19 | $scope.revision = null; 20 | 21 | $scope.changeAppStatus = function(status) { 22 | if (status == 'chat') { 23 | window.onbeforeunload = function() { 24 | return '離開本頁會斷線喔。' 25 | }; 26 | } 27 | $scope.appStatus = status; 28 | }; 29 | 30 | $scope.updateRevision = function(revision) { 31 | $scope.revision = revision; 32 | }; 33 | }) 34 | 35 | .controller('loginCtrl', ['$scope', 'loginService', 36 | 37 | function ($scope, loginService) { 38 | // State: prepare -> verify_code -> [success, error] 39 | $scope.loginStatus = 'prepare'; 40 | 41 | $scope.model = { 42 | id: '', 43 | password: '' 44 | }; 45 | 46 | $scope.loginBusy = false; 47 | $scope.loginError = null; 48 | $scope.pinCode = ''; 49 | 50 | 51 | $scope.login = function() { 52 | loginService.login($scope.model) 53 | .then(function(response) { 54 | $scope.loginStatus = 'success'; 55 | 56 | // change AppStatus 57 | $scope.changeAppStatus('chat'); 58 | 59 | // update Revision 60 | $scope.updateRevision(response.result); 61 | }, function(response) { 62 | $scope.loginStatus = 'error'; 63 | $scope.loginError = response.err; 64 | }, function(response) { 65 | $scope.loginStatus = 'verify_code'; 66 | $scope.pinCode = response.result.pinCode; 67 | }); 68 | $scope.loginBusy = true; 69 | }; 70 | } 71 | ]) 72 | 73 | .controller('chatFrameCtrl', ['$scope', '$q', 'chatService', 74 | 75 | function ($scope, $q, chatService) { 76 | // State: intialize -> unselect_buddy -> fetch_recent_messages <-> ready_to_chat 77 | $scope.chatFrameStatus = 'intialize'; 78 | 79 | $scope.myProfile = null; 80 | $scope.buddyProfile = null; 81 | 82 | $scope.myAvatar = null; 83 | $scope.buddyAvatar = null; 84 | 85 | $scope.messages = []; 86 | $scope.buddies = []; 87 | 88 | var genAvatar = function(path) { 89 | return path ? ('http://os.line.naver.jp/' + path + '/preview') : '/img/no-avatar.png'; 90 | } 91 | 92 | $scope.selectBuddy = function(buddy) { 93 | $scope.buddyProfile = buddy; 94 | $scope.buddyAvatar = genAvatar($scope.buddyProfile.picturePath); 95 | 96 | $scope.getRecentMessages(); 97 | }; 98 | 99 | $scope.getRecentMessages = function() { 100 | $scope.messages = []; 101 | 102 | $scope.chatFrameStatus = 'fetch_recent_messages'; 103 | chatService.getRecentMessages($scope.buddyProfile.mid) 104 | .then(function(response) { 105 | $scope.messages = response.result.reverse(); 106 | 107 | $scope.chatFrameStatus = 'ready_to_chat'; 108 | }); 109 | }; 110 | 111 | $q.all([chatService.getProfile(), chatService.getContacts()]) 112 | .then(function(responses) { 113 | $scope.myProfile = responses[0].result; 114 | $scope.myAvatar = genAvatar($scope.myProfile.picturePath);; 115 | 116 | $scope.buddies = responses[1].result.sort(function(a, b) {return a.mid - b.mid}); 117 | $scope.chatFrameStatus = 'unselect_buddy'; 118 | }); 119 | } 120 | ]) 121 | 122 | .controller('chatCtrl', ['$scope', 'chatService', 123 | 124 | function ($scope, chatService) { 125 | $scope.model = { 126 | message: '' 127 | }; 128 | 129 | $scope.isMyMessage = function(message) { 130 | return message.from == $scope.myProfile.mid; 131 | }; 132 | 133 | $scope.sendMessage = function() { 134 | var new_message; 135 | 136 | if ($scope.model.message.length > 0 && $scope.buddyProfile) { 137 | chatService.sendMessage({ 138 | id: $scope.buddyProfile.mid, 139 | message: $scope.model.message 140 | }); 141 | 142 | new_message = { 143 | contentType: 0, 144 | createdTime: new Date(), 145 | from: $scope.myProfile.mid, 146 | to: $scope.buddyProfile.mid, 147 | text: $scope.model.message 148 | }; 149 | $scope.messages.push(new_message); 150 | 151 | $scope.model.message = ''; 152 | } 153 | }; 154 | 155 | $scope.inputKeypress = function($event) { 156 | if ($event.keyCode == 13) { 157 | $scope.sendMessage(); 158 | } 159 | }; 160 | 161 | chatService.polling(function(response) { 162 | var operations = response.result, 163 | message; 164 | 165 | for (var i = 0; i < operations.length; i++) { 166 | if (operations[i].revision > $scope.revision) { 167 | message = operations[i].message; 168 | if (message && $scope.buddyProfile 169 | && ($scope.buddyProfile.mid == message.from 170 | /* || $scope.buddyProfile.mid == message.to*/)) { 171 | 172 | $scope.messages.push(message); 173 | } 174 | 175 | $scope.updateRevision(operations[i].revision); 176 | } 177 | } 178 | }); 179 | } 180 | ]); 181 | 182 | })(); 183 | -------------------------------------------------------------------------------- /public/js/services/chat_service.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | angular.module('webLineApp') 3 | 4 | .service('chatService', ['$q', 'socket', 5 | 6 | function chatService($q, socket){ 7 | 8 | this.getRecentMessages = function(id) { 9 | return this._generate_method('getRecentMessages', {id: id, size: 20}); 10 | }; 11 | 12 | this.getProfile = function() { 13 | return this._generate_method('getProfile'); 14 | }; 15 | 16 | this.getContacts = function() { 17 | return this._generate_method('getContacts'); 18 | }; 19 | 20 | this.sendMessage = function(message) { 21 | return this._generate_method('sendMessage', message); 22 | }; 23 | 24 | this.polling = function(_callback) { 25 | socket.on('polling', _callback); 26 | }; 27 | 28 | 29 | this._generate_method = function(method, option) { 30 | var deferred = $q.defer(); 31 | 32 | if (option) 33 | socket.emit(method, option); 34 | else 35 | socket.emit(method); 36 | 37 | socket.on(method + '_response', function(response) { 38 | socket.removeAllListeners([method + '_response']); 39 | 40 | if (!response.err) { 41 | deferred.resolve(response); 42 | } else { 43 | deferred.reject(response); 44 | } 45 | }); 46 | 47 | return deferred.promise; 48 | } 49 | } 50 | ]); 51 | 52 | })(); 53 | -------------------------------------------------------------------------------- /public/js/services/login_service.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | angular.module('webLineApp') 3 | 4 | .service('loginService', ['$q', 'socket', 5 | 6 | function loginService($q, socket){ 7 | 8 | this.login = function(user) { 9 | var deferred = $q.defer(); 10 | 11 | socket.emit('login', user); 12 | 13 | socket.on('login_waiting', function(response) { 14 | socket.removeAllListeners(['login_waiting']); 15 | 16 | deferred.notify(response); 17 | }); 18 | 19 | socket.on('login_success', function(response) { 20 | socket.removeAllListeners(['login_success', 'login_error', 'login_waiting']); 21 | 22 | deferred.resolve(response); 23 | }); 24 | 25 | socket.on('login_error', function(response) { 26 | socket.removeAllListeners(['login_error', 'login_success', 'login_waiting']); 27 | 28 | deferred.reject(response); 29 | }); 30 | 31 | return deferred.promise; 32 | }; 33 | } 34 | ]); 35 | 36 | })(); 37 | -------------------------------------------------------------------------------- /routes/index.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | var md5 = require('MD5'); 4 | var SocketClient = require('../lib/socket_client'); 5 | 6 | /* GET home page. */ 7 | 8 | router.get('/', function(req, res) { 9 | var time_seed = new Date(), 10 | channel_name = md5(time_seed), 11 | port = req.app.settings.port, 12 | host = req.protocol + '://' + req.host + ( port != 3000 ? '' : ':' + port ); 13 | 14 | // Create socket client for LineClient 15 | var socket_client = new SocketClient(channel_name); 16 | 17 | res.render('index', { 18 | host: host, 19 | channel_name: channel_name 20 | }); 21 | }); 22 | 23 | module.exports = router; 24 | -------------------------------------------------------------------------------- /views/error.ejs: -------------------------------------------------------------------------------- 1 | <% include header %> 2 | 3 | <%- message %> 4 | <%- error.status %> 5 | <%- error.stack %> 6 | 7 | <% include footer %> 8 | -------------------------------------------------------------------------------- /views/footer.ejs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /views/header.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Web LINE 7 | 8 | 9 | 10 | 11 | 12 | <% if (ENV_DEVELOPMENT) { %> 13 | 14 | <% } %> 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /views/index.ejs: -------------------------------------------------------------------------------- 1 | <% include header %> 2 | 3 | <% include partial/main %> 4 | 5 | <% include footer %> 6 | -------------------------------------------------------------------------------- /views/partial/chat.ejs: -------------------------------------------------------------------------------- 1 |
2 |

登入成功,載入中...

3 |
4 | 5 |
6 |
7 |
8 |

9 | 請選擇一位對象開始聊天

10 |

11 | 載入最近對話...

12 | 13 |
14 | 16 | 17 |
18 |
19 | 頭像 20 | 頭像 21 | 22 |
24 | 25 |
26 | {{ message.text }} 27 | 照片 28 | 影片 29 | 貼圖 30 | 例外媒體內容 31 |
32 |
33 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | 43 | 52 |
53 |
54 | 55 |
56 |
57 |
58 | 59 | 60 |
61 | 81 |
82 |
83 | -------------------------------------------------------------------------------- /views/partial/login.ejs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | 6 | 7 |
8 |
9 |
10 |
11 | 12 | 13 |
14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 |
22 | 23 |
24 |
25 |
26 | 27 | 等待輸入手機驗證碼: 28 | 29 | 30 |
31 |
32 |
33 |
34 |

登入成功

35 |
36 |
37 |
38 |

登入錯誤

39 |

Reason: {{ loginError.reason }}

40 |
41 |
42 |
43 |
44 |
45 | 46 |
47 | 48 |
49 |
50 |

說明

51 |
52 |
53 |

登入步驟:

54 |
    55 |
  1. 以帳號密碼登入
  2. 56 |
  3. 輸入驗證碼至手機
  4. 57 |
  5. 登入完成
  6. 58 |
59 |
60 |
61 |
62 | -------------------------------------------------------------------------------- /views/partial/main.ejs: -------------------------------------------------------------------------------- 1 |
2 |
4 | <% include login %> 5 |
6 | 7 |
9 | <% include chat %> 10 |
11 |
12 | 13 | Fork me on GitHub 14 | --------------------------------------------------------------------------------