title: Using the Decorator approach with AutobahnWS, how to publish messages independent from subscription callbacks and it's Session-Reference?
body: <p>When working with Autobahn and WAMP before I have been using the Subclassing-Approach but stumbled over decorator / functions approach which I really prefer over subclassing.</p>
  
  <p>However. I have a function that is being called from an external hardware (via callback) and this function needs to publish to Crossbar.io Router whenever it is being called.</p>
  
  <p>This is how I've done this, keeping a reference of the <code>Session</code> right after the <code>on_join -&gt; async def joined(session, details)</code> was called.</p>
  
  <pre><code>from autobahn.asyncio.component import Component
  from autobahn.asyncio.component import run
  
  global_session = None
  
  comp = Component(
      transports=u"ws://localhost:8080/ws",
      realm=u"realm1",
  )
  
  def callback_from_hardware(msg):
      if global_session is None:
          return
      global_session.publish(u'com.someapp.somechannel', msg)
  
  @comp.on_join
  async def joined(session, details):
      global global_session
      global_session = session
      print("session ready")
  
  if __name__ == "__main__":
      run([comp])
  </code></pre>
  
  <p>This approach of keeping a reference after component has joined connection feels however a bit "odd". Is there a different approach to this? Can this done on some other way.</p>
  
  <p>If not than it feels a bit more "right" with subclassing and having all the application depended code within that subclass (but however keeping everything of my app within one subclass also feels odd).</p>