def test_JSCreation(self):
        Hub.constructJSFile()
        self.assertTrue(os.path.exists(JSClientFileGenerator.FILE_NAME))
        os.remove(JSClientFileGenerator.FILE_NAME)

        otherPath = "onTest"
        fullPath = os.path.join(otherPath, JSClientFileGenerator.FILE_NAME)
        Hub.constructJSFile(otherPath)
        self.assertTrue(os.path.exists(fullPath))
 def test_JAVACreation(self):
     path = "onTest"
     try:
         Hub.constructJAVAFile("test", path)
         self.assertTrue(os.path.exists(os.path.join(path, JAVAFileGenerator.SERVER_FILE_NAME)))
         self.assertTrue(os.path.exists(os.path.join(path, JAVAFileGenerator.CLIENT_PACKAGE_NAME)))
     finally:
         for f in listdir(path):
             fullPath = os.path.join(path, f)
             os.remove(fullPath) if os.path.isfile(fullPath) else shutil.rmtree(fullPath)
    def setUp(self):
        class TestHub(Hub):
            def getData(self):
                pass

        class TestHub2(Hub):
            def getData(self):
                pass

        Hub.initHubsInspection()
Beispiel #4
0
    def setUp(self):
        #Constucting hubs for testing
        class TestHub(Hub):
            def getData(self):
                pass

        class TestHub2(Hub):
            pass

        Hub.initHubsInspection()
    def test_PythonCreation(self):
        Hub.constructPythonFile()
        self.assertTrue(os.path.exists(PythonClientFileGenerator.FILE_NAME))
        self.assertTrue(os.path.exists("__init__.py"), "Check if python package is created")
        os.remove(PythonClientFileGenerator.FILE_NAME)

        otherPath = "onTest"
        fullPath = os.path.join(otherPath, PythonClientFileGenerator.FILE_NAME)
        packageFilePath = os.path.join(otherPath, "__init__.py")
        Hub.constructPythonFile(otherPath)
        self.assertTrue(os.path.exists(fullPath))
        self.assertTrue(os.path.exists(packageFilePath), "Check if python package is created")
Beispiel #6
0
def initServer():
    class BaseHub(Hub):
        def sendToAll(self, name, message):
            self.otherClients.onMessage(name,message)
            return len(self.otherClients)
        def timeout(self,timeout = 3):
            time.sleep(timeout)
            return True

    Hub.constructPythonFile("client")
    server = make_server('127.0.0.1', 9999, server_class=WSGIServer,
                         handler_class=WebSocketWSGIRequestHandler,
                         app=WebSocketWSGIApplication(handler_cls=ClientHandler))
    server.initialize_websockets_manager()
    server.serve_forever()
Beispiel #7
0
                    connections[id].client.close()
                    del connections[id]
                    return

            self.ID = self._commHandler.onOpen(id)
            clientType = "background" if self.isBackground else "client"
            log.info("open new %s with ID: %s " % (clientType, getUnicode(self.ID)))

    def on_close(self):
        clientType = "background" if self.isBackground else "client"
        log.info("%s closed %s" % (clientType, self._commHandler.__dict__.get("ID", "None")))
        self._commHandler.onClose()


app = web.Application([
    (r'/in', IndexHandler),
    (r'/upload', UploadHandler),
    (r'/(.*)', WAUClientHandler),
    (r'/(.*)/(.*)', WAUClientHandler),
], **settings)

if __name__ == '__main__':
    importlib.import_module("Hubs.Hubs")
    Hub.initHubsInspection()
    Hub.constructJSFile("C:/Software Projects/ionicWAU/www/dependencies")
    Hub.constructPythonFile("DummyClient")
    # Hub.constructJAVAFile("com.application.jorge.whereappu.WebSocket","C:/Software Projects/WhereAppU/app/src/main/java/com/application/jorge/whereappu/WebSocket")
    log.debug("starting...")
    app.listen(8845)
    ioloop.IOLoop.instance().start()
Beispiel #8
0
import importlib
import os
import logging
import logging.config
import json

from tornado import web, ioloop

from wshubsapi.Hub import Hub
from wshubsapi.ConnectionHandlers.Tornado import ClientHandler

logging.config.dictConfig(json.load(open('logging.json')))
log = logging.getLogger(__name__)

settings = {"static_path": os.path.join(os.path.dirname(__file__), "../Clients/_static"), }

app = web.Application([
    (r'/(.*)', ClientHandler),
], **settings)

if __name__ == '__main__':
    importlib.import_module("ChatHub")  # necessary to add this import for code inspection

    Hub.constructJSFile(settings["static_path"])
    Hub.constructPythonFile(settings["static_path"])
    log.debug("starting...")
    app.listen(8888)

    ioloop.IOLoop.instance().start()
Beispiel #9
0
import importlib
import json
import logging
import logging.config
from wshubsapi.ConnectionHandlers.WS4Py import ClientHandler
from wsgiref.simple_server import make_server
from ws4py.server.wsgirefserver import WSGIServer, WebSocketWSGIRequestHandler
from wshubsapi.Hub import Hub
from ws4py.server.wsgiutils import WebSocketWSGIApplication

logging.config.dictConfig(json.load(open('logging.json')))
log = logging.getLogger(__name__)

if __name__ == '__main__':
    importlib.import_module("ChatHub")  # necessary to add this import for code inspection
    # construct the necessary client files in the specified path
    Hub.constructPythonFile("../Clients/_static")
    Hub.constructJSFile("../Clients/_static")
    # Hub.constructJAVAFile("tornado.WSHubsApi", "../Clients/_static")

    server = make_server('127.0.0.1', 8888, server_class=WSGIServer,
                         handler_class=WebSocketWSGIRequestHandler,
                         app=WebSocketWSGIApplication(handler_cls=ClientHandler))
    server.initialize_websockets_manager()
    log.debug("starting...")
    target = server.serve_forever()