def _connect(self): """Send connect command """ self.log.debug('Sending connect command') cmd = stomper.connect(self.factory.login, self.factory.passcode) # self.log.debug('Writing cmd: %s' % cmd) self.transport.write(cmd)
def _connect(self): """Send connect command """ self.log.debug("Sending connect command") cmd = stomper.connect(self.factory.getLogin(), self.factory.getPasscode()) # self.log.debug("Writing cmd: %s" % cmd) self.transport.write(cmd)
def connectionMade(self): """Register with stomp server. """ print "connect made .." cmd = stomper.connect(self.username, self.password, self.host) print "cmd is-------->", self.transport.write(cmd)
def login(self): credentials = self.credentials self.instanceId = credentials['username'] host = self.locust.host """Create random credentials""" user_pass = credentials['username'] + ":" + credentials['password'] encoded_user_pass = b64encode( user_pass.encode('ascii')).decode("utf-8") """Create connection""" init_time = time.time() ws_url = "ws://" + host + "/device-management-service/websocket" ws = create_connection( ws_url, header={"Authorization": "Basic " + str(encoded_user_pass)}) con = stomper.connect(credentials["username"], credentials["password"], host=ws_url, heartbeats=(30000, 30000)) ws.send(con) res = ws.recv() self.handle_message(str(res), init_time=init_time) """subscribe""" init_time = time.time() sub = stomper.subscribe("/user/queue/device", 0, ack='auto') ws.send(sub) res = ws.recv() self.handle_message(str(res), init_time=init_time) return ws
def connect(self, login='', passcode=''): self._socketConnect() self._write(stomper.connect(login, passcode)) frame = self.receiveFrame() if frame['cmd'] == 'CONNECTED': return frame raise StompProtocolError('Unexpected frame received: %s' % frame)
def connectionMade(self): """ Called when a connection is made. Protocol initialization happens here """ self.logger.info("Connection with the broker made") stompConnectMsg = stomper.connect(self._username, self._password) self.transport.write(stompConnectMsg)
def test_connectionMade(self): self.protocol.makeConnection( self.fakeTransport ) #the protocol must have sent the request for login to #the STOMP broker dataInTheWire = self.fakeTransport.value() expected = stomper.connect(config.USER, config.PASS) self.assertEquals(expected, dataInTheWire)
def test_connectionMade(self): self.protocol.makeConnection(self.fakeTransport) #the protocol must have sent the request for login to #the STOMP broker dataInTheWire = self.fakeTransport.value() expected = stomper.connect(config.USER, config.PASS) self.assertEquals(expected, dataInTheWire)
def testConnectWithHeartbeats(self): username, password = '******', '123' heartbeats = (1000, 1000) correct = "CONNECT\naccept-version:1.1\nhost:localhost\nheart-beat:1000,1000\nlogin:%s\npasscode:%s\n\n\x00\n" % ( username, password) self.assertEquals( stomper.connect(username, password, 'localhost', heartbeats=heartbeats), correct)
def test_processLine_throws_FrameError_after_done(self): cmd = stomper.connect('foo', 'bar') lines = cmd.split('\n')[:-1] parser = StompFrameLineParser() for line in lines: parser.processLine(line) self.assertTrue(parser.isDone()) self.assertRaises(StompFrameError, lambda: parser.processLine('SEND'))
def connectionMade(self): """ Called when a connection is made. Protocol initialization happens here """ self.logger.info("Connection with the broker made") stompConnectMsg = stomper.connect(self._username, self._password) self.sendMsg(stompConnectMsg) try: self.factory.resetDelay() except: pass
def on_open(ws, c=config): print('on_open:', 'Connection opened!') connDATA = c.getConf() """ stomp connect() lo interesante de marcar aqui son los parametos de conexion. Como podemos ver mandar fruta e igualmente se conecta. Funciona xq websockets ya tiene la conexion abierta. El connect del stomp es puramente formal """ msg = stomper.connect('DUMMY_USER', 'DUMMY_PW', 'DUMMY_HOST', (0,0)) print('stomp connect:', msg) ws.send(msg) f = stomper.Frame() f.unpack(stomper.subscribe(connDATA['endpoint']['bymaMD'], 'bymaMD', ack='auto')) fMsg = f.pack() ws.send(fMsg)
def testConnectWithHeartbeats(self): username, password = '******', '123' heartbeats = (1000, 1000) correct = "CONNECT\naccept-version:1.1\nhost:localhost\nheart-beat:1000,1000\nlogin:%s\npasscode:%s\n\n\x00\n" % (username, password) self.assertEquals(stomper.connect(username, password, 'localhost', heartbeats=heartbeats), correct)
#!/usr/bin/python import stomper stomper.connect()
def connect(self): cmd = stomper.connect(self.username, self.password, self.server) self._send(cmd)
def connectionMade(self): cmd = stomper.connect(self.username, self.password) self.transport.write(cmd)
def testConnect(self): username, password = '******', '123' correct = "CONNECT\naccept-version:1.1\nhost:localhost\nheart-beat:0,0\nlogin:%s\npasscode:%s\n\n\x00\n" % ( username, password) self.assertEquals(stomper.connect(username, password, 'localhost'), correct)
def connect(self): """Generate the STOMP connect command to get a session. """ return stomper.connect(self.username, self.password)
def connectionMade(self): """Register with stomp server. """ cmd = stomper.connect(self.username, self.password) self.transport.write(cmd)
def testConnect(self): username, password = '******', '123' correct = "CONNECT\nlogin:%s\npasscode:%s\n\n\x00\n" % (username, password) self.assertEquals(stomper.connect(username, password), correct)
def connect(self): """Generate the STOMP connect command to get a session.""" self.pygo_mp.logger.info("=> PyGoWave RPC Server starting <=") return stomper.connect(self.username, self.password)
def conectar(self): # Generate the STOMP connect command to get a session. return stomper.connect(self.username, self.password, 'localhost')
#!/usr/bin/env python import stomper ch = stomper.connect("", "", "172.17.5.194") stomper.send(ch, "hello") print ch
messages and anything else I can think of demonstrating. (c) Oisin Mulvihill, 2007-07-28. License: http://www.apache.org/licenses/LICENSE-2.0 """ from __future__ import print_function import pprint import stomper responder = stomper.Engine() # Generate the connect command to tell the server about us: msg = stomper.connect('bob','1234') print("msg:\n%s\n" % pprint.pformat(msg)) #>>> 'CONNECT\nlogin:bob\npasscode:1234\n\n\x00\n' # Send the message to the server and you'll get a response like: # server_response = """CONNECTED session:ID:snorky.local-49191-1185461799654-3:18 \x00 """ # We can react to this using the state machine to generate a response. #
def testConnect(self): username, password = '******', '123' correct = "CONNECT\naccept-version:1.1\nhost:localhost\nheart-beat:0,0\nlogin:%s\npasscode:%s\n\n\x00\n" % (username, password) self.assertEquals(stomper.connect(username, password, 'localhost'), correct)