This repository has been archived by the owner on Apr 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
handler.go
65 lines (57 loc) · 1.79 KB
/
handler.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
62
63
64
65
package nrf_handler
import (
"github.com/sirupsen/logrus"
"free5gc/lib/openapi/models"
"free5gc/src/nrf/logger"
"free5gc/src/nrf/nrf_handler/nrf_message"
"free5gc/src/nrf/nrf_producer"
"time"
)
const (
MaxChannel int = 100000
)
var nrfChannel chan nrf_message.HandlerMessage
var HandlerLog *logrus.Entry
func init() {
// init Pool
HandlerLog = logger.HandlerLog
nrfChannel = make(chan nrf_message.HandlerMessage, 20)
}
func SendMessage(msg nrf_message.HandlerMessage) {
nrfChannel <- msg
//go Handle()
}
func Handle() {
for {
select {
case msg, ok := <-nrfChannel:
if ok {
switch msg.Event {
case nrf_message.EventNFDiscovery:
HandlerLog.Info("EventNFDiscovery")
case nrf_message.EventNFManagement:
logger.HandlerLog.Info("EventNFManagement")
case nrf_message.EventNotificationNFRegisted:
HandlerLog.Info("EventNotificationNFRegisted")
url := msg.HTTPRequest.Params["url"]
nrf_producer.HandleNotification(msg.ResponseChan, url, msg.HTTPRequest.Body.(models.NotificationData))
case nrf_message.EventNotificationNFDeregisted:
HandlerLog.Info("EventNotificationNFDeregisted")
url := msg.HTTPRequest.Params["url"]
nrf_producer.HandleNotification(msg.ResponseChan, url, msg.HTTPRequest.Body.(models.NotificationData))
case nrf_message.EventNotificationNFProfileChanged:
HandlerLog.Info("EventNotificationNFProfileChanged")
url := msg.HTTPRequest.Params["url"]
nrf_producer.HandleNotification(msg.ResponseChan, url, msg.HTTPRequest.Body.(models.NotificationData))
case nrf_message.EventAccessToken:
HandlerLog.Info("EventAccessToken")
default:
HandlerLog.Warnf("Event[%s] has not implemented", msg.Event)
}
} else {
HandlerLog.Errorln("Channel closed!")
}
case <-time.After(time.Second * 1):
}
}
}