def on_get_message(self,event,conn=None): #self.m = input("Mensaje: ") """ ToDo: make this function run without blockings """ try: payload = self.comm_queue.get() #event.container.push_event(event,EventType("prueba")) if "message" in payload: print("Mensaje ",payload["message"]) self.m = payload["message"] else: print("Message ",payload) self.m = str(payload) if self.m == "": print("closing connection") event.connection.close() else: if conn: event.container.create_sender(conn, self.output_address) else: event.container.create_sender(event.connection, self.output_address) except queue.Empty: print("timeout") event.container.push_event(event,EventType("get_message"))
def __init__(self, typename, connection=None, session=None, link=None, delivery=None, subject=None): super(ApplicationEvent, self).__init__(PN_PYREF, self, EventType(typename)) self.connection = connection self.session = session self.link = link self.delivery = delivery if self.delivery: self.link = self.delivery.link if self.link: self.session = self.link.session if self.session: self.connection = self.session.connection self.subject = subject
# You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys, traceback from proton import EventType, Message, Delivery from .impl import dual_impl, DatawireEvent ENCODED_MESSAGE = EventType("encoded_message", DatawireEvent.Type.ENCODED_MESSAGE) MESSAGE = EventType("message", DatawireEvent.Type.MESSAGE) @dual_impl class Decoder: def __init__(self, *handlers): self.__message = Message() self.handlers = handlers def on_delivery(self, event): if hasattr(event, "message"): return if self.__message.recv(event.link): event.message = self.__message dlv = event.delivery
if address: if link.is_sender: link.target.address = address.text else: link.source.address = address.text return link def __str__(self): return pretty return Redirect() else: return None DRAINED = EventType("drained", DatawireEvent.Type.DRAINED) class Link: def __init__(self, *handlers, **kwargs): self.handlers = handlers self._link = None self.trace = None def start(self, reactor, link=None, open=True): if link is None: link = self.link self._link = link(reactor) self._link.open() self._link.session.open() if open:
# you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from proton import EventType, PN_LOCAL_ACTIVE from .impl import dual_impl, DatawireEvent SAMPLE = EventType("sample", DatawireEvent.Type.SAMPLE) @dual_impl class Sampler: def __init__(self, delegate=None, frequency=1): if delegate is None: self.__delegate = self else: self.__delegate = delegate self.frequency = frequency def on_link_local_open(self, event): self._sample(event) def _sample(self, event):