Documentation ¶
Index ¶
- func Encode(packet Packet) []byte
- type Client
- func (c *Client) Close()
- func (c *Client) Connect(addr string) error
- func (c *Client) GetBytesReceivedByEvent() (byEvent map[string]int64)
- func (c *Client) GetBytesSentByEvent() (byEvent map[string]int64)
- func (c *Client) PacketReceived(callback func(packet Packet))
- func (c *Client) WriteMessage(command string, data []byte)
- type Network
- func (n *Network) BroadcastEvent(name string, data []byte)
- func (n *Network) BytesReceived() int64
- func (n *Network) BytesReceivedByCommand() map[string]int64
- func (n *Network) BytesSent() int64
- func (n *Network) BytesSentByCommand() map[string]int64
- func (n *Network) ClientJoinedEvent(fn func(clientId string))
- func (n *Network) ClientToken() string
- func (n *Network) Close()
- func (n *Network) ConnectClient(addr string) error
- func (n *Network) FlushAllWriteBuffers()
- func (n *Network) FlushWriteBuffer(clientId string)
- func (n *Network) IsClient() bool
- func (n *Network) IsServer() bool
- func (n *Network) RegisterEvent(name string, fn func(clientId string, data []byte))
- func (n *Network) StartServer(port int)
- func (n *Network) TriggerEvent(name, clientId string, data []byte)
- func (n *Network) TriggerOnServerAndClients(name string, data []byte)
- func (n *Network) Update(dt float64)
- type Packet
- type Server
- func (s *Server) BroadcastMessage(command string, data []byte)
- func (s *Server) ClientJoinedEvent(callback func(clientId string))
- func (s *Server) Close()
- func (s *Server) FlushAllWriteBuffers()
- func (s *Server) FlushWriteBuffer(token string)
- func (s *Server) Listen(port int)
- func (s *Server) PacketReceived(callback func(packet Packet))
- func (s *Server) WriteMessage(packet Packet)
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetBytesReceivedByEvent ¶
func (*Client) GetBytesSentByEvent ¶
func (*Client) PacketReceived ¶
func (*Client) WriteMessage ¶
type Network ¶
type Network struct { emitter.EventEmitter // contains filtered or unexported fields }
func NewNetwork ¶
func NewNetwork() *Network
func (*Network) BroadcastEvent ¶
BroadcastEvent - trigger an event on all clients. If called on the client, this will trigger the event on the server.
func (*Network) BytesReceived ¶
func (*Network) BytesReceivedByCommand ¶
func (*Network) BytesSentByCommand ¶
func (*Network) ClientJoinedEvent ¶
ClientJoinedEvent - register an event to trigger when a new client joins the server
func (*Network) ClientToken ¶
func (*Network) ConnectClient ¶
func (*Network) FlushAllWriteBuffers ¶
func (n *Network) FlushAllWriteBuffers()
func (*Network) FlushWriteBuffer ¶
func (*Network) RegisterEvent ¶
RegisterEvent - register an event that will be triggered on clients and server. RegisterEvent should be used to register syncronous events
func (*Network) StartServer ¶
func (*Network) TriggerEvent ¶
TriggerEvent - Trigger an event to run on a particular client. If called on the client, this will trigger the event on the server.
func (*Network) TriggerOnServerAndClients ¶
CallOnServerAndClient - trigger an event on the server and on all client. If called on the client, this will trigger the event on the client and on the server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) BroadcastMessage ¶
func (*Server) ClientJoinedEvent ¶
func (*Server) FlushAllWriteBuffers ¶
func (s *Server) FlushAllWriteBuffers()
FlushAllWriteBuffers - send all buffered messages immediately for all sessions
func (*Server) FlushWriteBuffer ¶
FlushWriteBuffer - send all buffered messages immediately