github.com/aergoio/aergo@v1.3.1/examples/component/server/server.go (about) 1 /** 2 * @file 3 * @copyright defined in aergo/LICENSE.txt 4 */ 5 6 package server 7 8 import ( 9 "github.com/aergoio/aergo-actor/actor" 10 "github.com/aergoio/aergo/examples/component/message" 11 "github.com/aergoio/aergo/pkg/component" 12 ) 13 14 type TestServer struct { 15 *component.BaseComponent 16 } 17 18 func (ts *TestServer) BeforeStart() { 19 // do nothing 20 } 21 22 func (cs *TestServer) AfterStart() { 23 // do nothing 24 } 25 26 func (ts *TestServer) BeforeStop() { 27 28 // add stop logics for this service 29 } 30 31 func (ts *TestServer) Statistics() *map[string]interface{} { 32 return nil 33 } 34 35 func (ts *TestServer) Receive(context actor.Context) { 36 switch msg := context.Message().(type) { 37 case *message.HelloRsp: 38 ts.Info().Msg(msg.Greeting) 39 } 40 }