text: #
  #  Copyright (C) BlueWave Studio - All Rights Reserved
  #
  
  import common.Api_pb2 as oap_api
  from common.Client import Client, ClientEventHandler
  
  
  class EventHandler(ClientEventHandler):
  
      def on_hello_response(self, client, message):
          print(
              "received hello response, result: {}, oap version: {}.{}, api version: {}.{}"
              .format(message.result, message.oap_version.major,
                      message.oap_version.minor, message.api_version.major,
                      message.api_version.minor))
  
          set_status_subscriptions = oap_api.SetStatusSubscriptions()
          set_status_subscriptions.subscriptions.append(
              oap_api.SetStatusSubscriptions.Subscription.PROJECTION)
          client.send(oap_api.MESSAGE_SET_STATUS_SUBSCRIPTIONS, 0,
                      set_status_subscriptions.SerializeToString())
  
      def on_projection_status(self, client, message):
          print("projection status, state: {}, source: {}".format(
              message.state, message.source))
  
  
  def main():
      client = Client("projection status example")
      event_handler = EventHandler()
      client.set_event_handler(event_handler)
      client.connect('127.0.0.1', 44405)
  
      active = True
      while active:
          try:
              active = client.wait_for_message()
          except KeyboardInterrupt:
              break
  
      client.disconnect()
  
  
  if __name__ == "__main__":
      main()
  