Documentation
¶
Index ¶
- Constants
- type Event
- type EventRead
- type ListenerFunc
- type Server
- func (s *Server) AddListener(eventType string, l ListenerFunc)
- func (s *Server) Close()
- func (s *Server) Init(addr string) (err error)
- func (s *Server) Listen() (err error)
- func (s *Server) ListenAndRead()
- func (s *Server) Read() error
- func (s *Server) SetListener(eventType string, l ListenerFunc)
- func (s *Server) Write(eventName string, payload interface{}, addr *net.UDPAddr) (err error)
Constants ¶
View Source
const ( EventNameStart = "astiudp.start" EventNameDisconnect = "astiudp.disconnect" )
Event names
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { Name string `json:"name"` Payload interface{} `json:"payload"` }
Event represents an event sent between a client and a server
type EventRead ¶
type EventRead struct { Event Payload json.RawMessage `json:"payload"` }
EventRead overrides Event to allows proper unmarshaling of the payload
type ListenerFunc ¶
type ListenerFunc func(s *Server, eventName string, payload json.RawMessage, addr *net.UDPAddr) error
ListenerFunc represents the listener func
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents an UDP server
func (*Server) AddListener ¶
func (s *Server) AddListener(eventType string, l ListenerFunc)
AddListener adds a listener
func (*Server) ListenAndRead ¶
func (s *Server) ListenAndRead()
ListenAndRead listens and reads from the server
func (*Server) SetListener ¶
func (s *Server) SetListener(eventType string, l ListenerFunc)
SetListener sets a listener
Click to show internal directories.
Click to hide internal directories.