Hello guys,
Since few days I try to write my ST3 plugin to sending XML in background and view received data in new file.
I created transaction object to handle creating, sending and receiving data:
class Trx(threading.Thread):
def __init__(self, address, request, edit):
self.address = address # (host, port)
self.request = request
self.response = None
self._edit = edit
threading.Thread.__init__(self)
self.process();
def run(self):
new_view = sublime.active_window().new_file()
new_view.insert(self._edit, 0, self.response)
new_view.set_syntax_file('Packages/XML/XML.tmLanguage')
class RequestSenderCommand(sublime_plugin.TextCommand):
def run(self, edit, address=None):
if address is None:
sublime.error_message('No address')
return
window = sublime.active_window()
region = sublime.Region(0, self.view.size())
request = self.view.substr(region)
host, port = address.split(':')
sublime.status_message('Sending...')
thread = Trx((host,port), request, edit)
thread.start()
ThreadProgress(thread, 'Sending', 'Sent')
But there is a problem with edit object. It cannot be passed to other object and I don’t know how to view response.
Any suggestions?