Skip to content

BaseServer abstract class for tcp services. #280

@Relm-Arrowny

Description

@Relm-Arrowny

The goal is to create a core BaseServer class that handles all the TCP networking with the client , command loops, and error handling so that specific hardware implementations the hardware HF2, pulse generator only need to handle hardware-specific logic.

This class will enforce a Request-Response protocol where every command from a client results in either a success acknowledgement (1) or an error message (0: error_details).

Goals

Acceptance criteria : What journeys should the user be able to complete to consider your feature done
Be as specific as you can, check them off once they work. Add more if you find more requirements during development. Issue should only be considered done after all of them are checked

  • Network Lifecycle: Manage socket binding, listening, and teardown (stop() method).
  • Standardized Protocol: Implement the logic to receive data, split by line, and send to handler.
  • Automated Feedback: Ensure an ACK/NACK is sent back to the client for every processed line.
  • Error handling: E.g. A hardware exception in a child class does not crash the entire server.

Tasks

base on the goals, deduce the tasks required. check them off once they're done

  • Create tests for the baseclass.
  • Create baseserver.
  • start(self): The main entry point. Orchestrates the socket lifecycle (Bind -> Listen -> Accept).
  • _run_command_loop(self): An internal method that reads from the socket and splits incoming bytes into individual command lines.
  • stop(self): Safely closes the client connection and the server socket.
  • send_ack(self): Sends the success signal b"1\n".
  • send_nack(self, error_message): Formats and sends the error signal b"0: ...\n".
    abstract functions:
  • connect_hardware(self) -> bool
  • handle_command(self, cmd: bytes, args: list)

Related Resources

any images/gifs, mockups/wireframes that would aid the development should be listed here
MockUp : link to mockup
Coda doc: link to coda
Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions