當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript nextgen-events.Proxy類代碼示例

本文整理匯總了TypeScript中nextgen-events.Proxy的典型用法代碼示例。如果您正苦於以下問題:TypeScript Proxy類的具體用法?TypeScript Proxy怎麽用?TypeScript Proxy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Proxy類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: connection

emitter.on('connection', function connection(ws: any) {
    // Create a proxy for this client
    const proxy = new NgEmitter.Proxy();

    // Add the local service exposed to this client and grant it all right
    proxy.addLocalService('heartBeatService', heartBeatEmitter, {
        listen: true,
        emit: true,
        ack: true,
    });

    // message received: just hook to proxy.receive()
    ws.on('message', function incoming(message: any) {
        proxy.receive(message);
    });

    // Define the receive method: should call proxy.push()
    // after decoding the raw message
    proxy.receive = function receive(raw: any) {
        try {
            proxy.push(JSON.parse(raw));
        } catch (error) {}
    };

    // Define the send method
    proxy.send = function send(message: any) {
        ws.send(JSON.stringify(message));
    };

    // Clean up after everything is done
    ws.on('close', function close() {
        proxy.destroy();
    });
});
開發者ID:CNBoland,項目名稱:DefinitelyTyped,代碼行數:34,代碼來源:nextgen-events-tests.ts

示例2: open

ws.on('open', function open() {
    // Add the remote service we want to access
    proxy.addRemoteService('heartBeatService');

    // Listen to the event 'heartBeat' on this service
    proxy.remoteServices.heartBeatService.on('heartBeat', (beat: any) => {});
});
開發者ID:CNBoland,項目名稱:DefinitelyTyped,代碼行數:7,代碼來源:nextgen-events-tests.ts

示例3: close

ws.on('close', function close() {
    proxy.destroy();
});
開發者ID:CNBoland,項目名稱:DefinitelyTyped,代碼行數:3,代碼來源:nextgen-events-tests.ts

示例4: receive

proxy.receive = function receive(raw: any) {
    try {
        proxy.push(JSON.parse(raw));
    } catch (error) {}
};
開發者ID:CNBoland,項目名稱:DefinitelyTyped,代碼行數:5,代碼來源:nextgen-events-tests.ts

示例5:

ws.on('message', (message: any) => {
    proxy.receive(message);
});
開發者ID:CNBoland,項目名稱:DefinitelyTyped,代碼行數:3,代碼來源:nextgen-events-tests.ts

示例6: incoming

 ws.on('message', function incoming(message: any) {
     proxy.receive(message);
 });
開發者ID:CNBoland,項目名稱:DefinitelyTyped,代碼行數:3,代碼來源:nextgen-events-tests.ts


注:本文中的nextgen-events.Proxy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。