• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript butlerd.Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中butlerd.Client的典型用法代码示例。如果您正苦于以下问题:TypeScript Client类的具体用法?TypeScript Client怎么用?TypeScript Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Client类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:HorrerGames,项目名称:itch,代码行数:25,代码来源:setup.ts


示例2: setupLogging

export function setupLogging(client: Client, logger: Logger) {
  client.onWarning(msg => {
    logger.warn(`(butlerd) ${msg}`);
  });

  client.onNotification(messages.Log, ({ params }) => {
    switch (params.level) {
      case "debug":
        logger.debug(params.message);
        break;
      case "info":
        logger.info(params.message);
        break;
      case "warning":
        logger.warn(params.message);
        break;
      case "error":
        logger.error(params.message);
        break;
      default:
        logger.info(`[${params.level}] ${params.message}`);
        break;
    }
  });
}
开发者ID:HorrerGames,项目名称:itch,代码行数:25,代码来源:utils.ts


示例3: async

  sanityCheck: async (ctx, logger, versionPrefix) => {
    const instance = await makeButlerInstance({ ctx, versionPrefix });
    // we're awaiting it later, avoid 'unhandledRejection'
    instance.promise().catch(() => {});

    const client = new Client(await instance.getEndpoint());
    await client.call(messages.VersionGet, {});
  },
开发者ID:itchio,项目名称:itch,代码行数:8,代码来源:formulas.ts


示例4: 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();
   }
 },
开发者ID:HorrerGames,项目名称:itch,代码行数:13,代码来源:formulas.ts


示例5: makeClient

async function makeClient(store: Store, parentLogger: Logger): Promise<Client> {
  const logger = parentLogger.childWithName("butlerd/make-client");

  while (true) {
    const { endpoint } = store.getState().butlerd;
    if (endpoint) {
      const client = new Client(endpoint);
      client.onWarning(msg => {
        logger.warn(`(butlerd) ${msg}`);
      });
      return client;
    }

    logger.info(`Waiting for butlerd endpoint...`);
    await delay(1000);
  }
}
开发者ID:itchio,项目名称:itch,代码行数:17,代码来源:utils.ts


示例6: 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;
}
开发者ID:HorrerGames,项目名称:itch,代码行数:42,代码来源:utils.ts


示例7: setupClient

export function setupClient(
  client: Client,
  parentLogger: Logger,
  ctx: MinimalContext
) {
  client.onNotification(messages.Progress, ({ params }) => {
    ctx.emitProgress(params);
  });

  setupLogging(client, parentLogger);
}
开发者ID:HorrerGames,项目名称:itch,代码行数:11,代码来源:utils.ts


示例8: async

    work: async () => {
      client = new Client(store.getState().butlerd.endpoint);
      await client.connect();
      try {
        setupClient(client, logger, ctx);

        client.on(messages.PickManifestAction, async ({ actions }) => {
          const index = await pickManifestAction(store, actions, game);
          return { index };
        });

        client.on(messages.HTMLLaunch, async params => {
          return await performHTMLLaunch({
            ctx,
            logger,
            game,
            params,
          });
        });

        client.on(messages.ShellLaunch, async ({ itemPath }) => {
          shell.openItem(itemPath);
          return {};
        });

        client.on(messages.URLLaunch, async ({ url }) => {
          store.dispatch(actions.navigate({ window: "root", url }));
          return {};
        });

        client.on(messages.PrereqsStarted, async ({ tasks }) => {
          prereqsStateParams = {
            gameTitle: game.title,
            tasks: {},
          };

          for (const name of Object.keys(tasks)) {
            const task = tasks[name];
            prereqsStateParams.tasks[name] = {
              fullName: task.fullName,
              order: task.order,
              status: PrereqStatus.Pending,
              progress: 0,
              eta: 0,
              bps: 0,
            };
          }

          prereqsModal = modalWidgets.prereqsState.make({
            window: "root",
            title: ["grid.item.installing"],
            message: "",
            widgetParams: prereqsStateParams,
            buttons: [
              {
                id: "modal-cancel",
                label: ["prompt.action.cancel"],
                action: actions.abortTask({ id: ctx.getTaskId() }),
                className: "secondary",
              },
            ],
            unclosable: true,
          });
          store.dispatch(actions.openModal(prereqsModal));
        });

        client.on(
          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 }) => {
//.........这里部分代码省略.........
开发者ID:HorrerGames,项目名称:itch,代码行数:101,代码来源:perform-launch.ts


示例9: cancel

 async cancel() {
   this.setPhase(Phase.CANCELLING);
   await this.client.call(messages.DownloadsDriveCancel, {});
   this.client = null;
 }
开发者ID:HorrerGames,项目名称:itch,代码行数:5,代码来源:driver-persistent-state.ts



注:本文中的butlerd.Client类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript buttplug.ButtplugClient类代码示例发布时间:2022-05-25
下一篇:
TypeScript buster.testCase函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap