Documentation ¶
Overview ¶
Protocol layer used for client and server connection handling.
Index ¶
Constants ¶
View Source
const ( MODE_CLIENT = iota // Client mode MODE_SERVER = iota // Server mode )
View Source
const ( PROTO_IDENT_REQUEST = 0x01 // Identification request PROTO_IDENT_RESPONSE = 0X01 // Identification response PROTO_CLIENT_PING = 0x02 // Ping request (client to server) PROTO_SERVER_PONG = 0x02 // Pong request (server to client) PROTO_SERVER_PING = 0x03 // Ping request (server to client) PROTO_CLIENT_PONG = 0x03 // Pong request (client to server) PROTO_DATA_SIMPLE_1B = 0x21 PROTO_DATA_SIMPLE_2B = 0x41 PROTO_DATA_SIMPLE_4B = 0x61 PROTO_DATA_ARRAY_1B = 0x22 PROTO_DATA_ARRAY_2B = 0x42 PROTO_DATA_ARRAY_4B = 0x62 PROTO_MAX_SIZE_1B = 254 // 255 - 1 (for channel) PROTO_MAX_SIZE_2B = 65534 // 64K - 1 (for channel) PROTO_MAX_SIZE_4B = 1048576 // 1MB (we don't want to send more than 1MB at this stage) )
View Source
const (
BUFFER_SIZE = 1024 // Buffer size
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MessageDataArray ¶
Array of data message
func NewMessageDataArray ¶
func NewMessageDataArray(channel string) *MessageDataArray
func (*MessageDataArray) Add ¶
func (msg *MessageDataArray) Add(data []byte)
func (*MessageDataArray) AddString ¶
func (msg *MessageDataArray) AddString(data string)
type MessageDataSimple ¶
Simple message
type MessageIdentRequest ¶
type MessageIdentRequest struct {
Ident string
}
type MessageIdentResponse ¶
type MessageIdentResponse struct {
Ok bool
}
type ProtoHandler ¶
type ProtoHandler struct { Conn net.Conn // Logging is done on a connection basis to be to focus on some connections LogLevel int // contains filtered or unexported fields }
func NewProtoHandlerClient ¶
func NewProtoHandlerClient(c net.Conn) (pt *ProtoHandler)
Create a new protocol handler in client mode This is used to initiate a connection.
func NewProtoHandlerServer ¶
func NewProtoHandlerServer(c net.Conn) (pt *ProtoHandler)
Create a new protocol handler in server mode This is used to handle an incoming connection.
func (*ProtoHandler) Recv ¶
func (pt *ProtoHandler) Recv() interface{}
func (*ProtoHandler) Send ¶
func (pt *ProtoHandler) Send(msg interface{}) error
func (*ProtoHandler) String ¶
func (pt *ProtoHandler) String() string
Click to show internal directories.
Click to hide internal directories.