Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import time
- import logging
- from twisted.internet import reactor
- from autobahn.websocket import WebSocketClientFactory, \
- WebSocketClientProtocol, \
- connectWS
- from twisted.internet import inotify
- from twisted.python import filepath
- class connection :
- def __init__(self):
- factory = WebSocketClientFactory("ws://localhost:8888/ws", debug=False)
- factory.protocol = self.webSocket
- connectWS(factory)
- notifier = inotify.INotify()
- notifier.startReading()
- notifier.watch(filepath.FilePath("/home/amanush"), callbacks=[self.webSocket.notify])
- def retrievePrivateKey (self):
- return True
- def retrievePublicKey (self):
- return True
- class webSocket(WebSocketClientProtocol):
- def sendHello(self):
- pass
- def onOpen(self):
- self.sendHello()
- def onMessage(self, msg, binary):
- print "Got echo: " + msg
- reactor.callLater(1, self.sendHello)
- def notify(ignore, filepath, mask):
- print "CALLBACK"
- #print "event %s on %s" % (', '.join(inotify.humanReadableMask(mask)), filepath)
- if __name__ == '__main__':
- conn = connection()
- reactor.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement