本文整理汇总了Golang中github.com/rogeralsing/gam/actor.Context.Message方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Message方法的具体用法?Golang Context.Message怎么用?Golang Context.Message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/rogeralsing/gam/actor.Context
的用法示例。
在下文中一共展示了Context.Message方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Receive
func (state *BecomeActor) Receive(context actor.Context) {
switch msg := context.Message().(type) {
case Hello:
fmt.Printf("Hello %v\n", msg.Who)
context.Become(state.Other)
}
}
示例2: Receive
func (*remoteActor) Receive(context actor.Context) {
switch msg := context.Message().(type) {
case *messages.StartRemote:
log.Println("Starting")
msg.Sender.Tell(&messages.Start{})
case *messages.Ping:
msg.Sender.Tell(&messages.Pong{})
}
}
示例3: Receive
func (state *endpointWriter) Receive(ctx actor.Context) {
switch msg := ctx.Message().(type) {
case actor.Started:
state.initialize()
case actor.Stopped:
state.conn.Close()
case actor.Restarting:
state.conn.Close()
case []interface{}:
state.sendEnvelopes(msg, ctx)
default:
log.Fatal("Unknown message", msg)
}
}
示例4: Receive
func (state *endpointManager) Receive(ctx actor.Context) {
switch msg := ctx.Message().(type) {
case actor.Started:
state.connections = make(map[string]*actor.PID)
log.Println("Started EndpointManager")
case *messages.MessageEnvelope:
pid, ok := state.connections[msg.Target.Host]
if !ok {
props := actor.
FromProducer(newEndpointWriter(msg.Target.Host, state.config)).
WithMailbox(newEndpointWriterMailbox(state.config.batchSize, 1000000))
pid = actor.Spawn(props)
state.connections[msg.Target.Host] = pid
}
pid.Tell(msg)
}
}
示例5: Other
func (state *BecomeActor) Other(context actor.Context) {
switch msg := context.Message().(type) {
case Hello:
fmt.Printf("%v, ey we are now handling messages in another behavior", msg.Who)
}
}