github.com/qiuhoude/go-web@v0.0.0-20220223060959-ab545e78f20d/prepare/23_proto_actor/remoteadvertisedaddress/node2/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/AsynkronIT/goconsole"
     6  	"github.com/AsynkronIT/protoactor-go/actor"
     7  	"github.com/AsynkronIT/protoactor-go/examples/remotebenchmark/messages"
     8  	"github.com/AsynkronIT/protoactor-go/remote"
     9  )
    10  
    11  func main() {
    12  	remote.Start("127.0.0.1:8080")
    13  	rootContext := actor.EmptyRootContext
    14  	props := actor.
    15  		PropsFromFunc(
    16  			func(context actor.Context) {
    17  				switch context.Message().(type) {
    18  				case *messages.Ping:
    19  					fmt.Printf("Received ping from sender with address:%v \n", context.Sender())
    20  					context.Respond(&messages.Pong{})
    21  				}
    22  			})
    23  
    24  	rootContext.SpawnNamed(props, "remote")
    25  
    26  	console.ReadLine()
    27  }