Documentation ¶
Index ¶
- Constants
- func WriteTimeout(ctx context.Context, timeout time.Duration, c *websocket.Conn, msg []byte) error
- type AuthSucceededMessage
- type ChatMessage
- type ClientID
- type ClientType
- type ClusterCommand
- type CommandMessage
- type CommandResult
- type ConnectMessage
- type Connection
- type DiscordCodeMessage
- type ENetClient
- func (c *ENetClient) Connect(name string, isHidden bool, shouldCopy bool)
- func (c *ENetClient) Destroy()
- func (c *ENetClient) DeviceType() string
- func (c *ENetClient) Disconnect(reason int, message string)
- func (c *ENetClient) Host() string
- func (c *ENetClient) NetworkStatus() NetworkStatus
- func (c *ENetClient) Poll(ctx context.Context)
- func (c *ENetClient) ReceiveCommands() <-chan ClusterCommand
- func (c *ENetClient) ReceiveDisconnect() <-chan bool
- func (c *ENetClient) ReceivePackets() <-chan io.RawPacket
- func (c *ENetClient) Send(packet io.RawPacket) <-chan error
- func (c *ENetClient) ServerChanged(target string)
- func (c *ENetClient) Session() *utils.Session
- func (c *ENetClient) Type() ClientType
- type ENetIngress
- func (server *ENetIngress) AddClient(s *ENetClient)
- func (server *ENetIngress) FindClientForPeer(peer *enet.Peer) *ENetClient
- func (server *ENetIngress) Poll(ctx context.Context)
- func (server *ENetIngress) RemoveClient(client *ENetClient)
- func (server *ENetIngress) Serve(port int) error
- func (server *ENetIngress) Shutdown()
- type GenericMessage
- type InfoMessage
- type NetworkStatus
- type PacketACK
- type PacketMessage
- type ResponseMessage
- type ServerConnectedMessage
- type ServerDisconnectedMessage
- type ServerInfo
- type WSClient
- func (c *WSClient) Connect(name string, isHidden bool, shouldCopy bool)
- func (c *WSClient) Destroy()
- func (c *WSClient) DeviceType() string
- func (c *WSClient) Disconnect(reason int, message string)
- func (c *WSClient) Host() string
- func (c *WSClient) NetworkStatus() NetworkStatus
- func (c *WSClient) ReceiveCommands() <-chan ClusterCommand
- func (c *WSClient) ReceiveDisconnect() <-chan bool
- func (c *WSClient) ReceivePackets() <-chan io.RawPacket
- func (c *WSClient) Send(packet io.RawPacket) <-chan error
- func (c *WSClient) SendGlobalChat(message string)
- func (c *WSClient) Session() *utils.Session
- func (c *WSClient) Type() ClientType
- type WSIngress
- func (server *WSIngress) AddClient(s *WSClient)
- func (server *WSIngress) Broadcast(msg []byte)
- func (server *WSIngress) BuildBroadcast() ([]byte, error)
- func (server *WSIngress) HandleClient(ctx context.Context, c *websocket.Conn, host string, deviceType string) error
- func (server *WSIngress) HandleLogin(ctx context.Context, client *WSClient, code string)
- func (server *WSIngress) RemoveClient(client *WSClient)
- func (server *WSIngress) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (server *WSIngress) Shutdown(ctx context.Context)
- func (server *WSIngress) StartWatcher(ctx context.Context)
Constants ¶
View Source
const ( ClientTypeWS = iota ClientTypeENet )
View Source
const ( NetworkStatusConnected = iota NetworkStatusDisconnected )
View Source
const ( // Server -> client InfoOp int = iota ServerConnectedOp ServerDisconnectedOp ServerResponseOp AuthSucceededOp AuthFailedOp ChatOp // Client -> server ConnectOp DisconnectOp CommandOp DiscordCodeOp // server -> client OR client -> server PacketOp )
View Source
const (
CLIENT_MESSAGE_LIMIT int = 16
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthSucceededMessage ¶
type ChatMessage ¶
type ClientID ¶
type ClientID uint32
A unique identifier for this client for the lifetime of their session.
type ClientType ¶
type ClientType uint8
type ClusterCommand ¶
type ClusterCommand struct { Command string Response chan CommandResult }
type CommandMessage ¶
type CommandMessage struct { Op int // CommandOp Command string // Uniquely identifies the command so we can send a response Id int }
Issuing a cluster command on behalf of the user.
type CommandResult ¶
type CommandResult struct {
Err error
}
type ConnectMessage ¶
type ConnectMessage struct { Op int // ConnectOp // One of the servers hosted by the cluster Target string }
Connect the client to a server
type Connection ¶
type Connection interface { Session() *utils.Session // Lasts for the duration of the client's connection to its ingress. NetworkStatus() NetworkStatus Host() string Type() ClientType DeviceType() string // Tell the client that we've connected Connect(name string, isHidden bool, shouldCopy bool) // Messages going to the client Send(packet io.RawPacket) <-chan error // Messages going to the server ReceivePackets() <-chan io.RawPacket // Clients can issue commands out-of-band // Commands sent in ordinary game packets are interpreted anyway ReceiveCommands() <-chan ClusterCommand // When the client disconnects on its own ReceiveDisconnect() <-chan bool // Forcibly disconnect this client Disconnect(reason int, message string) Destroy() }
type DiscordCodeMessage ¶
type ENetClient ¶
type ENetClient struct {
// contains filtered or unexported fields
}
func NewENetClient ¶
func NewENetClient() *ENetClient
func (*ENetClient) Connect ¶
func (c *ENetClient) Connect(name string, isHidden bool, shouldCopy bool)
func (*ENetClient) Destroy ¶
func (c *ENetClient) Destroy()
func (*ENetClient) DeviceType ¶
func (c *ENetClient) DeviceType() string
func (*ENetClient) Disconnect ¶
func (c *ENetClient) Disconnect(reason int, message string)
func (*ENetClient) Host ¶
func (c *ENetClient) Host() string
func (*ENetClient) NetworkStatus ¶
func (c *ENetClient) NetworkStatus() NetworkStatus
func (*ENetClient) Poll ¶
func (c *ENetClient) Poll(ctx context.Context)
func (*ENetClient) ReceiveCommands ¶
func (c *ENetClient) ReceiveCommands() <-chan ClusterCommand
func (*ENetClient) ReceiveDisconnect ¶
func (c *ENetClient) ReceiveDisconnect() <-chan bool
func (*ENetClient) ReceivePackets ¶
func (c *ENetClient) ReceivePackets() <-chan io.RawPacket
func (*ENetClient) ServerChanged ¶
func (c *ENetClient) ServerChanged(target string)
func (*ENetClient) Session ¶
func (c *ENetClient) Session() *utils.Session
func (*ENetClient) Type ¶
func (c *ENetClient) Type() ClientType
type ENetIngress ¶
type ENetIngress struct { // Run when a client joins InitialCommand string // contains filtered or unexported fields }
func NewENetIngress ¶
func NewENetIngress(newClients chan Connection) *ENetIngress
func (*ENetIngress) AddClient ¶
func (server *ENetIngress) AddClient(s *ENetClient)
func (*ENetIngress) FindClientForPeer ¶
func (server *ENetIngress) FindClientForPeer(peer *enet.Peer) *ENetClient
func (*ENetIngress) Poll ¶
func (server *ENetIngress) Poll(ctx context.Context)
func (*ENetIngress) RemoveClient ¶
func (server *ENetIngress) RemoveClient(client *ENetClient)
func (*ENetIngress) Serve ¶
func (server *ENetIngress) Serve(port int) error
func (*ENetIngress) Shutdown ¶
func (server *ENetIngress) Shutdown()
type GenericMessage ¶
type GenericMessage struct {
Op int
}
type InfoMessage ¶
type InfoMessage struct { Op int // InfoOp // All of the servers from the master (real Sauerbraten servers.) Master []ServerInfo // All of the servers this cluster hosts. Cluster []string }
Contains information on servers this cluster contains and real ones from the master.
type PacketMessage ¶
type PacketMessage struct { Op int // ServerPacketOp or ClientPacketOp Channel int Data []byte Length int }
Contains a packet from the server a client is connected to.
type ResponseMessage ¶
type ServerConnectedMessage ¶
type WSClient ¶
type WSClient struct {
// contains filtered or unexported fields
}
func NewWSClient ¶
func NewWSClient() *WSClient
func (*WSClient) DeviceType ¶
func (*WSClient) Disconnect ¶
func (*WSClient) NetworkStatus ¶
func (c *WSClient) NetworkStatus() NetworkStatus
func (*WSClient) ReceiveCommands ¶
func (c *WSClient) ReceiveCommands() <-chan ClusterCommand
func (*WSClient) ReceiveDisconnect ¶
func (*WSClient) ReceivePackets ¶
func (*WSClient) SendGlobalChat ¶
func (*WSClient) Type ¶
func (c *WSClient) Type() ClientType
type WSIngress ¶
type WSIngress struct {
// contains filtered or unexported fields
}
func NewWSIngress ¶
func NewWSIngress(newClients chan Connection) *WSIngress
func (*WSIngress) BuildBroadcast ¶
func (*WSIngress) HandleClient ¶
func (*WSIngress) HandleLogin ¶
func (*WSIngress) RemoveClient ¶
func (*WSIngress) ServeHTTP ¶
func (server *WSIngress) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*WSIngress) StartWatcher ¶
Click to show internal directories.
Click to hide internal directories.