Files
soroush.asadi b0896dc777
CI/CD / CI · API (dotnet build + test) (push) Successful in 40s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 31s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m8s
CI/CD / CI · Admin Web (tsc) (push) Successful in 38s
CI/CD / CI · Website (tsc) (push) Successful in 46s
CI/CD / CI · Koja (tsc) (push) Successful in 50s
CI/CD / Deploy · all services (push) Successful in 3m29s
feat(pos): bridge the card terminal through the print agent + LAN auto-detect
The card-terminal integration only ever worked when the API could reach the
terminal's IP directly — impossible for the cloud deployment, where the terminal
sits on the café LAN (the same wall the Print Agent already climbs for printers).
And the terminal IP had to be typed by hand. Both fixed by reusing the agent.

Cloud→LAN relay:
- PrintAgentRegistry.SendPaymentAsync sends a PaymentRequest to the café's online
  agent and awaits its ack (PaymentResult on the hub); 95s window for the customer.
- PosDeviceService now prefers an online agent (branch-matched, else any café
  agent) to relay POST /pay over the LAN, and falls back to the direct HTTP call
  only when no agent is connected (on-prem). Agent errors map back to POS_DEVICE_*.
- Agent (Program.cs + PosTerminal.cs) handles PaymentRequest → POSTs the amount to
  the terminal's local http://ip:port/pay and reports approval/decline/timeout.

Auto-detect:
- Registry.ScanAsync + hub ReportScan; POST /print-agents/scan asks online agents
  to scan their /24 for given ports and merges the hosts found.
- Agent NetworkScanner scans the LAN (:9100 printers, :8088 terminals) with a
  short per-host TCP probe.
- Dashboard: a "تشخیص خودکار" (auto-detect) button on the POS-device, receipt and
  kitchen IP fields scans via the agent and fills the IP:port from a found host.

Backend + agent build clean; dashboard tsc clean. NOTE: the agent app is not in
CI — it must be rebuilt and redeployed on the café PC to gain these handlers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 14:01:21 +03:30
..

Meezi Print Agent (پرینت‌سرور میزی)

A tiny Windows background app that lets the cloud-hosted Meezi reach printers on the café's local network (USB or Wi-Fi/Ethernet). The cloud can't open a connection to a 192.168.x.x or USB printer directly — this agent runs on the cash PC (which is on that network), connects outward to Meezi over SignalR, reports the printers it can see, and prints the jobs the cloud sends it.

Cloud API ──SignalR(out)──► Print Agent (cash PC) ──► USB / LAN printers

How it works

  1. In the dashboard: Settings → Printers → Add print server → you get a pairing code.
  2. Run the agent on the cash PC, enter the code once. It saves a token to %APPDATA%\MeeziPrintAgent\config.json and connects.
  3. It reports every printer installed on that PC. Back in the dashboard you map receipt / kitchen / bar to a printer from the dropdown — no IP typing.
  4. When Meezi prints, the bytes (ESC/POS) are relayed to the agent, which writes them raw to the chosen printer (winspool for installed printers, raw TCP for ip:port devices).

Build & run (dev)

Requires the .NET 10 SDK on Windows.

# restore via the Nexus mirror (nuget.org is blocked on this network)
dotnet restore agent/Meezi.PrintAgent/Meezi.PrintAgent.csproj -s https://mirror.soroushasadi.com/repository/nuget-group/
dotnet run --project agent/Meezi.PrintAgent          # first run prompts to pair
dotnet run --project agent/Meezi.PrintAgent -- pair  # re-pair later

Publish a single .exe for cafés

dotnet publish agent/Meezi.PrintAgent -c Release -r win-x64 \
  -p:PublishSingleFile=true --self-contained true -o dist/agent
# → dist/agent/MeeziPrintAgent.exe

Notes / roadmap

  • Not part of the API solution or CI — it targets net10.0-windows and builds on its own.
  • Console MVP today. Next: system-tray UI, run-at-login (Task Scheduler / service), auto-update, and an optional LAN scan for raw ip:9100 printers that aren't installed in Windows.
  • The token is bearer-equivalent — keep config.json on a trusted machine. Revoke from the dashboard if a PC is lost.