Documentation ¶
Index ¶
- Variables
- type Client
- func (client *Client) Connect() error
- func (client *Client) Disconnect()
- func (client *Client) GetClients() ([]uint32, error)
- func (client *Client) ID() uint32
- func (client *Client) On(eventName string, on func(client *Client, senderId uint32, data []byte))
- func (client *Client) OnConnect(on func(client *Client))
- func (client *Client) OnDisconnect(on func(client *Client))
- func (client *Client) SendAll(eventName string, data []byte) error
- func (client *Client) SendTo(eventName string, id uint32, data []byte) error
- type Connection
- type Event
- type Packet
- type Server
- func (server *Server) Listen() error
- func (server *Server) OnConnect(on func(conn *Connection))
- func (server *Server) OnDisconnect(on func(conn *Connection))
- func (server *Server) OnMessage(on func(conn *Connection, eventName string, senderId uint32, data []byte))
- func (server *Server) OnStart(on func(server *Server))
- func (server *Server) Stop()
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrDisconnected error = errors.New("jolta client: disconnected")
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Address string Password []byte Salt []byte DataShards int // default: 10. ParityShards int // default: 3. KeyIter int // default: 1024. KeyLen int // default: 32. Events []*Event Timeout time.Duration // Timeout for accepting streams. 0 disables the timeout. // contains filtered or unexported fields }
func (*Client) Disconnect ¶
func (client *Client) Disconnect()
Disconnect disconnects the client from the server.
func (*Client) GetClients ¶
GetClients returns all client ID's that are connected to the server.
func (*Client) On ¶
On adds a hander to an event name. Empty event names will be called on any event.
func (*Client) OnConnect ¶
OnDisconnect sets the function that is called when the client is connected.
func (*Client) OnDisconnect ¶
OnDisconnect sets the function that is called before the client is disconnected.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func (*Connection) Disconnect ¶
func (conn *Connection) Disconnect()
Disconnect disconnects the client from the server.
type Packet ¶
type Packet uint8
const ( PACKET_GETID Packet = 0 // This packet is sent by the client when it's connected, the server responds with the client's ID. PACKET_SENDTO Packet = 1 // The client tells the server to send a message to a specified user ID PACKET_SENDALL Packet = 2 // The client tells the server to send a message to all clients PACKET_MESSAGE Packet = 3 // The server tells the client that someone sent it a new message PACKET_GETCLIENTS Packet = 4 // The client asks the server to list all clients )
type Server ¶
type Server struct { Address string Password []byte Salt []byte DataShards int // default: 10 ParityShards int // default: 3 Connections []*Connection KeyIter int // default: 1024 KeyLen int // default: 32 Timeout time.Duration // Timeout for accepting streams. 0 disables the timeout. // contains filtered or unexported fields }
func (*Server) OnConnect ¶
func (server *Server) OnConnect(on func(conn *Connection))
OnConnect sets the function that is called when a client is connected.
func (*Server) OnDisconnect ¶
func (server *Server) OnDisconnect(on func(conn *Connection))
OnDisconnect sets the function that is called when a client is connected.
func (*Server) OnMessage ¶
func (server *Server) OnMessage(on func(conn *Connection, eventName string, senderId uint32, data []byte))
OnMessage sets the function that is called when a client receives a message.
Click to show internal directories.
Click to hide internal directories.