Access WebSocketClientFactory from WebSocketClientFactory

#1

Is this possible to access the WebSocketClientFactory sub class method from WebSocketClientProtocol sub class.

I tried self.factory but not working. I need to call a method define in WebSocketClientFactory sub class from WebSocketClientProtocol sub class.

Thanks,

Chuck

0 Likes

#2

Is this possible to access the WebSocketClientFactory sub class method
from WebSocketClientProtocol sub class.

I tried self.factory but not working. I need to call a method define in
WebSocketClientFactory sub class from WebSocketClientProtocol sub class.

sure. make sure you call the base constructor in your derived class and/or implement buildProtocol correctly (setting protocol.factory to factory)

https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/broadcast/server.py#L39

Cheers
/Tobias

···

Am 14.03.2014 21:27, schrieb Chuck James:

Thanks,
Chuck

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com
<mailto:autobahnws+...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#3

Thanks for reply Tobias.

The example you gave me it’s server (listen) example. And I am using self.factory in serverProtocol sub class. But not able to call (throwing errors) self.factory from WebSocketClientProtocol sub class.

Check this example: https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/broadcast/client.py
In the following example, I want to call WebSocketClientFactory method from sendHello method of BroadcastClientProtocol class.

Getting following Error: ProtocolManager instance has no attribute ‘factory’
ProtocolManager is the subclass of WebSocketClientProtocol.

Thanks,
Chuck

···

On Friday, March 14, 2014 4:30:40 PM UTC-4, Tobias Oberstein wrote:

Am 14.03.2014 21:27, schrieb Chuck James:

Is this possible to access the WebSocketClientFactory sub class method

from WebSocketClientProtocol sub class.

I tried self.factory but not working. I need to call a method define in

WebSocketClientFactory sub class from WebSocketClientProtocol sub class.

sure. make sure you call the base constructor in your derived class
and/or implement buildProtocol correctly (setting protocol.factory to
factory)

https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/broadcast/server.py#L39

Cheers

/Tobias

Thanks,

Chuck

You received this message because you are subscribed to the Google

Groups “Autobahn” group.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#4

Oops sorry for silly mistake. Figure it out already:

So I was check self.factory.somemethod at init method of WebSocketClientProtocol sub class. And it was throwing given error. But it’s fine and accessible from and after onConnect methods.

Sorry for confusion.

Thanks Tobias and sorry for waste your time :).

Chuck.

···

On Friday, March 14, 2014 5:13:40 PM UTC-4, Chuck James wrote:

Thanks for reply Tobias.

The example you gave me it’s server (listen) example. And I am using self.factory in serverProtocol sub class. But not able to call (throwing errors) self.factory from WebSocketClientProtocol sub class.

Check this example: https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/broadcast/client.py
In the following example, I want to call WebSocketClientFactory method from sendHello method of BroadcastClientProtocol class.

Getting following Error: ProtocolManager instance has no attribute ‘factory’
ProtocolManager is the subclass of WebSocketClientProtocol.

Thanks,
Chuck

On Friday, March 14, 2014 4:30:40 PM UTC-4, Tobias Oberstein wrote:

Am 14.03.2014 21:27, schrieb Chuck James:

Is this possible to access the WebSocketClientFactory sub class method

from WebSocketClientProtocol sub class.

I tried self.factory but not working. I need to call a method define in

WebSocketClientFactory sub class from WebSocketClientProtocol sub class.

sure. make sure you call the base constructor in your derived class
and/or implement buildProtocol correctly (setting protocol.factory to
factory)

https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/websocket/broadcast/server.py#L39

Cheers

/Tobias

Thanks,

Chuck

You received this message because you are subscribed to the Google

Groups “Autobahn” group.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#5

Chuck,

Oops sorry for silly mistake. Figure it out already:

So I was check self.factory.somemethod at __init__ method
of WebSocketClientProtocol sub class. And it was throwing given error.
But it's fine and accessible from and after onConnect methods.

Great it works for you now ..

Sorry for confusion.

Thanks Tobias and sorry for waste your time :).

No problem;)

Tobias

···

Am 14.03.2014 22:26, schrieb Chuck James:

0 Likes