예제 #1
0
def test_server(wsuri, wsuri2=None):

    dealer = Dealer()

    if wsuri2 is None:
        calculator = Calculator()
        dealer.register("http://myapp.com/", calculator)

    broker = Broker()

    class MyPubSubServerProtocol(WampServerProtocol):
        def onSessionOpen(self):
            self.setBroker(broker)
            self.setDealer(dealer)

    wampFactory = WampServerFactory(wsuri)
    wampFactory.protocol = MyPubSubServerProtocol
    listenWS(wampFactory)

    if wsuri2:

        class MyPubSubClientProtocol(WampClientProtocol):
            def onSessionOpen(self):
                self.setBroker(broker)
                self.setDealer(dealer)

        factory = WampClientFactory(wsuri2)
        factory.protocol = MyPubSubClientProtocol
        connectWS(factory)
예제 #2
0
        def onSessionOpen(self):

            print "Connected!"
            calculator = Calculator()

            dealer = Dealer()
            dealer.register("http://myapp2.com/", calculator)

            self.setDealer(dealer)