Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Remilia - Structure of Huaban Directional Pinni...

Avatar for ZHU, Kaidi ZHU, Kaidi
February 03, 2015

Remilia - Structure of Huaban Directional Pinning System

Avatar for ZHU, Kaidi

ZHU, Kaidi

February 03, 2015
Tweet

More Decks by ZHU, Kaidi

Other Decks in Programming

Transcript

  1. “All the gensokyo characters services are written in Framework Gensokyo.”

    –XadillaX <The Remilia Bible> 1-1-3, Gensokyo Prologue
  2. module.exports = { echo1: [ "before1", "echo2" ], echo2: [

    "before1", [ "echo1", "echo2" ], "after1" ], echo3: "echo1", echo4: { before: [ "before1" ], ctrller: "echo1" } };
  3. function makeSequence(before, controller, after, routerName, keyName) { var sequence =

    []; sequence.add(before); sequence.add(controller); sequence.add(after); var func = function(req, resp, callback) { var funcIdx = 0; var funcCount = sequence.length; app.logger.info("Received a request \"{router}.{action}\".".assign({ router : routerName, action : keyName })); // do the sequence async.whilst( function() { return funcIdx < funcCount; }, function(next) { var func = sequence[funcIdx]; func(req, resp, function() { funcIdx++; next(); }); }, function(err) { if(err) { app.logger.err("An error occurred in `{router}` -> `{action}`: {error}".assign({ router : routerName, action : keyName, error : err.message })); return; } callback(); } ); }; return func; }
  4. var util = require("util"); var Controller = require("gensokyo").Controller; var EchoController

    = function(gensokyo) { Controller.call(this, gensokyo); }; util.inherits(EchoController, Controller); EchoController.prototype.echo1 = function(req, resp, next) { this.logger.info("echo1"); next(); }; EchoController.prototype.echo2 = function(req, resp, next) { this.logger.info("echo2"); resp.message.ok = true; // 测试⼈人品 if(Number.random(1, 100) < 50) { resp.error("You're unlucky!"); return; } next(); }; module.exports = EchoController;
  5. “All ciphertext is from Sanae and into Cellar.” –Kochiya Sanae

    <The Remilia Bible> 5-3-12, Sanae Ciphertext
  6. The Cellar (Ver. 1) Fetch wet data from mongodb stored

    by Sanae regularly Dry the wet data into useful data and store back to another collection
  7. The Cellar (Ver. 2) Wait for Illyria Requests. Get data

    from Sanae’s storage. Response the data.
  8. “Cellar is a raw data fetcher & sender. And the

    Gate is to peep the raw data to fetch dry information.” –Remilia Scarlet <The Remilia Bible> 6-2-13, Gate T estament
  9. “The Gate is a hub between the Cellar and the

    Koumakan. And the peep hole is the core soul of the Gate.” –Remilia Scarlet <The Remilia Bible> 6-2-13, Gate T estament
  10. Gate Wait for peep requests. Peep the raw data from

    the Cellar. Response the peeped data back.
  11. “One peep hole per rule. And one rule per hole.”

    –Puppets <The Remilia Bible> 9-8-1, Puppet Oath
  12. “Of cause, we peep the description of that heavenly image.

    And we peep the kind of it.” –Puppets <The Remilia Bible> 9-8-1, Puppet Oath
  13. “At last, don’t forget to peep the raw board name

    for it.” –Puppets <The Remilia Bible> 9-8-1, Puppet Oath
  14. Koumakan The palace puppets live. The magic controls all the

    puppets. A puppet owns a Huaban account. Each puppet is independent.
  15. “Remilia created a factory to create puppets at the first

    day.” –<The Remilia Bible> 2-1-1, Factday
  16. Puppet Manager The puppet factory var PuppetManager = function() {};

    PuppetManager.prototype.addPuppets = function() {}; PuppetManager.prototype.startOne = function() {}; ……
  17. “At the second day, she gave puppets body, blood and

    soul.” –<The Remilia Bible> 2-1-2, Thouday
  18. Puppets builds with Composition Account Composition Peeped Queue Composition Schedule

    Composition (Pin) Hand Composition Board Composition …
  19. Base Composition var BaseComposition = function(puppetId, parent) { EventEmitter.call(this); this.gensokyo

    = gensokyo; this.logger = gensokyo.logger; this.puppetId = puppetId; this.parent = parent; }; util.inherits(BaseComposition, EventEmitter); module.exports = BaseComposition; BaseComposition.type = "BaseComposition";
  20. So Puppets var Puppet = function(puppetId) { EventEmitter.call(this); this.gensokyo =

    gensokyo; this.logger = gensokyo.logger; this.puppetId = puppetId; // 账号组件 this.account = new Compositions.Account(puppetId, this); // 缓存数据队列 this.peepedQueue = new Compositions.PeepedQueue(puppetId, this); // 时间表 this.schedule = new Compositions.Schedule(puppetId, this); // ⼊入库之⽖爪 this.pinHand = new Compositions.PinHand(puppetId, this); // 魔貫光殺砲 ƅЧƅ)σ━00000000000━• … this.logger.info("Puppet " + puppetId + " created."); };
  21. “Remilia endued puppets the ability to acquire an outside world,

    Huaban at the third day.” –<The Remilia Bible> 2-1-3, Huaday
  22. Account Composition var AccountComposition = function() {}; AccountComposition.prototype.fetchInformation = function()

    {}; AccountComposition.prototype.createAccount = function() {}; AccountComposition.prototype.signIn = function() {}; …
  23. “Puppets got the ability of peeping from Gate at the

    forth day due to Remilia.” –<The Remilia Bible> 2-1-4, Gatday
  24. Peeped Queue Composition var PeepedQueueComposition = function() {}; PeepedQueueComposition.prototype.nextImage =

    function() {}; PeepedQueueComposition.prototype.clean = function() {}; PeepedQueueComposition.prototype.peepCrowd = function() {}; ...
  25. “Sixth day, puppets got the ability to pin to Huaban

    from Remilia.” –<The Remilia Bible> 2-1-6, Pinsday
  26. “The last day, each puppet made its own schedule to

    pin. And Remilia went to rest.” –<The Remilia Bible> 2-1-7, Scheday
  27. “Boom is a Bang to implement interacting with Huaban.” –Remilia

    Scarlet <The Remilia Bible> 17-3-8, Big Boom