Esempio n. 1
0
 def test_invalid_type_key(self):
     with self.assertRaises(ValueError) as ctx:
         Component(transports=[{
             "type": "bad",
         }])
     self.assertIn("Invalid transport type", str(ctx.exception))
from twisted.internet.defer import inlineCallbacks
from autobahn.twisted.component import Component, run
from autobahn.twisted.util import sleep
from autobahn.wamp.types import PublishOptions

comp = Component(
    transports=[
        {
            "type": "websocket",
            "url": "ws://localhost:8443/ws",
            "endpoint": {
                "type": "tcp",
                "host": "localhost",
                "port": 8443,
            },
            "serializers": ["json", "cbor"],
        },
    ],
    realm="realm1",
)


@comp.on_join
@inlineCallbacks
def _(session, details):
    print("joined: {}".format(session))
    topic_name = u"io.crossbar.demo.public.foo"

    while session.is_connected():
        print("publish to '{}'".format(topic_name))
        session.publish(
Esempio n. 3
0
component = Component(
    # you can configure multiple transports; here we use two different
    # transports which both exist in the demo router
    transports=[
        {
            u"type": u"websocket",
            u"url": u"ws://localhost:8080/auth_ws",
            u"endpoint": {
                u"type": u"tcp",
                u"host": u"localhost",
                u"port": 8080,
            },
            # you can set various websocket options here if you want
            u"options": {
                u"open_handshake_timeout": 100,
            }
        },
    ],
    # authentication can also be configured (this will only work on
    # the demo router on the first transport above)
    authentication={
        u"cryptosign": {
            u'authid':
            u'alice',
            # this key should be loaded from disk, database etc never burned into code like this...
            u'privkey':
            '6e3a302aa67d55ffc2059efeb5cf679470b37a26ae9ac18693b56ea3d0cd331c',
        }
    },
    # must provide a realm
    realm=u"crossbardemo",
)
Esempio n. 4
0
    options = optionsForClientTLS(
        hostname=u'localhost',
        trustRoot=cert,
    )

component = Component(
    transports=[
        {
            u"type": u"websocket",
            u"url": u"ws://localhost:8080/ws",
            u"endpoint": {
                u"type": u"tcp",
                u"host": u"localhost",
                u"port": 8080,
#                "tls": options,
#                "tls": {
#                    u"hostname": u"localhost",
#                    u"trust_root": cert_fname,
#                },
            },
            u"options": {
                u"open_handshake_timeout": 100,
            }
        },
    ],
    realm=u"crossbardemo",
)


@component.on_join
def join(session, details):
    print("joined {}: {}".format(session, details))
Esempio n. 5
0
        def test_successful_connect(self, fake_sleep):
            endpoint = Mock()
            joins = []

            def joined(session, details):
                joins.append((session, details))
                return session.leave()

            directlyProvides(endpoint, IStreamClientEndpoint)
            component = Component(
                transports={
                    "type": "websocket",
                    "url": "ws://127.0.0.1/ws",
                    "endpoint": endpoint,
                })
            component.on('join', joined)

            def connect(factory, **kw):
                proto = factory.buildProtocol('boom')
                proto.makeConnection(Mock())

                from autobahn.websocket.protocol import WebSocketProtocol
                from base64 import b64encode
                from hashlib import sha1
                key = proto.websocket_key + WebSocketProtocol._WS_MAGIC
                proto.data = (b"HTTP/1.1 101 Switching Protocols\x0d\x0a"
                              b"Upgrade: websocket\x0d\x0a"
                              b"Connection: upgrade\x0d\x0a"
                              b"Sec-Websocket-Protocol: wamp.2.json\x0d\x0a"
                              b"Sec-Websocket-Accept: " +
                              b64encode(sha1(key).digest()) +
                              b"\x0d\x0a\x0d\x0a")
                proto.processHandshake()

                from autobahn.wamp import role
                features = role.RoleBrokerFeatures(
                    publisher_identification=True,
                    pattern_based_subscription=True,
                    session_meta_api=True,
                    subscription_meta_api=True,
                    subscriber_blackwhite_listing=True,
                    publisher_exclusion=True,
                    subscription_revocation=True,
                    payload_transparency=True,
                    payload_encryption_cryptobox=True,
                )

                msg = Welcome(123456, dict(broker=features), realm=u'realm')
                serializer = JsonSerializer()
                data, is_binary = serializer.serialize(msg)
                proto.onMessage(data, is_binary)

                msg = Goodbye()
                proto.onMessage(*serializer.serialize(msg))
                proto.onClose(True, 100, "some old reason")

                return succeed(proto)

            endpoint.connect = connect

            # XXX it would actually be nicer if we *could* support
            # passing a reactor in here, but the _batched_timer =
            # make_batched_timer() stuff (slash txaio in general)
            # makes this "hard".
            reactor = Clock()
            with replace_loop(reactor):
                yield component.start(reactor=reactor)
                self.assertTrue(len(joins), 1)
                # make sure we fire all our time-outs
                reactor.advance(3600)
Esempio n. 6
0
        res = yield session.register(
            lambda: None,
            u"prefix.fail.",
            options=RegisterOptions(match=u'prefix'),
        )
        print("\n\nshould have failed\n\n")
    except ApplicationError as e:
        print("prefix-match 'prefix.fail.' failed as expected: {}".format(
            e.error))

    print("calling 'example.foo'")
    res = yield session.call(u"example.foo")
    print("example.foo() = {}".format(res))

    print("done")


component = Component(transports=u"ws://localhost:8080/auth_ws",
                      main=main,
                      realm=u"crossbardemo",
                      authentication={
                          u"wampcra": {
                              u"authid": u"bob",
                              u"authrole": u"dynamic_authed",
                              u"secret": u"p4ssw0rd",
                          }
                      })

if __name__ == "__main__":
    run([component])
Esempio n. 7
0
DEFAULT_AUTHID = 'team4'
DEFAULT_TICKET = 'knife23 fork spoon cutlery'

TOPIC = 'com.conti.hackathon.team4.backend'
SERVICE_NAME = 'simple seller python example service'
SERVICE_TYPE = 'backend'

display_component = Component(transports=os.environ.get(
    'XBR_INSTANCE', 'wss://continental2.crossbario.com/ws'),
                              realm=os.environ.get('XBR_REALM', 'realm1'),
                              authentication={
                                  'ticket': {
                                      'authid':
                                      os.environ.get('XBR_AUTHID',
                                                     DEFAULT_AUTHID),
                                      'ticket':
                                      os.environ.get('XBR_TICKET',
                                                     DEFAULT_TICKET),
                                      'authextra': {
                                          'service_name': SERVICE_NAME,
                                          'type': SERVICE_TYPE,
                                      },
                                  },
                              })


@display_component.on_join
async def joined(session, _details):
    data = None

    def get_distance():
                        help='Optional service name.')

    parser.add_argument('--service_uuid',
                        dest='service_uuid',
                        type=six.text_type,
                        default=None,
                        help='Optional service UUID.')

    args = parser.parse_args()

    log_level = 'debug' if args.debug else 'info'

    # any extra info we want to forward to our ClientSession (in self.config.extra)
    extra = {
        u'service_name': args.service_name or "default",
        u'service_uuid': args.service_uuid,
    }
    client = Component(transports=args.url,
                       realm=args.realm,
                       main=main,
                       extra=extra,
                       authentication={
                           "anonymous": {
                               "authrole": "anonymous",
                           },
                       })

    # starts the reactor, and logging -- this won't return unless all
    # our components complete
    run([client])
Esempio n. 9
0
"""

import sys
import codecs

from autobahn.twisted.component import Component
from autobahn.twisted.component import run
from autobahn.wamp.exception import ApplicationError
from twisted.internet.defer import inlineCallbacks

if len(sys.argv) < 4:
    print("Usage: eas-populate-room.py SERVER GDTFILE ROOM")
    sys.exit(1)

easclient = Component(
    transports=u"ws://%s/ws" % (sys.argv[1]),
    realm=u"eas",
)

infos = {}
room = sys.argv[3]


@easclient.on_join
@inlineCallbacks
def join(session, details):
    print("Joined session")
    try:
        if not 'dowhat' in infos or infos["dowhat"] == "CALL":
            res = yield session.call(u'com.eas.populate_room', room,
                                     infos["id"], infos["name"],
                                     infos["surname"], infos["title"])
Esempio n. 10
0
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""

from os import environ

from autobahn.twisted.component import Component
from autobahn.twisted.component import run
from autobahn.wamp.exception import ApplicationError
from autobahn.wamp.types import CallResult
from peewee import SqliteDatabase, Model, CharField, ForeignKeyField, IntegerField, DoesNotExist, IntegrityError, JOIN

eascomp = Component(
    transports=u"ws://localhost:8080/ws",
    realm=u"eas",
)

db = SqliteDatabase("eas.db", pragmas={'foreign_keys': 1})
mySession = None

wcOccupied = False


class BaseModel(Model):
    class Meta:
        database = db


"""
Implementation of a patient
Esempio n. 11
0
TOPIC = 'io.crossbar.example'
SERVICE_NAME = 'simple buyer python example service'
SERVICE_TYPE = 'buyer'

comp = Component(
    transports=os.environ.get('XBR_INSTANCE',
                              'wss://continental2.crossbario.com/ws'),
    realm=os.environ.get('XBR_REALM', 'realm1'),
    authentication={
        'ticket': {
            'authid': os.environ.get('XBR_AUTHID', DEFAULT_AUTHID),
            'ticket': os.environ.get('XBR_TICKET', DEFAULT_TICKET),
            'authextra': {
                'service_name': SERVICE_NAME,
                'type': SERVICE_TYPE,
            },
        },
    },
    extra={
        'market_maker_adr':
        os.environ.get('XBR_MARKET_MAKER_ADR',
                       '0x3e5e9111ae8eb78fe1cc3bb8915d5d461f3ef9a9'),
        'buyer_privkey':
        os.environ.get(
            'XBR_BUYER_PRIVKEY',
            '0x2d48f8f2f25d6c2f2e76e8337c6d9ef9e0aecdd198eaf61d7f3b831ae1652d75'
        ),
    })


@comp.on_join
async def joined(session, details):
Esempio n. 12
0
        #     counter += 1
        #     yield sleep(1)

    def onLeave(self, details):
        print("Client session left: {}".format(details))
        self.disconnect()

    def onDisconnect(self):
        print("Client session disconnected.")


def callback(arg):
    print("Started NotificationService WAMP Client", arg)


component = Component()


class NotificationService(ApplicationSession):

    # def start(self):
    #     self._runner = ApplicationRunner(url=u'ws://localhost:8080/ws',
    #                                      realm=u"realm1",
    #                                      extra=dict(parent=self))
    #     self._runner.run(WampClientSession, log_level='info')

    def __init__(self):
        @run_in_reactor
        def start_wamp():
            # self.wapp = Application()
            self._runner = ApplicationRunner(url=u'ws://localhost:8080/ws',
Esempio n. 13
0
import txaio
txaio.use_twisted()


DEFAULT_AUTHID = 'team1'
DEFAULT_TICKET = 'apple pear orange fig'

comp = Component(
    transports=os.environ.get(
        'XBR_INSTANCE', 'wss://continental2.crossbario.com/ws'),
    realm=os.environ.get('XBR_REALM', 'realm1'),
    authentication={
        'ticket': {
            'authid': os.environ.get('XBR_AUTHID', DEFAULT_AUTHID),
            'ticket': os.environ.get('XBR_TICKET', DEFAULT_TICKET),
        },
    },
    extra={
        'market_maker_adr': os.environ.get('XBR_MARKET_MAKER_ADR', '0x3e5e9111ae8eb78fe1cc3bb8915d5d461f3ef9a9'),
        'buyer_privkey': os.environ.get('XBR_BUYER_PRIVKEY', '0x16A60CED74B0D0523567B2261CF3E1C41048036D291D7132BF353E10B74F817A'),
    }
)


@comp.on_join
async def joined(session, details):
    print('Buyer session joined', details)

    market_maker_adr = binascii.a2b_hex(
        session.config.extra['market_maker_adr'][2:])
Esempio n. 14
0
    A first component, which gets called "setup-like". When
    it returns, this signals that the component is ready for work.
    """
    # expose the API on the session
    yield session.expose(api)


@coroutine
def component2(reactor, session):
    """
    A second component, which gets called "main-like".
    When it returns, this will automatically close the session.
    """
    result = yield session.call('com.example.add2', 2, 3)
    session.publish('com.example.on-hello', 'result={}'.format(result))


if __name__ == '__main__':
    from autobahn.twisted.component import Component, run

    # Components wrap either a setup or main function and
    # can be configured with transports, authentication and so on.
    components = [
        Component(setup=component1),
        Component(main=component2)
    ]

    # a convenience runner is provided which takes a list of
    # components and runs all of them
    run(components)
def create_component(args, extra):

    log = txaio.make_logger()

    # 'transports' can also be a list of dicts containing more
    # detailed connection information (and multiple ways to connect)
    client = Component(
        transports=args.url,
        realm=args.realm,
        extra=extra,
        authentication={
            "anonymous": {
                "authrole": "anonymous",
            },
        }
    )

    info = {
        "ident": "unknown",
        "type": "Python",
    }

    @client.on_connect
    def connected(session, x):
        log.info("Client connected: {klass}, {extra}", klass=session.__class__, extra=session.config.extra)

    @client.on_join
    @inlineCallbacks
    def joined(session, details):
        log.info("Joined: {details}", details=details)

        info["ident"] = details.authid

        log.info("Component ID is  {ident}", **info)
        log.info("Component type is  {type}", **info)

        # this could go in a "main" procedure to be passed to
        # Component, declared as "def main(reactor, session):" and
        # passed to Component() via "main="
        x = 0
        counter = 0
        while True:

            # CALL
            try:
                res = yield session.call(u'com.example.add2', x, 3)
                print('----------------------------')
                log.info("add2 result: {result}", result=res[0])
                log.info("from component {id} ({type})", id=res[1], type=res[2])
                x += 1
            except ApplicationError as e:
                # ignore errors due to the frontend not yet having
                # registered the procedure we would like to call
                if e.error != 'wamp.error.no_such_procedure':
                    raise e

            # PUBLISH
            yield session.publish(u'com.example.oncounter', counter, info["ident"], info["type"])
            print('----------------------------')
            log.info("published to 'oncounter' with counter {counter}",
                     counter=counter)
            counter += 1

            yield sleep(2)  # note this is an "async sleep" using callLater()

    @client.register(
        "com.example.add2",
        options=RegisterOptions(invoke=u'roundrobin'),
    )
    def add2(a, b):
        print('----------------------------')
        print("add2 called on {}".format(info["ident"]))
        return [ a + b, info["ident"], info["type"]]


    @client.subscribe("com.example.oncounter")
    def oncounter(counter, ident, kind):
        print('----------------------------')
        log.info("'oncounter' event, counter value: {counter}", counter=counter)
        log.info("from component {ident} ({kind})", ident=ident, kind=kind)

    @client.on_leave
    def left(session, details):
        log.info("session left: {}".format(details))

    return client
Esempio n. 16
0
from autobahn.twisted.component import Component, run
from autobahn.wamp.types import RegisterOptions
from autobahn.wamp.exception import ApplicationError
from twisted.internet.defer import inlineCallbacks

component = Component(transports=u"ws://localhost:8080/auth_ws",
                      realm=u"crossbardemo",
                      authentication={
                          u"scram": {
                              u"authid": u"carol",
                              u"authrole": u"authenticated",
                              u"password": u"p4ssw0rd",
                              u"kdf": u"argon2id13",
                          }
                      })


@component.on_join
def joined(session, details):
    print("Session joined: {}".format(details))


if __name__ == "__main__":
    run([component])  #, log_level='debug')
Esempio n. 17
0
from twisted.web.http import Request
from typing import Optional

from common.compat import Machine, MachineDict
from models import GameState

# this is mostly working, just needs cleanup

PREFIX = "com.lambentri.edge.la4.extservices.gsi.csgo"
SRC_PREFIX = "com.lambentri.edge.la4.machine.link.src."

LEDS_IN_ARRAY_DEFAULT = int(os.environ.get("LA4_GSI_LEDS", 256))

##
wamp_component = Component(
    transports=os.environ.get("LA4_XBAR_ROUTER", "ws://127.0.0.1:8083/ws"),
    realm=os.environ.get("LA4_XBAR_REALM", "realm1"),
)
wamp_component.state: Optional[GameState] = None
wamp_component.count = 0


@inlineCallbacks
def publish_gsi(session):
    if wamp_component.state:
        options = PublishOptions(retain=True)
        # yield session.publish(
        #     f"{SRC_PREFIX}ltri-csgo-gsi-de",
        #     []],
        #     id="ltri-csgo-gsi-de",
        #     options=options)
        yield session.publish(f"{SRC_PREFIX}ltri-csgo-gsi-health",
Esempio n. 18
0
 def test_no_url(self):
     with self.assertRaises(ValueError) as ctx:
         Component(transports=[{
             "type": "websocket",
         }])
     self.assertIn("Transport requires 'url'", str(ctx.exception))
Esempio n. 19
0
from __future__ import print_function

from autobahn.twisted.component import Component, run
from autobahn.wamp import cryptosign
import binascii

privkey_hex = '6e3a302aa67d55ffc2059efeb5cf679470b37a26ae9ac18693b56ea3d0cd331c'
# pubkey: 020b13239ca0f10a1c65feaf26e8dfca6e84c81d2509a2b7b75a7e5ee5ce4b66

component = Component(transports=u'ws://localhost:8080/auth_ws',
                      realm=u'crossbardemo',
                      authentication={
                          u"wampcra": {
                              "authid": u"username",
                              "secret": u"p4ssw0rd",
                          }
                      })


@component.on_join
def join(session, details):
    print("Session {} joined: {}".format(details.session, details))


if __name__ == '__main__':
    run(component)
Esempio n. 20
0
from autobahn.wamp.types import RegisterOptions
from autobahn.wamp.exception import ApplicationError
from twisted.internet.defer import inlineCallbacks, CancelledError


@inlineCallbacks
def main(reactor, session):
    print("Client session={}".format(session))
    d = session.call(u"example.foo", "some", "args")
    print("Called 'example.foo': {}".format(d))
    print("cancel()-ing the above Deferred")

    d.cancel()

    try:
        res = yield d
        print("somehow we got a result: {}".format(res))
    except CancelledError:
        print("call was canceled successfully")
    print("done")


component = Component(
    transports=u"ws://localhost:8080/auth_ws",
    main=main,
    realm=u"crossbardemo",
)

if __name__ == "__main__":
    run([component])  #, log_level='debug')
    reactor.callLater(2, session.leave)


@inlineCallbacks
def setup_bob(reactor, session):
    print('bob created', session)

    def on_join(session, details):
        print('bob joined', session, details)

    session.on('join', on_join)
    yield sleep(1)
    print("bob done sleeping")


#    session.leave()

if __name__ == '__main__':
    transports = [{"type": "websocket", "url": "ws://127.0.0.1:8080/ws"}]

    component1 = Component(on_join=setup_alice,
                           transports=transports,
                           realm='crossbardemo')
    component2 = Component(main=setup_bob,
                           transports=transports,
                           realm='crossbardemo')
    #run([component1, component2], log_level='debug')
    #run([component1, component2], log_level='info')
    run([component1], log_level='info')
    #run([component2], log_level='info')
Esempio n. 22
0
    else:
        sock_dir = os.path.join(os.path.expandvars('$SNAP_COMMON'), 'deskconn-sock-dir')

    sock_path = os.path.join(sock_dir, 'deskconnd.sock')
    if not os.path.exists(sock_path):
        print("deskconnd not found, please make sure its installed and running.")
        sys.exit(1)

    transport = {
        "type": "rawsocket",
        "url": "ws://localhost/ws",
        "endpoint": UNIXClientEndpoint(reactor, sock_path),
        "serializer": "cbor",
    }

    component = Component(transports=[transport], realm="deskconn")

    @component.on_join
    async def joined(session, _details):
        if args.state == 'on':
            procedure = 'org.deskconn.piconn.gpio.set_out_high'
        else:
            procedure = 'org.deskconn.piconn.gpio.set_out_low'

        try:
            await session.call(procedure, args.pin)
        except ApplicationError as e:
            print(e)
            pass
        finally:
            session.leave()
Esempio n. 23
0
parser = argparse.ArgumentParser()
parser.add_argument("server_ip", help="IP address of the WAMP server")
parser.add_argument("player_id", help="Player's unique nickname")
parser.add_argument('--logic',
                    metavar='logic_function',
                    type=str,
                    default="example",
                    help="logic function name (without .py)")
args = parser.parse_args()

component = Component(
    transports=[{
        "type": "websocket",
        "url": u"ws://{}:8080/ws".format(args.server_ip),
        "options": {
            "open_handshake_timeout": 60.0,
        }
    }],
    realm=u'realm1',
)


@component.on_join
@inlineCallbacks
def join(self, details):

    logged_in = False

    while not logged_in:
        try:
            # login to gameserver
from autobahn.twisted.component import Component, run
from autobahn.twisted.util import sleep
from twisted.internet.defer import inlineCallbacks
import os
import argparse
import six
import datetime

url = os.environ.get('CBURL', u'ws://localhost:8080/ws')
realmv = os.environ.get('CBREALM', u'realm1')
print(url, realmv)
component = Component(transports=url, realm=realmv)


@component.on_join
@inlineCallbacks
def joined(session, details):
    print("session ready")
    try:
        res = yield session.call(u'com.myapp.date')
        print("\ncall result: {}\n".format(res))
    except Exception as e:
        print("call error: {0}".format(e))
    yield session.leave()


if __name__ == "__main__":
    run([component])
from autobahn.twisted.util import sleep
from autobahn.twisted.xbr import SimpleSeller

DEFAULT_AUTHID = 'team2'
DEFAULT_TICKET = 'cabbage peas onion eggplant'

comp = Component(
    transports=os.environ.get('XBR_INSTANCE',
                              'wss://continental2.crossbario.com/ws'),
    realm=os.environ.get('XBR_REALM', 'realm1'),
    authentication={
        'ticket': {
            'authid': os.environ.get('XBR_AUTHID', DEFAULT_AUTHID),
            'ticket': os.environ.get('XBR_TICKET', DEFAULT_TICKET),
        },
    },
    extra={
        'market_maker_adr':
        os.environ.get('XBR_MARKET_MAKER_ADR',
                       '0x3e5e9111ae8eb78fe1cc3bb8915d5d461f3ef9a9'),
        'seller_privkey':
        os.environ.get(
            'XBR_SELLER_PRIVKEY',
            '0xc880bc8b2caf7bd15addfc12bd99b20a0199b1201bceff1b04d62fd5c88a247c'
        ),
    })

running = False


@comp.on_join
async def joined(session, details):
TRANSPORT, SERIALIZER = sys.argv[1].split('-')
if TRANSPORT not in ['websocket', 'rawsocket']:
    raise Exception('invalid TRANSPORT "{}"'.format(TRANSPORT))
if SERIALIZER not in ['cbor', 'msgpack', 'json', 'ubjson']:
    raise Exception('invalid TRANSPORT "{}"'.format(TRANSPORT))

AUTHENTICATION = {'ticket': {'authid': 'user2', 'ticket': 'secret2'}}

if TRANSPORT == 'websocket':
    comp = Component(transports=[
        {
            "type": "websocket",
            "url": "ws://localhost:8443/ws",
            "endpoint": {
                "type": "tcp",
                "host": "localhost",
                "port": 8443,
            },
            "serializers": [SERIALIZER],
        },
    ],
                     realm="realm1",
                     authentication=AUTHENTICATION)
elif TRANSPORT == 'rawsocket':
    comp = Component(transports=[
        {
            "type": "rawsocket",
            "url": "rs://localhost:8443",
            "endpoint": {
                "type": "tcp",
                "host": "localhost",
                "port": 8443,
Esempio n. 27
0
DEFAULT_AUTHID = 'team4'
DEFAULT_TICKET = 'knife23 fork spoon cutlery'

TOPIC = 'com.conti.hackathon.team4.seller'
SERVICE_NAME = 'simple seller python example service'
SERVICE_TYPE = 'seller'

comp = Component(
    transports=os.environ.get('XBR_INSTANCE', 'wss://continental2.crossbario.com/ws'),
    realm=os.environ.get('XBR_REALM', 'realm1'),
    authentication={
        'ticket': {
            'authid': os.environ.get('XBR_AUTHID', DEFAULT_AUTHID),
            'ticket': os.environ.get('XBR_TICKET', DEFAULT_TICKET),
            'authextra': {
                'service_name': SERVICE_NAME,
                'type': SERVICE_TYPE,
            },
        },
    },
    extra={
        'market_maker_adr': os.environ.get('XBR_MARKET_MAKER_ADR', '0x3e5e9111ae8eb78fe1cc3bb8915d5d461f3ef9a9'),
        'seller_privkey': os.environ.get('XBR_SELLER_PRIVKEY', '0xAF5648AAB4CB8582FA6F1A678D49009EDE489BC5B25F6F38CD351EC98C29D97A'),
    }
)

running = False


@comp.on_join
async def joined(session, details):
    print('Seller session joined', details)
Esempio n. 28
0
 def test_invalid_type(self):
     with self.assertRaises(ValueError) as ctx:
         Component(transports=["foo"])
     self.assertIn("must be a dict", str(ctx.exception))
from __future__ import print_function

from autobahn.twisted.component import Component, run
from autobahn.wamp import cryptosign
import binascii

privkey_hex = '6e3a302aa67d55ffc2059efeb5cf679470b37a26ae9ac18693b56ea3d0cd331c'
# pubkey: 020b13239ca0f10a1c65feaf26e8dfca6e84c81d2509a2b7b75a7e5ee5ce4b66

component = Component(transports=u'ws://localhost:8080/auth_ws',
                      realm=u'crossbardemo',
                      authentication={
                          u"cryptosign": {
                              "authid": u"alice",
                              "privkey": privkey_hex,
                          }
                      })


@component.on_join
def join(session, details):
    print("Session {} joined: {}".format(details.session, details))


if __name__ == '__main__':
    run(component)