當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。