41 lines
		
	
	
	
		
			642 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
	
		
			642 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package message
 | 
						|
 | 
						|
import "git.sr.ht/~cco/go-scopes/lib"
 | 
						|
 | 
						|
// Message implementation(s)
 | 
						|
 | 
						|
type strMessage string
 | 
						|
 | 
						|
func (msg strMessage) Action() string {
 | 
						|
	return string(msg)
 | 
						|
}
 | 
						|
 | 
						|
func (msg strMessage) Sender() lib.Address {
 | 
						|
	return nil
 | 
						|
}
 | 
						|
 | 
						|
func StrMessage(action string) strMessage {
 | 
						|
	return strMessage(action)
 | 
						|
}
 | 
						|
 | 
						|
var Quit = StrMessage("quit")
 | 
						|
 | 
						|
// Address implementation
 | 
						|
 | 
						|
type address struct {
 | 
						|
	service string
 | 
						|
}
 | 
						|
 | 
						|
func (addr *address) Service() string {
 | 
						|
	return addr.service
 | 
						|
}
 | 
						|
 | 
						|
func (addr *address) Send(ctx lib.Context, msg lib.Message) {
 | 
						|
	lib.Send(ctx, addr, msg)
 | 
						|
}
 | 
						|
 | 
						|
func SimpleAddress(srv string) *address {
 | 
						|
	return &address{
 | 
						|
		service: srv,
 | 
						|
	}
 | 
						|
}
 |