/
remote_process.go
executable file
·61 lines (51 loc) · 1.3 KB
/
remote_process.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package remote
import (
"github.com/meeypioneer/mey-actor/actor"
)
type process struct {
pid *actor.PID
}
func newProcess(pid *actor.PID) actor.Process {
return &process{
pid: pid,
}
}
func (ref *process) SendUserMessage(pid *actor.PID, message interface{}) {
header, msg, sender := actor.UnwrapEnvelope(message)
SendMessage(pid, header, msg, sender, -1)
}
func SendMessage(pid *actor.PID, header actor.ReadonlyMessageHeader, message interface{}, sender *actor.PID, serializerID int32) {
rd := &remoteDeliver{
header: header,
message: message,
sender: sender,
target: pid,
serializerID: serializerID,
}
endpointManager.remoteDeliver(rd)
}
func (ref *process) SendSystemMessage(pid *actor.PID, message interface{}) {
//intercept any Watch messages and direct them to the endpoint manager
switch msg := message.(type) {
case *actor.Watch:
rw := &remoteWatch{
Watcher: msg.Watcher,
Watchee: pid,
}
endpointManager.remoteWatch(rw)
case *actor.Unwatch:
ruw := &remoteUnwatch{
Watcher: msg.Watcher,
Watchee: pid,
}
endpointManager.remoteUnwatch(ruw)
default:
SendMessage(pid, nil, message, nil, -1)
}
}
func (ref *process) Stop(pid *actor.PID) {
ref.SendSystemMessage(pid, stopMessage)
}
func (ref *process) MsgNum() int32 {
return ref.MsgNum()
}