示例#1
0
文件: async.py 项目: mozes/stompest
 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)
示例#2
0
文件: async.py 项目: nkvoll/stompest
 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)
示例#3
0
 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)
示例#4
0
    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
示例#5
0
文件: simple.py 项目: nkvoll/stompest
 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)
示例#6
0
 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)
示例#8
0
    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)
示例#9
0
 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)
示例#10
0
    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
示例#12
0
    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
示例#13
0
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)
示例#14
0
 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)
示例#15
0
#!/usr/bin/python
import stomper
stomper.connect()
示例#16
0
文件: scrape.py 项目: j105rob/FoxBot
 def connect(self):
     cmd = stomper.connect(self.username, self.password, self.server)
     self._send(cmd)
示例#17
0
 def connectionMade(self):
     cmd = stomper.connect(self.username, self.password)
     self.transport.write(cmd)
示例#18
0
 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)
示例#19
0
 def connectionMade(self):
     cmd = stomper.connect(self.username, self.password)
     self.transport.write(cmd)
示例#20
0
 def connect(self):
     """Generate the STOMP connect command to get a session.
     """
     return stomper.connect(self.username, self.password)
示例#21
0
 def connectionMade(self):
     """Register with stomp server.
     """
     cmd = stomper.connect(self.username, self.password)
     self.transport.write(cmd)
示例#22
0
 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)
示例#23
0
	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)
示例#24
0
 def conectar(self):
     # Generate the STOMP connect command to get a session.
     return stomper.connect(self.username, self.password, 'localhost')
示例#25
0
 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)
示例#26
0
#!/usr/bin/env python


import stomper

ch = stomper.connect("", "", "172.17.5.194")

stomper.send(ch, "hello")

print ch
示例#27
0
 def connect(self):
     """Generate the STOMP connect command to get a session.
     """
     return stomper.connect(self.username, self.password)
示例#28
0
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.
#
示例#29
0
 def connectionMade(self):
     """Register with stomp server.
     """
     cmd = stomper.connect(self.username, self.password)
     self.transport.write(cmd)
示例#30
0
 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)