The Endpoint layer provides high-level message routing and request handling functionality.
from netcore import Endpoint, Response
@endpoint.route("hello")
def handle_hello():
return Response("hello", "Hello World!")
@endpoint.route("echo")
def handle_echo():
return Response("echo", request.data)
def on_response(data, info):
print(f"Received response: {data}")
endpoint.send("hello", "Hi!", callback=on_response)
@endpoint.default
def handle_default(data, info):
print(f"Unhandled message: {data}")