hennedo / escpos

golang library for espos printers, supporting images, barcodes and qr codes
MIT License
70 stars 29 forks source link

Doesn't work on WASM #20

Open apuatcfbd opened 8 months ago

apuatcfbd commented 8 months ago

Even the WASM build failing, There's a PR which solves that. By using that PR I'm able to build a WASM binay & successfully load into browser,

But the unfortunate thing is WASM doesn't supports direct TCP communication so net.Dial doesn't work.

tcp 192.168.0.121:9100: Connection refused

(works natively - when running the (documented) code from terminal)

Is there any plan/ way to do that?

The thing I'm trying is to ship a WASM that will handle swift printing from the client site (since the printer in is clients (local) network.

Is it even possible?

justinmichaelvieira commented 8 months ago

@apuatcfbd I think it is currently only possible via Emscripten; If I'm understanding correctly this is a WASM limitation and not an escpos library one.

Can you take a look at https://github.com/WebAssembly/design/issues/1251 (relevant closed WASM design issue with guidance), and let us know?

apuatcfbd commented 8 months ago

At the current scope of this package, it's okay. I wanted to work with WASM to have a specific advantage. This isn't an issue. Do you have any plan to implement something that works from WASM? Like in Epson printers I've seen that they support web sockets, which is available in WASM too. But they way that works they call is ePOSprint I'm not sure if that is using the escpos standard or not.

justinmichaelvieira commented 8 months ago

Epos and escpos are two completely separate languages. So that's out of scope here, you'd need to use a library that targets epos language.

justinmichaelvieira commented 8 months ago

This issue can be closed, as the root cause of the issue is a wasm limitation.