35 lines
801 B
Go
35 lines
801 B
Go
package matrix
|
|
|
|
import (
|
|
lib "git.sr.ht/~cco/go-scopes"
|
|
"git.sr.ht/~cco/go-scopes/config"
|
|
"git.sr.ht/~cco/go-scopes/core/action"
|
|
)
|
|
|
|
func DefaultConfig(name string) lib.Config {
|
|
cfg := config.Default(name)
|
|
cfg.AddAction("create", action.Base(create))
|
|
return cfg
|
|
}
|
|
|
|
func create(act lib.Action) bool {
|
|
ctx := act.Context()
|
|
spec := act.Spec()
|
|
msg := act.Message()
|
|
cctx := createCell(ctx)
|
|
//nmsg := message.New("matrix", "connect").WithSender(cctx)
|
|
//msg.Sender().Cell().Send(nmsg)
|
|
connect(ctx, cctx, spec, msg)
|
|
connect(cctx, msg.Sender().Cell(), spec, msg)
|
|
return true
|
|
}
|
|
|
|
func createCell(ctx lib.Context) lib.Context {
|
|
cfg := DefaultConfig("")
|
|
cctx := ctx.ChildContext(cfg)
|
|
cfg.Starter()(cctx)
|
|
return cctx
|
|
}
|
|
|
|
func connect(src, tgt lib.Context, spec lib.ActionSpec, msg lib.Message) {
|
|
}
|