Search & Gracefull Close on Websocket

This commit is contained in:
mr
2026-03-13 10:28:24 +01:00
parent a11d764729
commit 80bb9ffbed
4 changed files with 45 additions and 22 deletions

View File

@@ -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()
}