Exemplo n.º 1
0
	def sendMessage(self, destination, message):
		self.__connect_to_server()
		server_msg = "{}|{}|{}|{}".format(
			ipcCommon.get_cmd_send_message(), self.name, destination, message);
		print("ipcClient({}) ==> '{}'".format(self.name, server_msg))
		ipcCommon.send_string(self.tcp_socket, server_msg)
		self.close()
Exemplo n.º 2
0
 def stopPeeking():
     self.__connect_to_server()
     server_msg = "{}|{}".format(ipcCommon.get_cmd_remove_peeker(),
                                 self.name)
     print("ipcClient({}) ==> '{}'".format(self.name, server_msg))
     ipcCommon.send_string(self.tcp_socket, server_msg)
     self.close()
Exemplo n.º 3
0
 def __process_msg_peek_request(self, fields, session_socket):
     if not len(fields) == 2:
         print("Invalid msg peek request: '{}'".format(fields))
         return
     peeker_name = fields[1]
     msg = self.peek_data.getMessage(peeker_name)
     if msg is None:
         msg = ""
     print("ipcServer: ==> '{}'".format(msg))
     ipcCommon.send_string(session_socket, msg)
Exemplo n.º 4
0
 def __process_msg_pull_request(self, fields, session_socket):
     if not len(fields) == 3:
         print("Invalid msg pull request: '{}'".format(fields))
         return
     from_node = fields[1]
     to_node = fields[2]
     msg = self.msg_container.getMessage(from_node, to_node)
     if msg is None:
         msg = ""
     print("ipcServer: ==> '{}'".format(msg))
     ipcCommon.send_string(session_socket, msg)
Exemplo n.º 5
0
 def peekMessage(self):
     server_msg_out = "{}|{}".format(ipcCommon.get_cmd_peek_message(),
                                     self.name)
     self.__connect_to_server()
     print("ipcClient({}) ==> '{}'".format(self.name, server_msg_out))
     ipcCommon.send_string(self.tcp_socket, server_msg_out)
     raw_msg_in = ipcCommon.recv_data(self.tcp_socket)
     #print("ipcClient({}) RawReply: '{}'".format(self.name, raw_msg_in))
     if not ((raw_msg_in is None) or (len(raw_msg_in) == 0)):
         msg_in = raw_msg_in.decode()
     print("ipcClient({}) <== '{}'".format(self.name, msg_in))
     if (not msg_in is None) and (len(msg_in) == 0):
         msg_in = None
     self.close()
     return msg_in
Exemplo n.º 6
0
	def getMessage(self, from_who, timeOut = 5):
		server_msg_out = "{}|{}|{}".format(
			ipcCommon.get_cmd_get_message() ,from_who, self.name)
		for i in range(timeOut):
			self.__connect_to_server()
			print("ipcClient({}) ==> '{}'".format(self.name, server_msg_out))
			ipcCommon.send_string(self.tcp_socket, server_msg_out)
			raw_msg_in = ipcCommon.recv_data(self.tcp_socket)
			#print("ipcClient({}) RawReply: '{}'".format(self.name, raw_msg_in))
			if not ((raw_msg_in is None) or (len(raw_msg_in) == 0)):
				msg_in = raw_msg_in.decode()
				print("ipcClient({}) <== '{}'".format(self.name, msg_in))
				self.close()
				return msg_in
			self.close()
			time.sleep(1)
		return None
Exemplo n.º 7
0
	def stopServer(self):
		self.__connect_to_server()
		server_msg = ipcCommon.get_cmd_stop_server()
		print("ipcClient({}) ==> '{}'".format(self.name, server_msg))
		ipcCommon.send_string(self.tcp_socket, server_msg)
		self.close()