def client_end(request, socket, context):
 for channel in socket.channels:
  events.on_unsubscribe.send(request, socket, context, channel)
 events.on_finish.send(request, socket, context)
 for channel in socket.channels[:]:
  socket.unsubscribe(channel)
 del CLIENTS[socket.session.session_id]

def client_end ( request , socket , context ) : for channel in socket . channels : events . on_unsubscribe . send ( request , socket , context , channel ) events . on_finish . send ( request , socket , context ) for channel in socket . channels [ : ] : socket . unsubscribe ( channel ) del CLIENTS [ socket . session . session_id ]
handles cleanup when a session ends for the given client triple .