Skip to content

Commit

Permalink
updated with latest changes to digitalpy
Browse files Browse the repository at this point in the history
  • Loading branch information
naman108 committed Jan 30, 2024
1 parent d039830 commit 374c994
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,13 @@
[HelloWorld]
__class = components.hello_world.hello_world.HelloWorld

[HelloService]
__class = components.hello_world.service.hello_service.HelloService
[DigitalPyHelloWorld.HelloService]
__class = components.hello_world.service.hello_service.HelloService
default_status = Running
service_id = hello_world.HelloService
name = HelloService
description = "Hello World Service"
network = TCPNetwork
protocol = XML
port = 8080
host = 127.0.0.1
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,4 @@ url="https://github.com/FreeTAKTeam/DigtalPyHelloWorld"
; Location of the release of this component
repo = https://pypi.org/project/DigtalPyHelloWorld/
; software license for this component
license = EPL

[HelloService]
default_status = Running
service_id = hello_world.HelloService
name = HelloService
description = "Hello World Service"
network = TCPNetwork
protocol = XML
port = 8080
host = 127.0.0.1
license = EPL
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time
import traceback

from digitalpy.core.zmanager.response import Response
from digitalpy.core.parsing.formatter import Formatter
from digitalpy.core.service_management.digitalpy_service import DigitalPyService
from digitalpy.core.service_management.domain.service_status import ServiceStatus
Expand Down Expand Up @@ -32,13 +33,16 @@ def event_loop(self):
"""
super().event_loop()

time.sleep(0.1)
requests = self.network.service_connections()
for request in requests:
print("received "+str(request.get_value("data")) +
" from "+str(request.get_value("client").id))
self.handle_inbound_message(request)

def handle_response(self, response: Response):
"""used to handle a response. Should be overriden by inheriting classes"""
if self.network:
response.set_value("clients", response.get_value("recipients"))
self.network.send_response(response)

def handle_inbound_message(self, message: Request):
"""This function is used to handle inbound messages from other services.
It is intiated by the event loop.
Expand Down
2 changes: 1 addition & 1 deletion DigitalPyHelloWorld/services/DPHelloWorld.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def event_loop(self):
self.stop()
elif command == "1":
# service_id = input("What is the id of the service you would like to start?: ")
self.start_service(service_id="hello_world.HelloService")
self.start_service(service_section_name="DigitalPyHelloWorld.HelloService")
elif command == "2":
# service_id = input("What is the id of the service you would like to stop?: ")
self.stop_service(service_id="hello_world.HelloService")
Expand Down

0 comments on commit 374c994

Please sign in to comment.