39 lines
808 B
Go
39 lines
808 B
Go
|
package module
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"forge.cadoles.com/arcad/edge/pkg/bus"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
MessageNamespaceClient bus.MessageNamespace = "client"
|
||
|
MessageNamespaceServer bus.MessageNamespace = "server"
|
||
|
)
|
||
|
|
||
|
type ServerMessage struct {
|
||
|
Context context.Context
|
||
|
Data interface{}
|
||
|
}
|
||
|
|
||
|
func (m *ServerMessage) MessageNamespace() bus.MessageNamespace {
|
||
|
return MessageNamespaceServer
|
||
|
}
|
||
|
|
||
|
func NewServerMessage(ctx context.Context, data interface{}) *ServerMessage {
|
||
|
return &ServerMessage{ctx, data}
|
||
|
}
|
||
|
|
||
|
type ClientMessage struct {
|
||
|
Context context.Context
|
||
|
Data map[string]interface{}
|
||
|
}
|
||
|
|
||
|
func (m *ClientMessage) MessageNamespace() bus.MessageNamespace {
|
||
|
return MessageNamespaceClient
|
||
|
}
|
||
|
|
||
|
func NewClientMessage(ctx context.Context, data map[string]interface{}) *ClientMessage {
|
||
|
return &ClientMessage{ctx, data}
|
||
|
}
|