本文整理匯總了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)),
);
});
}