Jump to content

Remotely sending a message to web client


Damien Keraudren

Recommended Posts

Hi everyone,

I have an event listener running on my machine. Some action events trigger some python code running locally. I wanted to send a notification on ftrack after launching an action to say that the event was correctly received and was treated.
I tried to publish an event with the topic ftrack.action.trigger-user-interface. The event is sent but doesn't seem to be received. Is my code wrong, or this event can only be published inside an action and not remotely ?

def action_rooting(event):
    user_id = event['source']['user']['id']
    triggerInterface = ftrack_api.event.base.Event(topic='ftrack.action.trigger-user-interface',
                                                   data=dict(type='message', success=True, message='test message'), 
                                                   target='applicationId=ftrack.client.web and user.id="{0}"'.format(user_id))
    sessionFT.event_hub.publish(triggerInterface, on_error='raise')
    
sessionFT.event_hub.subscribe('topic=ftrack.action.launch', action_rooting)
sessionFT.event_hub.wait()

 

Link to comment
Share on other sites

Hi @Damien Keraudren
I have just tested the code and seems to be working fine the following:
 

import ftrack_api

session = ftrack_api.Session(
    auto_connect_event_hub=True
)

user = session.query(
    'User where username is "{}"'.format(
        session.api_user
    )
).first()

ui_event = ftrack_api.event.base.Event(
    topic='ftrack.action.trigger-user-interface',
    data=dict(
        type='message',
        success=True,
        message='A message to the user.'
    ),
    target='applicationId=ftrack.client.web and user.id="{}"'.format(
        user['id']
    )
)
session.event_hub.publish(ui_event)

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...