Beispiel #1
0
	def __send_app_connections(self, app):
		if not app in self.applications.keys(): return
		
		dest = from_arg_to_addr(app, "127.0.0.1", self.applications[app])
		orig = from_arg_to_addr()
		
		message = Message(destination=dest, origin=orig)
		message.content = {
							"intent": DAEMON_APP_CONN_LST_ANS, 
							"connections": self.connections
						   }
		message.send()
Beispiel #2
0
	def __register_app(self):
		""" This function ask the Siderus Daemon to register the app """
		
		self.address = from_arg_to_addr(app=self.name, port=DEFAULT_APP_TMP_PORT)
		daemon_address = return_daemon_address("127.0.0.1",DAEMON_LOC_PORT)
		
		message_ask = Message(origin=self.address, destination=daemon_address)
		message_ask.content = {"intent": DAEMON_APP_LCCN_REQ}
		
		message_port = Message(destination=self.address)
		
		message_ask.send()
		message_port.receive_and_decode()
		
		self.address = message_port.content['address']		
Beispiel #3
0
	def add_application(self, application):
		""" 
			This function send to the application the port 
			to use establishing a connection.
		"""	
		port = get_random_port(exclude_list=self.applications.values())
		
		dest = from_arg_to_addr(application, "127.0.0.1", DEFAULT_APP_TMP_PORT)
		orig = return_daemon_address("127.0.0.1")
		app_address = return_application_address(application, port)
		
		message = Message(destination=dest, origin=orig)
		message.content = {"intent": DAEMON_APP_LCCN_REQ_PRT, "address": app_address }
		message.send()
				
		self.applications[application] = port
#!/usr/bin/env python

import sys

sys.path.append("..")
sys.path.append("../..")

from siderus.message import Message
from siderus.common import return_application_address, from_arg_to_addr
import sys

destination = from_arg_to_addr(app="MessageTester", addr=sys.argv[1], port=52225)
origin = return_application_address("MessageTester", 52225)

m = Message(" ".join(sys.argv[2:]), destination, origin)
m.send()