Code Monkey home page Code Monkey logo

rawbt_ws_server's Introduction

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

For Windows

  • Run server (rawbt.bat - The application starts in a minimized window)

For Linux

  • php rawbt.phar

For Linux (run as daemon)

  • copy rawbt.service to /etc/systemd/system/rawbt.service
  • edit User, Group (don't run it as root), WorkingDirectory and ExecStart
  • sudo systemctl daemon-reload
  • sudo systemctl enable rawbt.service
  • sudo systemctl start rawbt.service

screenshot

  • Add bat file to startup

In the /doc directory you can find a useful utility (TrayIt) that can hide the window of a running server.

Front-end

https://rawbt.ru/mike42/example_rawbt/

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

    $connector = new RawbtPrintConnector();

rawbt_ws_server's People

Contributors

muraveiko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rawbt_ws_server's Issues

empty print job

Hi,

I'm trying to print from a Java application deployed in another device. The connection with RawBT WS is established and closed with no errors. When sending, RawBT notifies "Empty print job". This is the code fragment:

if (c.connectBlocking(1, TimeUnit.SECONDS)) { StringBuilder json = new StringBuilder(); json.append("{\"message\":\"").append("test").append("\"}"); c.send(json.toString()); }

I guess it has to do with the JSON arguments, or string format.

Any helps would be appreciated.

RawBT.bat always close automatically

i use RawBT for printing by network. but the bat file always close automatically after few minutes.

what causes the application to close itself ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.