|
|
@@ -30,55 +30,57 @@ type Moscato struct {
|
|
30
|
30
|
secure_mng secure_manager
|
|
31
|
31
|
}
|
|
32
|
32
|
|
|
33
|
|
-type MicroService struct {
|
|
34
|
|
- receivemsg *SubscriptionMsg
|
|
|
33
|
+type Reply struct {
|
|
|
34
|
+ ReceiveMsg MsgUnit
|
|
35
|
35
|
}
|
|
36
|
36
|
|
|
37
|
|
-//Recieve - MM가 msg전달 받음
|
|
38
|
|
-func (moscato *Moscato) Recieve(msg MsgUnit) (MsgUnit, error) {
|
|
39
|
|
- msg_type := msg.CheckType()
|
|
|
37
|
+type Listner int
|
|
|
38
|
+
|
|
|
39
|
+
|
|
|
40
|
+//MS에서 보내는거-rpc call 사용
|
|
|
41
|
+/*func (l *Listner)MM_Receive(msg MsgUnit, reply *Reply)error{
|
|
|
42
|
+ reply.ReceiveMsg=msg
|
|
|
43
|
+
|
|
|
44
|
+ return nil
|
|
|
45
|
+}*/
|
|
|
46
|
+
|
|
|
47
|
+func (moscato *Moscato)MM_Receive(msg MsgUnit, reply *Reply)error{
|
|
|
48
|
+ reply.ReceiveMsg=msg
|
|
|
49
|
+ go moscato.Receive(reply)
|
|
|
50
|
+ return nil
|
|
|
51
|
+}
|
|
40
|
52
|
|
|
|
53
|
+//Recieve - MM가 msg전달 받음
|
|
|
54
|
+func (moscato *Moscato)Receive(reply *Reply) (MsgUnit, error) {
|
|
|
55
|
+ //rpc call
|
|
|
56
|
+ var msg_type = reply.ReceiveMsg.CheckType()
|
|
41
|
57
|
//메세지 타입에 따라 다르게 처리
|
|
42
|
58
|
switch msg_type {
|
|
43
|
59
|
|
|
44
|
60
|
case KSM: //Key share msg
|
|
45
|
61
|
|
|
46
|
62
|
case PM: //Publish msg
|
|
47
|
|
- moscato.queue.push(msg.(*PublishMsg))
|
|
|
63
|
+ moscato.queue.push(reply.ReceiveMsg.(*PublishMsg))
|
|
48
|
64
|
|
|
49
|
65
|
case SM: //Subscription msg
|
|
50
|
|
- moscato.match_mng.add_subscription(msg.(*SubscriptionMsg))
|
|
|
66
|
+ moscato.match_mng.add_subscription(reply.ReceiveMsg.(*SubscriptionMsg))
|
|
51
|
67
|
|
|
52
|
68
|
case RM: //Register msg
|
|
53
|
69
|
//var newmsg RegisterMsg
|
|
54
|
|
- var newmsg = msg.(*RegisterMsg)
|
|
|
70
|
+ var newmsg = reply.ReceiveMsg.(*RegisterMsg)
|
|
55
|
71
|
newNode := MSnode{newmsg.From(), newmsg.From()}
|
|
56
|
72
|
moscato.ms_mng.add_microservice(newNode)
|
|
57
|
73
|
|
|
58
|
74
|
case WM: //Withdraw msg
|
|
59
|
|
- moscato.ms_mng.remove_microservice(msg.(*WithdrawMsg).From())
|
|
|
75
|
+ moscato.ms_mng.remove_microservice(reply.ReceiveMsg.(*WithdrawMsg).From())
|
|
60
|
76
|
|
|
61
|
77
|
default:
|
|
62
|
78
|
return nil, errors.New("Message type Error: Not registered message type")
|
|
63
|
79
|
}
|
|
64
|
80
|
|
|
65
|
|
- return msg, nil
|
|
|
81
|
+ return reply.ReceiveMsg, nil
|
|
66
|
82
|
}
|
|
67
|
83
|
|
|
68
|
|
-//Receive - MicorService가 msg 받음// MS.go들어가야할 함수
|
|
69
|
|
-/*func (ms *MicroService)Receive(msg MsgUnit)error{
|
|
70
|
|
- msg_type:=msg.CheckType()
|
|
71
|
|
-
|
|
72
|
|
- switch msg_type{
|
|
73
|
|
- case KGM://Key Gen Msg
|
|
74
|
|
-
|
|
75
|
|
- case KSM://Key Share Msg
|
|
76
|
|
-
|
|
77
|
|
- case SM://Subscription Msg
|
|
78
|
|
- ms.receivemsg=msg.(*SubscriptionMsg)
|
|
79
|
|
- }
|
|
80
|
|
- return nil
|
|
81
|
|
-}*/
|
|
82
|
84
|
|
|
83
|
85
|
func (moscato *Moscato) Run() {
|
|
84
|
86
|
//모스카토 구조체 변수 초기화
|