@miaozo/sync-response
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published
const cfg = require('config');
let request_channel = Date.now().toString() + '_req';
let response_channel = Date.now().toString() + '_resp';
let client = new SyncResponseClient(request_channel,
    response_channel,
    cfg.get('sync_response_client.redis'),
    async (channel, message) => {
        let reqMsg = RequestMessage.fromMessageString(message);
        await client.publish(response_channel, 
            new ResponseMessage(reqMsg.requestId, 
            JSON.stringify({code: 0, message: Date.now().toString(16)})).toMessageString());
    });
client.resp(
    new RequestMessage('861111111000001' + Date.now().toString(),
        JSON.stringify({
            a: 1,
            b: Buffer.from('hello').toString('hex')})), 1000)
    .then((respMsg) => {
        console.log(respMsg);
    });

/@miaozo/sync-response/

    Package Sidebar

    Install

    npm i @miaozo/sync-response

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    14 kB

    Total Files

    13

    Last publish

    Collaborators

    • mattf25