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


TypeScript AuthorizedRestApi.connectOptionsToAccess方法代碼示例

本文整理匯總了TypeScript中rcf.AuthorizedRestApi.connectOptionsToAccess方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript AuthorizedRestApi.connectOptionsToAccess方法的具體用法?TypeScript AuthorizedRestApi.connectOptionsToAccess怎麽用?TypeScript AuthorizedRestApi.connectOptionsToAccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rcf.AuthorizedRestApi的用法示例。


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

示例1: getDefaultNodeName

            if (address.family === 'IPv4' && !address.internal) {
                ipv4Addresses.push(address.address);
            }
        }
    }
    if (ipv4Addresses.length > 0) {
        return ipv4Addresses[0];
    } else {	// no IPv4 address
        return '{?}';
    }
}

let dispatcherConfig = config.dispatcherConfig;

let pathname = '/node-app/events/event_stream';
let api = new rcf.AuthorizedRestApi($node.get(), rcf.AuthorizedRestApi.connectOptionsToAccess(dispatcherConfig));
let clientOptions: rcf.IMessageClientOptions = {reconnetIntervalMS: 10000};

let cpus = os.cpus();
let numCPUs:number = (config.numCPUs ? config.numCPUs : cpus.length - (config.reservedCPUs ? config.reservedCPUs : 2));
numCPUs = Math.max(numCPUs, 1);
let nodeName:string = (config.nodeName ? config.nodeName : getDefaultNodeName());
console.log(new Date().toISOString() + ': nodeName=' + nodeName + ', cpus=' + cpus.length + ', numCPUs=' + numCPUs);

let tasksTracker = new TasksTracker();

interface ITaskExec {
    run(task: ITask) : Promise<void>;
    on(event: "error", listener: (err: any) => void) : this;
    on(event: "exec-params", listener: (taskExecParams: ITaskExecParams) => void) : this;
    on(event: "started", listener: (pid: number) => void) : this;
開發者ID:wchang28,項目名稱:node-grid-2,代碼行數:31,代碼來源:launcherApp.ts

示例2: Date

import * as rcf from 'rcf';
import * as $node from 'rest-node';
import * as fs from 'fs';
import * as path from 'path';

let configFile = (process.argv.length < 3 ? path.join(__dirname, '../client_test_config.json') : process.argv[2]);
let connectOptions: rcf.ApiInstanceConnectOptions = JSON.parse(fs.readFileSync(configFile, 'utf8'));

let pathname = '/services/events/event_stream';

let api = new rcf.AuthorizedRestApi($node.get(), rcf.AuthorizedRestApi.connectOptionsToAccess(connectOptions));
let clientOptions: rcf.IMessageClientOptions = {reconnetIntervalMS: 3000};
let client = api.$M(pathname, clientOptions);

client.on('connect', (conn_id:string) => {
    console.log('');
    console.log('connected: conn_id=' + conn_id);
    console.log('');
    //let topic = '/topic/'+conn_id;
    let topic = '/topic/say_hi';
    client.subscribe(topic
    , (msg: rcf.IMessage): void => {
        console.log('msg-rcvd:');
        console.log('===============================================');
        console.log(JSON.stringify(msg, null, 2));
        console.log('===============================================');
    }, {"selector": "location = 'USA'"}
    ).then((sub_id: string) => {
        console.log('topic subscribed sub_id=' + sub_id + " :-)");
        console.log('sending a test message...');  
        return client.send(topic, {'location': 'USA'}, {'greeting':'good afternoon ' + new Date()});     
開發者ID:wchang28,項目名稱:topic-eventsource,代碼行數:31,代碼來源:clientTest.ts

示例3:

import * as $node from 'rest-node';
import * as FormData from 'form-data';
import * as rcf from 'rcf';
import * as fs from 'fs';
import * as path from 'path';

let configFile = (process.argv.length < 3 ? path.join(__dirname, '../client_test_config.json') : process.argv[2]);
let connectOptions: rcf.ApiInstanceConnectOptions = JSON.parse(fs.readFileSync(configFile, 'utf8'));

let $driver = $node.get();
let api = new rcf.AuthorizedRestApi($driver, rcf.AuthorizedRestApi.connectOptionsToAccess(connectOptions));

//let form = new FormData();
let form: FormData = $driver.createFormData();
form.append('FirstName', 'Wen');
form.append('LastName', 'Chang');
form.append("Myfile[]", fs.createReadStream('C:/tmp/signedcorrected 4506-T.pdf'), 'signedcorrected 4506-T.pdf');
form.append("Myfile[]", fs.createReadStream('C:/tmp/polaris.txt'), 'polaris.txt');

api.$F("POST", '/services/upload/file_upload', form)
.then((ret: rcf.RESTReturn) => {
    console.log(JSON.stringify(ret, null, 2));
}).catch((err: any) => {
    console.error("!!! Error: " + JSON.stringify(err));
});

api.$F("POST", '/services/upload/s3_upload', form)
.then((ret: rcf.RESTReturn) => {
    console.log(JSON.stringify(ret, null, 2));
}).catch((err: any) => {
    console.error("!!! Error: " + JSON.stringify(err));
開發者ID:wchang28,項目名稱:topic-eventsource,代碼行數:31,代碼來源:test.ts


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