How To Setup Module Commands And Custom Module Commands

You may implement your own custom commands and logic with Diarkis.

 

In order for clients to call module commands, the server must set up module commands.

Room, Group, and Field modules have ExposeCommands function respectively to set up built-in module commands.

 

Group module built-in command set up example:

package groupcmds

 

import (

        "fmt"

        "github.com/Diarkis/diarkis/group"

)

 

func Expose(rootpath string) {

        // rootpath is defined in cmds/main.go

        group.Setup(fmt.Sprintf("%s/configs/shared/group.json", rootpath))

        group.ExposeCommands()

}

 

If you wish not to use built-in module commands entirely and implement your own module commands, use SetupAsTCPServer, SetupAsUDPServer, or SetupAsWebSocketServer according to the server type instead of ExposeCommands.

 

TCP server example:

package groupcmds

 

import (

        "fmt"

        "github.com/Diarkis/diarkis/group"

)

 

func Expose(rootpath string) {

        // rootpath is defined in cmds/main.go

        group.Setup(fmt.Sprintf("%s/configs/shared/group.json", rootpath))

        group.SetupAsTCPServer()

}

 

 

 
 
会社ロゴ
Connect the World with Diarkis