Bad Send status
const Bad = 4
Err Send status
const Err = 5
Ok Send status
const Ok = 1
TCPType a type of TCP server used by mesh module
const TCPType = tcp.Type
UDPType a type of UDP server used by mesh module
const UDPType = udp.Type
WSType a type of WebSocket server used by mesh module
const WSType = ws.Type
func Command(ver uint8, cmd uint16, handler func(*user.User, func(error)))
Command [WebSocket ONLY] use HandleCommand instead for other servers.
func GetEndPoint() string
GetEndPoint returns the end point address the server is bound with
func GetServerType() string
GetServerType returns server type as a string
func HandleCommand(ver uint8, cmd uint16, handler func(uint8, uint16, []byte, *user.User, func(error))) error
HandleCommand registers a command handler function for TCP and UDP/RUDP server.
func HandleWSCommand(ver float64, cmd float64, handler func(float64, float64, map[string]interface{}, *user.User, func(error))) error
HandleWSCommand registers WebSocket command function.
func HookAllCommands(handler func(*user.User, func(error)))
HookAllCommands Registers a packet handler as a hook to all commands
func IsCommandDuplicate(ver uint8, commandID uint16) bool
IsCommandDuplicate returns true if ver and commandID are used elsewhere when this function is invoked
func IsTCP() bool
IsTCP Returns true if the server is setup as TCP server
func IsUDP() bool
IsUDP Returns true if the server is setup as UDP server
func IsWebSocket() bool
IsWebSocket Returns true if the server is setup as WebSocket server
func Offline()
Offline Set server status to offline
func OnDisconnect(callback func(string, *user.User))
OnDisconnect Registers a callback on connection termination for TCP/UDP
func OnKeepAlive(handler func(*user.User, func(error)))
OnKeepAlive Registers a handler on TCP heartbeat or UDP echo
func Online()
Online Set server status to online
func SendPM(nodeAddr string, sid string, ver uint8, cmd uint16, message []byte)
SendPM sends a direct message to another user - The sent private message is a reliable delivery
func SetPublicEndPoint(addr string)
SetPublicEndPoint sets public end point to be sent to the client to be used to connect
func SetupAsConnector(path string)
SetupAsConnector Initialize the server as a Connector server for an external real-time server. This is meant to be used with an external real-time server such as Unreal Engine Dedicated server etc. Diarkis itself will not communicate wit the clients, but focuses on autoscaling and horizontal scaling on K8s.
func SetupAsTCPServer(path string)
SetupAsTCPServer Initialize as a TCP server. Load configurations from the file path given. Pass an empty string, if there is no need for configurations.
func SetupAsUDPServer(path string)
SetupAsUDPServer Initialize as a UDP server. Load configurations from the file path given. Pass an empty string, if there is no need for configurations.
func SetupAsWebSocketServer(path string)
SetupAsWebSocketServer Initialize as a WebSocket server. Load configurations from the file path given. The config name is "WS". Pass an empty string, if there is no need for configurations.
func SetupServerForAWS() error
SetupServerForAWS sets public endpoint in AWS environement Must be called in diarkis.OnReady() as a callback
func SetupServerForAzure() error
SetupServerForAzure sets public endpoint in Microsoft Azure environement Must be called in diarkis.OnReady() as a callback
func SetupServerForGCP() error
SetupServerForGCP sets public endpoint in GCP environement Must be called in diarkis.OnReady() as a callback