Search & Gracefull Close on Websocket
This commit is contained in:
@@ -26,20 +26,18 @@ func EmitNATS(user string, groups []string, message tools.PropalgationMessage) {
|
||||
b, _ := json.Marshal(message)
|
||||
switch message.Action {
|
||||
case tools.PB_SEARCH:
|
||||
if slices.Contains(ressourceCols, oclib.LibDataEnum(message.DataType)) {
|
||||
SearchMu.Lock()
|
||||
SearchStream[user] = make(chan resources.ResourceInterface, 128)
|
||||
SearchMu.Unlock()
|
||||
}
|
||||
SearchMu.Lock()
|
||||
SearchStream[user] = make(chan resources.ResourceInterface, 128)
|
||||
SearchMu.Unlock()
|
||||
tools.NewNATSCaller().SetNATSPub(tools.PROPALGATION_EVENT, tools.NATSResponse{
|
||||
FromApp: "oc-catalog",
|
||||
Datatype: -1,
|
||||
User: user,
|
||||
Groups: groups,
|
||||
Method: int(tools.PROPALGATION_EVENT),
|
||||
Payload: b,
|
||||
})
|
||||
}
|
||||
tools.NewNATSCaller().SetNATSPub(tools.PROPALGATION_EVENT, tools.NATSResponse{
|
||||
FromApp: "oc-catalog",
|
||||
Datatype: -1,
|
||||
User: user,
|
||||
Groups: groups,
|
||||
Method: int(tools.PROPALGATION_EVENT),
|
||||
Payload: b,
|
||||
})
|
||||
}
|
||||
|
||||
// un ressource quand on l'ajoute à notre catalogue elle nous est étrangère.
|
||||
@@ -70,6 +68,7 @@ func ListenNATS() {
|
||||
if err == nil {
|
||||
fmt.Println("SearchStream", p)
|
||||
SearchMu.Lock()
|
||||
fmt.Println(SearchStream, resp.User)
|
||||
SearchStream[resp.User] <- p // TODO when do we update it in our catalog ?*
|
||||
SearchMu.Unlock()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user