本文整理汇总了TypeScript中butlerd.Client.close方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Client.close方法的具体用法?TypeScript Client.close怎么用?TypeScript Client.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类butlerd.Client
的用法示例。
在下文中一共展示了Client.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: refreshButlerd
async function refreshButlerd(store: IStore) {
logger.info(`Refreshing butlerd! Spinning up new instance...`);
let instance = await makeButlerInstance();
instance.promise().catch(e => {
console.error(`butlerd instance threw:`);
console.error(e.stack);
refreshButlerd(store).catch(() => {});
});
const endpoint = await instance.getEndpoint();
logger.info(`Connecting client...`);
const nextClient = new Client(endpoint);
await nextClient.connect();
if (masterClient) {
// instances exit gracefully when all clients have closed
logger.info(`Closing old master client...`);
masterClient.close();
masterClient = null;
}
masterClient = nextClient;
logger.info(`Got new endpoint`);
store.dispatch(actions.gotButlerdEndpoint({ endpoint }));
initialButlerdResolve();
}
示例2: async
sanityCheck: async (versionPrefix: string) => {
const instance = await makeButlerInstanceWithPrefix(versionPrefix);
// we're awaiting it later, avoid 'unhandledRejection'
instance.promise().catch(() => {});
try {
const client = new Client(await instance.getEndpoint());
await client.connect();
await client.call(messages.VersionGet, {});
client.close();
} finally {
await instance.promise();
}
},
示例3: getRootState
export async function withButlerClient<T>(
parentLogger: Logger,
cb: WithCB<T>
): Promise<T> {
const { endpoint } = getRootState().butlerd;
if (!endpoint) {
throw new Error(`no butlerd endpoint yet`);
}
const client = new Client(endpoint);
await client.connect();
setupLogging(client, parentLogger);
let res: T;
let err: Error;
try {
res = await cb(client);
} catch (e) {
if (getRootState().system.quitting) {
// ignore butlerd error when quitting
} else {
console.error(`Caught butler error:`);
if (isInternalError(e)) {
const ed = getRpcErrorData(e);
if (ed) {
console.error(`butler version: ${ed.butlerVersion}`);
console.error(`Golang stack:\n${ed.stack}`);
}
console.error(`JavaScript stack: ${e.stack}`);
} else {
console.error(`${e.message}`);
}
err = e;
}
} finally {
client.close();
}
if (err) {
throw err;
}
return res;
}
示例4: async
//.........这里部分代码省略.........
messages.PrereqsTaskState,
async ({ name, status, progress, eta, bps }) => {
if (!prereqsModal) {
return;
}
let state = {
...prereqsStateParams.tasks[name],
status,
progress,
eta,
bps,
};
let tasks = {
...prereqsStateParams.tasks,
[name]: state,
};
prereqsStateParams = { ...prereqsStateParams, tasks };
store.dispatch(
actions.updateModalWidgetParams(
modalWidgets.prereqsState.update({
id: prereqsModal.id,
widgetParams: prereqsStateParams,
})
)
);
}
);
client.on(messages.PrereqsFailed, async ({ errorStack, error }) => {
closePrereqsModal();
const { title } = game;
let errorMessage = error;
errorMessage = errorMessage.split("\n")[0];
let log = "(empty)\n";
if (logger.customOut && logger.customOut.toString) {
log = logger.customOut.toString();
}
const res = await promisedModal(
store,
modalWidgets.showError.make({
window: "root",
title: ["game.install.could_not_launch", { title }],
message: [
"game.install.could_not_launch.message",
{ title, errorMessage },
],
detail: ["game.install.could_not_launch.detail"],
widgetParams: {
game,
rawError: { stack: errorStack },
log,
},
buttons: [
{
label: ["prompt.action.continue"],
action: actions.modalResponse({
continue: true,
}),
},