sorry, hit send too quick.
try this:
class SyslogPgAsyncListener(AsyncNotify):
def __init__(self, wsClientFactory):
self._wsClientFactory = wsClientFactory
def gotNotify(self, pid, notify):
if self._wsClientFactory._proto:
self._wsClientFactory._proto.sendMessage(...)
class SyslogViewerPgNotifer(WebSocketClientProtocol):
def onOpen(self):
self.factory._proto = self
...
def onClose(self, wasClean, code, reason):
self.factory._proto = None
factory._proto = None
Am 25.08.2014 15:13, schrieb Михаил Калинин:
> My code:
>
> |
> fromautobahn.twisted.websocket
> importWebSocketClientProtocol,WebSocketClientFactory
> fromtwisted.internet importdefer
> fromAsyncNotifyimportAsyncNotify
>
>
> classSyslogPgAsyncListener(AsyncNotify):
>
> defgotNotify(self,pid,notify):
>
> pglistener =SyslogPgAsyncListener(dsn)
> pglistener_run =pglistener.run()
> pglistener.addNotify('qweasd22')
>
> defonMessage(self,payload,isBinary):
> ifisBinary:
> print("Binary message received: {0} bytes".format(len(payload)))
> else:
> print("Text message received: {0}".format(payload.decode('utf8')))
>
> defonClose(self,wasClean,code,reason):
> print("WebSocket connection closed: {0}".format(reason))
>
>
>
> if__name__ =='__main__':
>
> importsys
>
> fromtwisted.python importlog
> fromtwisted.internet importreactor
>
> log.startLogging(sys.stdout)
>
> dsn ='...'
>