simplest python example: subscribe to channel and receive notification

#1

Hi,

I’m a complete newbie with crossbar.io and am a l

I’d like to write a very small python application.
It should just

  • connect to an existing crossbar server,
  • subscribe to a channel
  • receive a message

for testing I’d like to have another python application:

  • connect to an existing crossbar server
  • subscribe to a channel
  • send a message to that channel

I asume, that I need to use autobahn.asyncio for the application waiting for a callback, but wondered whether
just using the requests library could be enough.

For the code just sending information to a channel can work with requests only. right?

thanks in advance for any pointers.
I’ll updaet this post as I start learning

0 Likes

#2

I’m working with python 2.7.

It seems asyncio works only from python 3.4 onwards. so just replace asyncio with twisted in my previous post.

···

On Sunday, May 3, 2015 at 10:31:31 PM UTC+2, Gelonida Gel wrote:

Hi,

I’m a complete newbie with crossbar.io and am a l

I’d like to write a very small python application.
It should just

  • connect to an existing crossbar server,
  • subscribe to a channel
  • receive a message

for testing I’d like to have another python application:

  • connect to an existing crossbar server
  • subscribe to a channel
  • send a message to that channel

I asume, that I need to use autobahn.asyncio for the application waiting for a callback, but wondered whether
just using the requests library could be enough.

For the code just sending information to a channel can work with requests only. right?

thanks in advance for any pointers.
I’ll updaet this post as I start learning

0 Likes

#3

Having now

  • one crossbar node created with crossbar init --apdir mydir # using default template
  • can run this crossbar node and let it serve static ocntents
  • installed trollius for python 2.7

The best I found so far for stand-alone apps seems to be:
http://autobahn.ws/python/wamp/programming.html

However I had to change the
yield from statement in the example.
So instead of writing
rslt = yield from self.call(‘com.exanple.myadd’, 2, 3)
I had to write
rslt = yield from self.call(‘com.exanple.myadd’, 2, 3)
yield rslt

The code looks simple enough.
Is there anything I could still improve?

···

On Monday, May 4, 2015 at 8:17:55 AM UTC+2, Gelonida Gel wrote:

I’m working with python 2.7.

It seems asyncio works only from python 3.4 onwards. so just replace asyncio with twisted in my previous post.

On Sunday, May 3, 2015 at 10:31:31 PM UTC+2, Gelonida Gel wrote:

Hi,

I’m a complete newbie with crossbar.io and am a l

I’d like to write a very small python application.
It should just

  • connect to an existing crossbar server,
  • subscribe to a channel
  • receive a message

for testing I’d like to have another python application:

  • connect to an existing crossbar server
  • subscribe to a channel
  • send a message to that channel

I asume, that I need to use autobahn.asyncio for the application waiting for a callback, but wondered whether
just using the requests library could be enough.

For the code just sending information to a channel can work with requests only. right?

thanks in advance for any pointers.
I’ll updaet this post as I start learning

0 Likes

#4

Correction:
I meant:
So instead of writing
rslt = yield from self.call(‘com.exanple.myadd’, 2, 3)
I had to write
rslt = yield self.call(‘com.exanple.myadd’, 2, 3)
yield rslt

···

On Monday, May 4, 2015 at 10:47:42 AM UTC+2, Gelonida Gel wrote:

Having now

  • one crossbar node created with crossbar init --apdir mydir # using default template
  • can run this crossbar node and let it serve static ocntents
  • installed trollius for python 2.7

The best I found so far for stand-alone apps seems to be:
http://autobahn.ws/python/wamp/programming.html

However I had to change the
yield from statement in the example.
So instead of writing
rslt = yield from self.call(‘com.exanple.myadd’, 2, 3)
I had to write
rslt = yield from self.call(‘com.exanple.myadd’, 2, 3)
yield rslt

The code looks simple enough.
Is there anything I could still improve?

On Monday, May 4, 2015 at 8:17:55 AM UTC+2, Gelonida Gel wrote:

I’m working with python 2.7.

It seems asyncio works only from python 3.4 onwards. so just replace asyncio with twisted in my previous post.

On Sunday, May 3, 2015 at 10:31:31 PM UTC+2, Gelonida Gel wrote:

Hi,

I’m a complete newbie with crossbar.io and am a l

I’d like to write a very small python application.
It should just

  • connect to an existing crossbar server,
  • subscribe to a channel
  • receive a message

for testing I’d like to have another python application:

  • connect to an existing crossbar server
  • subscribe to a channel
  • send a message to that channel

I asume, that I need to use autobahn.asyncio for the application waiting for a callback, but wondered whether
just using the requests library could be enough.

For the code just sending information to a channel can work with requests only. right?

thanks in advance for any pointers.
I’ll updaet this post as I start learning

0 Likes