當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Context.Message方法代碼示例

本文整理匯總了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)
	}
}
開發者ID:yonglehou,項目名稱:gam,代碼行數:7,代碼來源:main.go

示例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{})
	}
}
開發者ID:yonglehou,項目名稱:gam,代碼行數:9,代碼來源:main.go

示例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)
	}
}
開發者ID:yonglehou,項目名稱:gam,代碼行數:14,代碼來源:endpointwriter.go

示例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)
	}
}
開發者ID:yonglehou,項目名稱:gam,代碼行數:17,代碼來源:endpointmanager.go

示例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)
	}
}
開發者ID:yonglehou,項目名稱:gam,代碼行數:6,代碼來源:main.go


注:本文中的github.com/rogeralsing/gam/actor.Context.Message方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。