Skip to content
This repository was archived by the owner on Mar 20, 2019. It is now read-only.

working client for Python 2 and 3 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,41 @@ Raise issues if you encounter any problems.

```python

import stomp, gzip, StringIO, xml

import stomp, gzip, io
from bs4 import BeautifulSoup

class MyListener(object):
#
# def __init__ (self, conn):
# self._conn = conn

def on_error(self, headers, message):
print('received an error %s' % message)

def on_message(self, headers, message):
fp = gzip.GzipFile(fileobj = StringIO.StringIO(message))
text = fp.readlines()
#print (message)
fp = gzip.GzipFile(fileobj = io.BytesIO(bytes(message)))
text = fp.read()
fp.close()
print('%s\n' % text)

soup = BeautifulSoup(text, 'html.parser')
print("="*60)
print(soup.prettify())
print("="*60)

# self._conn.ack(id=headers['message-id'], subscription=headers['subscription'])

conn = stomp.Connection([('datafeeds.nationalrail.co.uk', 61613)])

conn = stomp.Connection([('datafeeds.nationalrail.co.uk', 61613)], auto_decode=False)
conn.set_listener('', MyListener())
conn.start()
conn.connect(username = 'd3user', passcode = 'd3password', wait=False)

conn.subscribe(destination='/queue/<your GUID queue>', id=1, ack='auto')

#conn.send(body=' '.join(sys.argv[1:]), destination='')

mydata = raw_input('Prompt :')

mydata = input('Prompt :')
conn.disconnect()


Expand Down