当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ServerApp.on方法代码示例

本文整理汇总了TypeScript中@feathersjs/feathers.ServerApp.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ServerApp.on方法的具体用法?TypeScript ServerApp.on怎么用?TypeScript ServerApp.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@feathersjs/feathers.ServerApp的用法示例。


在下文中一共展示了ServerApp.on方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: configureChannels

function configureChannels(app: ServerApp) {
  app.on('connection', (connection) => {
    app.channel('anonymous').join(connection);

    app.channel('all').join(connection);

    app.channel('region:eu').join(connection);

  });

  app.on('login', (_, { connection }) => {
    if (connection) {
      app.channel('anonymous').leave(connection);

      app.channel('authenticated').join(connection);

      app.channel(`region:${connection.user.region}`).join(connection);
    }
  });

  app.on('logout', (_, { connection }) => {
    app.channel('authenticated').leave(connection);

    app.channel('anonymous').join(connection);
  });
}
开发者ID:TF2PickupNET,项目名称:TF2Pickup,代码行数:26,代码来源:configure-channels.ts

示例2: events

export default function events(app: ServerApp) {
  log('Setting up events for the user-settings service');

  app.on('socket-connection', (socket) => {
    socket.on('user-settings:change-volume', onChangeVolume(app, socket));

    socket.on('user-settings:change-emoji-set', onChangeEmojiSet(app, socket));

    socket.on('user-settings:change-announcer', onChangeAnnouncer(app, socket));
  });
}
开发者ID:TF2PickupNET,项目名称:TF2Pickup,代码行数:11,代码来源:index.ts

示例3: events

export default function events(app: ServerApp) {
  log('Setting up events for the users service');

  app.on('login', onLogin(app));

  app.on('logout', onLogout(app));

  app.on('socket-connection', (socket) => {
    socket.on('users:change-region', onChangeRegion(app, socket));

    socket.on('users:accept-rules', onAcceptRules(app, socket));

    socket.on('users:set-name', onSetName(app, socket));

    socket.on('users:add-role', onAddRole(app, socket));

    socket.on('users:remove-role', onRemoveRole(app, socket));

    socket.on('users:complete-sign-up', onCompleteSignUp(app, socket));
  });
}
开发者ID:TF2PickupNET,项目名称:TF2Pickup,代码行数:21,代码来源:index.ts

示例4: events

export default function events(app: ServerApp) {
  log('Setting up events for the pickup-queues service');

  app.on('socket-connection', (socket) => {
    socket.on('queues:join', onJoin(app, socket));

    socket.on('queues:leave', onLeave(app, socket));

    socket.on('queues:ready-up', onReadyUp(app, socket));

    socket.on('queues:select-map', onSelectMap(app, socket));
  });
}
开发者ID:TF2PickupNET,项目名称:TF2Pickup,代码行数:13,代码来源:index.ts

示例5: setupEvents

export default function setupEvents(app: ServerApp) {
  app.on('login', async (_, { connection }) => {
    const userId = connection.user.id;

    try {
      const profile = await app.service('user-profiles').get(userId);
      const data = await getUserData(profile);

      await app.service('user-profiles').patch(userId, data);
    } catch (error) {
      log('Error in login callback', error);
    }
  });
}
开发者ID:TF2PickupNET,项目名称:TF2Pickup,代码行数:14,代码来源:setup-events.ts

示例6: configureDebug

export default function configureDebug(app: ServerApp) {
  // We need this to catch the logs which were emitted before the server was ready
  debug.log = createLogger((log) => {
    logs.push(log);
  });


  app.on('listening', async () => {
    debug.log = createLogger((log) => {
      app.service('logs').create(log);
    });

    const service = app.service('logs');

    await Promise.all(
      logs.map(log => service.create(log)),
    );
  });
}
开发者ID:TF2PickupNET,项目名称:TF2Pickup,代码行数:19,代码来源:configure-debug.ts


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