nextpyp.client.gen.RealtimeServices#
- class nextpyp.client.gen.RealtimeServices#
Bases:
objectAll of the different realtime services that can be accessed by the NextPYP client
Realtime services exchange messages with the NextPYP website, rather than perform function calls, like regular services. The message exchange format lets the client send a message to the website and then wait for any number of different responses which can all arrive different times. In effect, this kind of connection lets the client stream data back from the website as soon as it’s ready.
Realtime services use Python’s asyncio system over a HTTP WebSocket connection to send and receive messages to/from the website. This technique results in a lower event latency than more traditional connection polling techniques, and can be more efficient with network resources as well.
Realtime services are different from regular services. To learn more about regular services, see
Services.Examples
Call a realtime service:
async with client.realtime_services.project as project: await project.send_listen_to_project(RealTimeC2SListenToProject( user_id='user_id', project_id='project_id' )) msg = await project.recv() if type(msg) is RealTimeS2CProjectStatus: print(f'project status: {msg}') else: print(f'received other msg: {msg}')
Methods
Attributes
The Project realtime service, see
ProjectRealtimeServiceConnectionThe SingleParticleSession realtime service, see
SingleParticleSessionRealtimeServiceConnectionThe TomographySession realtime service, see
TomographySessionRealtimeServiceConnectionDetails
-
project:
RealtimeService[ProjectRealtimeServiceConnection]# The Project realtime service, see
ProjectRealtimeServiceConnection
-
single_particle_session:
RealtimeService[SingleParticleSessionRealtimeServiceConnection]# The SingleParticleSession realtime service, see
SingleParticleSessionRealtimeServiceConnection
-
tomography_session:
RealtimeService[TomographySessionRealtimeServiceConnection]# The TomographySession realtime service, see
TomographySessionRealtimeServiceConnection
-
project: