Documentation
¶
Index ¶
- Variables
- type Client
- type Server
- func (s *Server) Clients() []string
- func (s *Server) HistoryOfReceive() []TextMessage
- func (s *Server) HistoryOfSend() []TextMessage
- func (s *Server) Port() int
- func (s *Server) Run(stop chan struct{})
- func (s *Server) SendText(remoteAddr string, msg string) error
- func (s *Server) SendTextToAllConnection(msg string) error
- func (s *Server) ServerPath() string
- func (s *Server) URL() string
- type ServerType
- type TextMessage
Constants ¶
This section is empty.
Variables ¶
var ServerTypeEnum = []string{"normal", "echo"}
ServerTypeEnum the type of websocket server
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client websocket client
func NewWsClient ¶
NewWsClient the websocket client constructor
func (*Client) CloseConnection ¶
CloseConnection close the websocket connection
func (*Client) HandlerTextReceive ¶
func (c *Client) HandlerTextReceive()
HandlerTextReceive handler the text message from websocket server to print on cli
func (*Client) HistoryOfReceive ¶
func (c *Client) HistoryOfReceive() []TextMessage
HistoryOfReceive the history of the received messages
func (*Client) HistoryOfSend ¶
func (c *Client) HistoryOfSend() []TextMessage
HistoryOfSend the history of the send messages
func (*Client) ServerPath ¶
ServerPath return server path which is the client to connection
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server websocket socket server
func NewWsServer ¶
NewWsServer the constructor of Server
func (*Server) HistoryOfReceive ¶
func (s *Server) HistoryOfReceive() []TextMessage
HistoryOfReceive the history of the received messages
func (*Server) HistoryOfSend ¶
func (s *Server) HistoryOfSend() []TextMessage
HistoryOfSend the history of the send messages
func (*Server) SendTextToAllConnection ¶
SendTextToAllConnection send text message to all connection
type ServerType ¶
type ServerType int
ServerType the type of websocket server
const ( // Normal normal websocket server Normal ServerType = iota // Echo echo server Echo )
func (ServerType) ToString ¶
func (st ServerType) ToString() string
ToString return the type of websocket server
type TextMessage ¶
type TextMessage struct {
// contains filtered or unexported fields
}
TextMessage the text-message object
func NewReceiveMessage ¶
func NewReceiveMessage(conn *websocket.Conn, msg string) TextMessage
NewReceiveMessage TextMessage constructor for receive message
func NewSendMessage ¶
func NewSendMessage(conn *websocket.Conn, msg string) TextMessage
NewSendMessage TextMessage constructor for send message
func (TextMessage) Message ¶
func (h TextMessage) Message() string
Message return the context of message
func (TextMessage) SourceAddress ¶
func (h TextMessage) SourceAddress() string
SourceAddress return the source address of message
func (TextMessage) TargetAddress ¶
func (h TextMessage) TargetAddress() string
TargetAddress return the target address of message
func (TextMessage) TimeString ¶
func (h TextMessage) TimeString() string
TimeString return the time of message
func (TextMessage) ToString ¶
func (h TextMessage) ToString() string
ToString return the message info