Documentation ¶
Index ¶
Constants ¶
const ( VERSION = "1.0" MINIMUM_VERSION = "1.0" DEFAULT_INTERVAL = 0 )
const MAILBOX_SIZE = 1000
The unsent messages are kept temporarily in a mailbox. But only last MAILBOX_SIZE messages are kept.
const MAX_ID_GEN_RETRY = 100
Maximum number of retry to avoid conflict
const MAX_ID_KEPT_TIME = 30 * time.Minute
Maximum time to keep IDs from being auto-released
const MAX_SESSION_IDEL time.Duration = 1 * time.Minute
Maximum allowed session idel. After that, the session is considered as disconnected.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broker ¶
A simple Message Broker that transmits text messages between clients through subscribed channels.
type EventMessage ¶
type Instance ¶
type Instance struct { *Server // contains filtered or unexported fields }
func (*Instance) AddService ¶
func (c *Instance) AddService(channel string, handler func(session *Session, message *MetaMessage)) *Instance
Add new handler to listen and process messages sent to /service/** channel. It doesn't check for conflict and will override existing one with the same name. The returned Instance object allows flow style configuration.
type LongPolling ¶
type LongPolling struct { }
From [The Bayeux Protocol](http://cometd.org/documentation/bayeux/spec):
"Long-polling" is a poolling transport that attempts to minimize both latency in sever-client message delivery, and the processing/network resources required for the cnnection.
type MetaMessage ¶
type MetaMessage struct { Channel string `json:"channel"` Version string `json:"version,omitempty"` MinimumVersion string `json:"minimumVersion,omitempty"` SupportedConnectionTypes []string `json:"supportedConnectionTypes,omitempty"` ClientId string `json:"clientId,omitempty"` Advice *Advice `json:"advice,omitempty"` ConnectionType string `json:"connectionType,omitempty"` Id string `json:"id,omitempty"` Timestamp string `json:"timestamp,omitempty"` Data json.RawMessage `json:"data,omitempty"` Successful bool `json:"successful"` Subscription string `json:"subscription,omitempty"` Error string `json:"error,omitempty"` Extension interface{} `json:"ext,omitempty"` }
func (*MetaMessage) String ¶
func (mm *MetaMessage) String() string
type Router ¶
A simple router that accepts mutiple matching rules, responds to path query, and returns the matching client IDs.
Internally, it uses a Trie to do path matching. Adding or removing rule will change the internal Trie structure. The lookup efficiency is proportional to the approximte number of path segments.
Note: it's thread-safe and can be shared in different goroutines.
type Server ¶
The Bayeux protocol implementation V1.0.
A common scenario is that, the client should handshake the server first, to determine which version of the protocol is used. It doesn't have any transport related fields or logic either becuase they should be already taken care of before it's used.
type Session ¶
type Session struct { ID string // contains filtered or unexported fields }
func (*Session) ListenOnRemoval ¶
Attach a listener for session destroy event.