Skip to content

Commit

Permalink
fix: tag.update is ok now
Browse files Browse the repository at this point in the history
  • Loading branch information
manatlan committed Oct 8, 2023
1 parent 627ca20 commit df61c1b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion htagweb/appserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ async def serve(self, request,
connect();
""" % locals()

p = HrClient(uid,fqn,js,self.sesprovider.__name__)
p = HrClient(uid,fqn,js,self.sesprovider.__name__,http_only=is_http_only)
html=await p.start(*args,**kargs)
return HTMLResponse(html)

Expand Down
18 changes: 12 additions & 6 deletions htagweb/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __repr__(self):
return self.hid

##################################################################################
def hrprocess(hid:Hid,js,init,sesprovidername):
def hrprocess(hid:Hid,js,init,sesprovidername,useUpdate):
##################################################################################
FactorySession=importFactorySession(sesprovidername)

Expand Down Expand Up @@ -139,14 +139,20 @@ def suicide():
# register tag.update feature
#======================================
async def update(actions):
""" return always True !!
IRL: it should wait an hrclient response to return true/false according
the fact it reachs to send back on socket.
"""
try:
r=await bus.publish(hid.event_response_update,actions)
await bus.publish(hid.event_response_update,actions)
except:
log("!!! concurrent write/read on redys !!!")
r=False
return r

hr.sendactions=update
return True
if useUpdate:
log("tag.update enabled")
hr.sendactions=update
else:
log("tag.update not possible (http only)")
#======================================
recreate={}

Expand Down
4 changes: 3 additions & 1 deletion htagweb/server/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ def startProcess(params:dict):


class HrClient:
def __init__(self,uid:str,fqn:str,js:str=None,sesprovidername=None):
def __init__(self,uid:str,fqn:str,js:str=None,sesprovidername=None,http_only=False):
""" !!!!!!!!!!!!!!!!!!!! if js|sesprovidername is None : can't do a start() !!!!!!!!!!!!!!!!!!!!!!"""
self.js=js
self.bus = redys.v2.AClient()
self.sesprovidername=sesprovidername
self.useUpdate = not http_only

self.hid=Hid.create(uid,fqn)

Expand Down Expand Up @@ -59,6 +60,7 @@ async def start(self,*a,**k) -> str:
js=self.js,
init= (a,k),
sesprovidername=self.sesprovidername,
useUpdate = self.useUpdate,
)

running_hids:list=await self.bus.get(KEYAPPS) or []
Expand Down

0 comments on commit df61c1b

Please sign in to comment.