Documentation
¶
Index ¶
Constants ¶
View Source
const ( HEAD_SIZE = 4 HEADER = "socket-cluster" // The maximum length of each message (including headers), which can be set to 4G MAX_LENGTH = 1024 * 70 )
Variables ¶
View Source
var ExceededErr = errors.New("The maximum length of the packet is exceeded")
View Source
var HeaderErr = errors.New("The message header is incorrect")
Functions ¶
func GenerateTLSConfigForClient ¶
GenerateTLSConfigForClient setup a bare-bones(skip verify) TLS config for client.
func GenerateTLSConfigForServer ¶
GenerateTLSConfigForServer setup a bare-bones TLS config for server.
Types ¶
type Connection ¶
type FlowProtocol ¶
type FlowProtocol struct {
Proto
// contains filtered or unexported fields
}
func NewFlowProtocol ¶
func NewFlowProtocol(header string, bufLength int, conn io.Reader) *FlowProtocol
func (*FlowProtocol) Pack ¶
func (this *FlowProtocol) Pack(data []byte) ([]byte, error)
Pack Package raw data
func (*FlowProtocol) ReadMsg ¶
func (this *FlowProtocol) ReadMsg() ([]byte, error)
Read Read and parse the received message
type Proto ¶
type Proto interface {
// Pack writes the Message into the connection.
// NOTE: Make sure to write only once or there will be package contamination!
Pack([]byte) ([]byte, error)
// Read bytes from the connection.
ReadMsg() ([]byte, error)
}
Proto pack/read protocol scheme of socket message.
type Protocol ¶
type Protocol interface {
// ListenAndServe turns on the listening service.
ListenAndServe(port int64, onConnect func(conn Connection)) error
// Dial connects with the socket of the destination address.
Dial(addr string) (Connection, error)
}
type Session ¶
type Session struct {
Conn Connection
ClientId string
}
func (*Session) CasClientId ¶
CasClientId sets the session uid and return oldClientId
func (*Session) LoadClientId ¶
LoadClientId returns the session uid.
func (*Session) StoreClientId ¶
StoreClientId sets the session uid.
Click to show internal directories.
Click to hide internal directories.