Using Channels
Learn how to effectively use channels in your QPub applications.
Overview
Channels are the primary way to organize and route messages in QPub. This guide covers best practices for using channels effectively.
Channel Types
Public Channels
// Create a public channel
const publicChannel = await client.createChannel({
name: 'general-chat',
type: 'public',
description: 'General discussion channel'
});Private Channels
// Create a private channel
const privateChannel = await client.createChannel({
name: 'team-dashboard',
type: 'private',
permissions: ['team-member']
});Presence Channels
// Create a presence channel
const presenceChannel = await client.createChannel({
name: 'online-users',
type: 'presence',
trackPresence: true
});Channel Naming Conventions
Recommended Patterns
- Use descriptive names:
user-notifications,order-updates - Use hierarchical naming:
app.feature.subfeature - Include environment prefixes:
prod.user-chat,dev.test-channel
Examples
// Good channel names
'user-123-notifications'
'chat-room-general'
'order-processing-updates'
'analytics-page-views'
// Avoid generic names
'channel1'
'test'
'data'Channel Configuration
Basic Configuration
const channel = await client.createChannel({
name: 'my-channel',
description: 'Channel description',
type: 'public',
maxSubscribers: 1000,
messageRetention: 7 // days
});Advanced Configuration
const channel = await client.createChannel({
name: 'secure-channel',
type: 'private',
permissions: ['admin', 'moderator'],
encryption: true,
auditLog: true,
rateLimiting: {
messagesPerMinute: 100,
subscribersPerSecond: 10
}
});Best Practices
- Use meaningful names that describe the channel's purpose
- Limit channel scope to specific features or user groups
- Implement proper permissions for sensitive channels
- Monitor channel usage to optimize performance
- Clean up unused channels to reduce clutter
This page is under construction. Channel usage documentation will be expanded soon.
Previous
Overview
Next
Channel Lifecycle