# Path: pyactor/util.py
# RABBIT_USER = "guest"
# 
# RABBIT_PASS = "guest"


import pika
import threading
import pickle
from urllib.parse import urlparse
from pyactor.util import RABBIT_USER, RABBIT_PASS

    def register_function(self, func):
        self.on_message = func
        self.channel.basic_consume(self.url, self.on_request,
                                   exclusive=True)

    def run(self):
        self.channel.start_consuming()

    def stop(self):
        self.channel.queue_delete(queue=self.url)
        self.channel.close()
        self.connection.close()

    def on_request(self, ch, method, props, body):
        self.on_message(body)
        ch.basic_ack(delivery_tag=method.delivery_tag)


class Sink(object):
    """
    Facade for RabbitMQ concrete connexions to remote actors.
    This manages the publish to queues.
    """

    def __init__(self, url):
        aurl = urlparse(url)
        address = aurl.netloc.split(':')
        ip, port = address[0], int(address[1])
        self.url = ip + '/' + str(port)

# Path: pyactor/util.py
# RABBIT_USER = "guest"
# 
# RABBIT_PASS = "guest"


# Path: pyactor/rabbitserver.py
import pika
import threading
import pickle
from urllib.parse import urlparse
from pyactor.util import RABBIT_USER, RABBIT_PASS


    def register_function(self, func):
        self.on_message = func
        self.channel.basic_consume(self.url, self.on_request,
                                   exclusive=True)

    def run(self):
        self.channel.start_consuming()

    def stop(self):
        self.channel.queue_delete(queue=self.url)
        self.channel.close()
        self.connection.close()

    def on_request(self, ch, method, props, body):
        self.on_message(body)
        ch.basic_ack(delivery_tag=method.delivery_tag)


class Sink(object):
    """
    Facade for RabbitMQ concrete connexions to remote actors.
    This manages the publish to queues.
    """

    def __init__(self, url):
        aurl = urlparse(url)
        address = aurl.netloc.split(':')
        ip, port = address[0], int(address[1])
        self.url = ip + '/' + str(port)

        credentials = pika.PlainCredentials(RABBIT_USER, RABBIT_PASS)