本文整理汇总了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);
});
}
示例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));
});
}
示例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));
});
}
示例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));
});
}
示例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);
}
});
}
示例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)),
);
});
}