成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

amiaodaifu.com

fuchenxuan / 2405人閱讀

const http  = require("http");
const fs    = require("fs");
const events= require("events");

function post(path, json, cb) {
    let options = {
        host: "hr.amiaodaifu.com",
        port: 50000,
        path: `/1610/${path}`,
        method: "GET"
    };
    let content = undefined;
    if(json!==null) {
        content = new Buffer(JSON.stringify(json));
        options.method = "POST";
        options.headers = {
            "Content-Type": "application/json; charset=utf-8",
            "Content-Length": content.length
        };
    }

    let req = http.request(options, function(res) {
        let content = "";
        res.on("data", (data) => content += data);
        res.on("end", () => cb(
            res.statusCode===200 ? JSON.parse(content) : null
        ));
    });
    req.on("error", (e) => cb(null));
    req.end(content);
}

function _new(cb) {
    post("new-question", {mail: "[email protected]"}, cb);
}

function _get(questionId, id, cb) {
    post(`questions/${questionId}/get-children/${id}`, null, cb);
}

function _check(questionId, json, cb) {
    post(`questions/${questionId}/check`, {root: json}, cb);
}

function _submit(questionId, cb) {
    post(`questions/${questionId}/submit`, {
        name: "amiao",
        forFun: true,
        phone: 01234567890,
        sourceCode: fs.readFileSync(__filename, "utf-8")
    }, cb);
}

class p1610 extends events {
    constructor() {
        super();
        _new((question) => {
            if(question===null) return;
            this.questionId = question.id;
            this.root = {id: question.rootId, children: []};
            this.queue = [this.root];
            this.tasks = 0;
            this.emit("get");
        });
    }
    run(father) {
        _get(this.questionId, father.id, (childrenId) => {
            if(childrenId===null)
                this.queue.push(father);
            else
                for(let i=0; i {
            if(judge===null) return;
            if(judge.pass) this.emit("submit");
            console.log(judge);
        });
    }
    submit() {
        _submit(this.questionId, (message) => console.log(message));
    }
}

let p = new p1610;
p.on("get", p.get);
p.on("check", p.check);
p.on("submit", p.submit);

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/91103.html

相關(guān)文章

發(fā)表評論

0條評論

fuchenxuan

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<