Source File
ss_wa_sm.go
Belonging Package
/examples/wasm/states
package statesimport (amssrpcss)//// FOO (server)//// FooStatesDef contains all the states of the Server state machine "foo".type FooStatesDef struct {*am.StatesBase// Timeout without msgs.Bored string// inherit from SharedStatesDef*SharedStatesDef}// FooGroupsDef contains all the state groups Foo state machine.type FooGroupsDef struct {// GroupName S}// FooSchema represents all relations and properties of FooStates.var FooSchema = SchemaMerge(// inherit from SharedSchemaSharedSchema,am.Schema{ssF.Bored: {},ssF.Msg: StateAdd(SharedSchema[ssF.Msg],am.State{Remove: S{ssF.Bored},}),})// EXPORTS AND GROUPSvar (ssF = am.NewStates(FooStatesDef{})sgF = am.NewStateGroups(FooGroupsDef{// GroupName: S{...},})// FooStates contains all the states for the Foo machine.FooStates = ssF// FooGroups contains all the state groups for the Foo machine.FooGroups = sgF)//// BAR (browser)//// BarStatesDef contains all the states of the Browser state machine "bar".type BarStatesDef struct {*am.StatesBaseSubmitMsg string// inherit from SharedStatesDef*SharedStatesDef}// BarGroupsDef contains all the state groups Bar state machine.type BarGroupsDef struct {// GroupName S}// BarSchema represents all relations and properties of BarStates.var BarSchema = SchemaMerge(// inherit from SharedSchemaSharedSchema,am.Schema{ssB.SubmitMsg: {Multi: true},})// EXPORTS AND GROUPSvar (ssB = am.NewStates(BarStatesDef{})sgB = am.NewStateGroups(BarGroupsDef{// GroupName: S{...},})// BarStates contains all the states for the Bar machine.BarStates = ssB// BarGroups contains all the state groups for the Bar machine.BarGroups = sgB)//// SHARED (common for both server and browser)//// SharedStatesDef contains all the states of the Shared state machine.type SharedStatesDef struct {*am.StatesBase// Message received and should be processed.Msg string// inherit from BasicStatesDef*ss.BasicStatesDef// inherit from rpc/StateSourceStatesDef*ssrpc.StateSourceStatesDef}// SharedGroupsDef contains all the state groups Shared state machine.type SharedGroupsDef struct {// GroupName S}// SharedSchema represents all relations and properties of SharedStates.var SharedSchema = SchemaMerge(// inherit from BasicSchemass.BasicSchema,// inherit from rpc/WorkerSchemassrpc.StateSourceSchema,am.Schema{ssS.Msg: {Multi: true},})// EXPORTS AND GROUPSvar (ssS = am.NewStates(SharedStatesDef{})sgS = am.NewStateGroups(SharedGroupsDef{// GroupName: S{...},})// SharedStates contains all the states for the Shared machine.SharedStates = ssS// SharedGroups contains all the state groups for the Shared machine.SharedGroups = sgS)
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |