Gracefull stop on websocket
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
"cloud.o-forge.io/core/oc-lib/config"
|
||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
||||
"cloud.o-forge.io/core/oc-lib/models/peer"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
)
|
||||
@@ -87,7 +88,18 @@ func ListenNATS() {
|
||||
}, p.GetID())
|
||||
}
|
||||
} else if p.Relation != peer.SELF {
|
||||
access.StoreOne(p.Serialize(p))
|
||||
if p.Relation != peer.SELF {
|
||||
access.StoreOne(p.Serialize(p))
|
||||
} else if data := access.Search(&dbs.Filters{
|
||||
And: map[string][]dbs.Filter{
|
||||
"relation": {{Operator: dbs.EQUAL.String(), Value: peer.SELF.EnumIndex()}},
|
||||
},
|
||||
}, "", false); len(data.Data) == 0 {
|
||||
access.StoreOne(p.Serialize(p))
|
||||
} else if len(data.Data) == 1 && data.Data[0].GetID() != p.GetID() {
|
||||
access.DeleteOne(data.Data[0].GetID())
|
||||
access.StoreOne(p.Serialize(p))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user