from firefly_client import FireflyClient
#import astropy.utils.data
# This test can be modified to make multiple firefly_clients to prove there is only 1 per channel
lsst_demo_host = 'https://lsst-demo.ncsa.illinois.edu/firefly'
local_host = 'http://127.0.0.1:8080/firefly'
host = local_host
channel1 = 'channel-test-1'
channel2 = 'channel-test-2'
channel3 = 'channel-test-3'
fc1_c1 = FireflyClient.make_client(host, channel_override=channel1, launch_browser=True)
fc1_c1.show_fits(url="http://web.ipac.caltech.edu.s3-us-west-2.amazonaws.com/staff/roby/demo/wise-00.fits")
{'success': True}
# Extensions can be made but there is not web socket connections until a listener is added
fc1_c1.add_extension(ext_type='LINE_SELECT', title='a line')
fc1_c1.add_extension(ext_type='AREA_SELECT', title='a area')
fc1_c1.add_extension(ext_type='POINT', title='a point')
{'success': True}
# A Web socket should not be made until this cell is added
def listener1(ev):
print('l1')
print(ev)
fc1_c1.add_listener(listener1)
l1 {'data': {'payload': {'channel-test-1': ['1e', '2b', '2d']}, 'type': 'app_data.wsConnUpdated'}, 'scope': 'SELF', 'dataType': 'JSON', 'name': 'FLUX_ACTION', 'from': '-1'}
# does not close the web socket, since it might be shared
fc1_c1.remove_listener(listener1)
# this will actually disconnect the web socket, any other client in this python instance will lose their connection as well
fc1_c1.disconnect()