forked from centrifugal/centrifuge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannel.go
76 lines (63 loc) · 3.81 KB
/
channel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package centrifuge
// ChannelNamespace allows to create channels with different channel options.
type ChannelNamespace struct {
// Name is a unique namespace name.
Name string `json:"name"`
// Options for namespace determine channel options for channels
// belonging to this namespace.
ChannelOptions `mapstructure:",squash"`
}
// ChannelOptions represent channel specific configuration for namespace
// or global channel options if set on top level of configuration.
type ChannelOptions struct {
// ServerSide marks all channels in namespace as server side, when on then
// all client subscribe requests to these channels will be rejected with
// PermissionDenied error.
ServerSide bool `mapstructure:"server_side" json:"server_side"`
// Publish enables possibility for clients to publish messages into channels.
// Once enabled client can publish into channel and that publication will be
// broadcasted to all current channel subscribers. You can control publishing
// on server-side setting On().Publish callback to client connection.
Publish bool `json:"publish"`
// SubscribeToPublish turns on an automatic check that client subscribed
// on channel before allow it to publish into that channel.
SubscribeToPublish bool `mapstructure:"subscribe_to_publish" json:"subscribe_to_publish"`
// Anonymous enables anonymous access (with empty user ID) to channel.
// In most situations your application works with authenticated users so
// every user has its own unique user ID. But if you provide real-time
// features for public access you may need unauthenticated access to channels.
// Turn on this option and use empty string as user ID.
Anonymous bool `json:"anonymous"`
// JoinLeave turns on join/leave messages for channels.
// When client subscribes on channel join message sent to all
// clients in this channel. When client leaves channel (unsubscribes)
// leave message sent. This option does not fit well for channels with
// many subscribers because every subscribe/unsubscribe event results
// into join/leave event broadcast to all other active subscribers.
JoinLeave bool `mapstructure:"join_leave" json:"join_leave"`
// Presence turns on presence information for channels.
// Presence is a structure with clients currently subscribed on channel.
Presence bool `json:"presence"`
// PresenceDisableForClient prevents presence to be asked by clients.
// In this case it's available only over server-side presence call.
PresenceDisableForClient bool `mapstructure:"presence_disable_for_client" json:"presence_disable_for_client"`
// HistorySize determines max amount of history messages for channel,
// 0 means no history for channel. Centrifugo history has auxiliary
// role – it can not replace your backend persistent storage.
HistorySize int `mapstructure:"history_size" json:"history_size"`
// HistoryLifetime determines time in seconds until expiration for
// history messages. As Centrifuge-based server keeps history in memory
// (for example in process memory or in Redis process memory) it's
// important to remove old messages to prevent infinite memory grows.
HistoryLifetime int `mapstructure:"history_lifetime" json:"history_lifetime"`
// Recover enables recover mechanism for channels. This means that
// server will try to recover missed messages for resubscribing
// client. This option uses publications from history and must be used
// with reasonable HistorySize and HistoryLifetime configuration.
HistoryRecover bool `mapstructure:"history_recover" json:"history_recover"`
// HistoryDisableForClient prevents history to be asked by clients.
// In this case it's available only over server-side history call.
// History recover mechanism if enabled will continue to work for
// clients anyway.
HistoryDisableForClient bool `mapstructure:"history_disable_for_client" json:"history_disable_for_client"`
}