mq

package
v0.0.0-...-7518d33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BaseContestIDToRuntime = make(map[uint]*eventloop.EventLoop)
	RuntimeToBaseContestID = make(map[*eventloop.EventLoop]uint)
	Mutex                  = &sync.Mutex{} // 用于保护 map 的并发访问
)

定义全局 map

View Source
var Ctx_callback = context.Background()

Functions

func AddMatch

func AddMatch(playerIDs []uint, baseContestID uint, tag string, extraInfo map[string]interface{}) (matchID uint, err error)

func CallJSFunction

func CallJSFunction(loop *eventloop.EventLoop, funcName string, args ...interface{}) (result goja.Value, err error)

func CallOnAIAssigned

func CallOnAIAssigned(contestant model.Contestant) error

func CallOnMatchFinished

func CallOnMatchFinished(matchID uint, replay string) error

func ChangeMatch

func ChangeMatch(tag string, state string, matchID uint) (err error)

func CreateRuntimeWithJSFile

func CreateRuntimeWithJSFile(baseContestID uint) error

func InitGameMq

func InitGameMq(baseContestID uint, vm *goja.Runtime)

func InitGameMqAndRunScript

func InitGameMqAndRunScript(baseContestID uint)

func InitMq

func InitMq()

func ListenMsgForMatchFinished

func ListenMsgForMatchFinished()

func SendBuildAIMsg

func SendBuildAIMsg(ctx context.Context, aiID uint) error

func SendBuildGameLogicMsg

func SendBuildGameLogicMsg(ctx context.Context, gameID uint) error

func SendRunAutoMatchMsg

func SendRunAutoMatchMsg(ctx context.Context, matchID uint) error

func SetCreateMatch

func SetCreateMatch(baseContestID uint, vm *goja.Runtime) error

func SetGetContestantsByRanking

func SetGetContestantsByRanking(baseContestID uint, vm *goja.Runtime) error

func SetGoFuncForJS

func SetGoFuncForJS(baseContestID uint, funcName string, goFunc func(goja.FunctionCall) goja.Value, vm *goja.Runtime) error

func SetUpdateContestant

func SetUpdateContestant(baseContestID uint, vm *goja.Runtime) error

func Startup

func Startup()

Types

type Msg

type Msg struct {
	ID        string // 消息的编号
	Topic     string // 消息的主题(Build/Run)
	Body      []byte // 消息的Body
	Partition int    // 分区号
	Type      string // 消息类型(AI/Game_logic/SDK)
}

Msg 消息

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL