mirror of
https://github.com/xcat2/confluent.git
synced 2025-01-17 13:13:18 +00:00
Add closesession request to term sessions
This provides a method for client to request session be closed down. This provides more immediate responsiveness to the client count when closing such a terminal. With this both closing a single window and doing a 'logout' immediately impacts clientcount.
This commit is contained in:
parent
244f655055
commit
64751bccee
@ -536,6 +536,8 @@ class ConsoleSession(object):
|
||||
if self.registered:
|
||||
self.conshdl.detachsession(self)
|
||||
self.databuffer = None
|
||||
if self._evt:
|
||||
self._evt.send()
|
||||
self._evt = None
|
||||
self.reghdl = None
|
||||
|
||||
|
@ -406,10 +406,17 @@ def resourcehandler_backend(env, start_response):
|
||||
start_response('200 OK', headers)
|
||||
yield json.dumps({'session': querydict['session']})
|
||||
return # client has requests to send or receive, not both...
|
||||
elif 'closesession' in querydict:
|
||||
consolesessions[querydict['session']]['session'].destroy()
|
||||
del consolesessions[querydict['session']]
|
||||
start_response('200 OK', headers)
|
||||
yield '{"sessionclosed": true}'
|
||||
return
|
||||
else: # no keys, but a session, means it's hooking to receive data
|
||||
sessid = querydict['session']
|
||||
if sessid not in consolesessions:
|
||||
start_response('400 Expired Session', headers)
|
||||
yield ''
|
||||
return
|
||||
consolesessions[sessid]['expiry'] = time.time() + 90
|
||||
# add our thread to the 'inflight' to have a hook to terminate
|
||||
@ -424,6 +431,10 @@ def resourcehandler_backend(env, start_response):
|
||||
loggedout = ge
|
||||
httpsessions[authorized['sessionid']]['inflight'].discard(
|
||||
greenlet.getcurrent())
|
||||
if sessid not in consolesessions:
|
||||
start_response('400 Expired Session', headers)
|
||||
yield ''
|
||||
return
|
||||
if loggedout is not None:
|
||||
consolesessions[sessid]['session'].destroy()
|
||||
start_response('401 Logged out', headers)
|
||||
|
Loading…
x
Reference in New Issue
Block a user