From 0791314bace804767f4dfba19a4962405c7f90b9 Mon Sep 17 00:00:00 2001 From: Muraveiko Date: Sat, 2 Nov 2019 21:53:26 +0300 Subject: [PATCH] 0.0.1 --- README.md | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-- composer.json | 2 +- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4c65608..65a5abd 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,52 @@ -# rawbt_ws_server -Websoket Server for ESC/POS Printers +# RawBT: Websocket Server for ESC/POS Printers + +RawBT requires PHP 5.4.0+ to run. +The utility is distributed as a Phar package. + +## Installing on user PC +0. Install PHP (if not installed yet) + +1. Download last release from https://github.com/402d/rawbt_ws_server/releases +2. Unpack +3. Copy files from dist folder +4. Rename one from examples config +5. Edit connect params +6. Run server (rawbt) + +## Front-end +https://rawbt.ru/mike42/example_rawbt/ +```js +function pc_print(data){ + var socket = new WebSocket("ws://127.0.0.1:40213/"); + socket.bufferType = "arraybuffer"; + socket.onerror = function(error) { + alert("Error"); + }; + socket.onopen = function() { + socket.send(data); + socket.close(1000, "Work complete"); + }; +} +function android_print(data){ + window.location.href = data; +} +function ajax_print(url, btn) { + $.get(url, function (data) { + var ua = navigator.userAgent.toLowerCase(); + var isAndroid = ua.indexOf("android") > -1; + if(isAndroid) { + android_print(data); + }else{ + pc_print(data); + } + }); +} +``` + +## Back-end demo +https://github.com/mike42/escpos-php/blob/development/example/rawbt-receipt.php + +**It is enough to specify the desired connector** +```php + $connector = new RawbtPrintConnector(); +``` diff --git a/composer.json b/composer.json index 808f102..437aefb 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "402d/rawbt_ws_server", - "description": "Websoket Server for ESC/POS Printers", + "description": "Websocket Server for ESC/POS Printers", "require": { "hoa/websocket": "3.17.01.09", "mike42/escpos-php": "^2.0",