Browse Source

update websocket

Rahmat Ade Saputra 3 years ago
parent
commit
34cce79699
100 changed files with 34 additions and 7 deletions
  1. 1
    1
      app/Http/Controllers/ThermalPrintingController.php
  2. 1
    1
      app/Http/Controllers/TransactionController.php
  3. 0
    0
      websocket_print/ThermalPrinting.php
  4. 25
    0
      websocket_print/client.php
  5. 0
    0
      websocket_print/composer.json
  6. 0
    0
      websocket_print/composer.lock
  7. 7
    5
      websocket_print/server.php
  8. 0
    0
      websocket_print/vendor/autoload.php
  9. 0
    0
      websocket_print/vendor/composer/ClassLoader.php
  10. 0
    0
      websocket_print/vendor/composer/InstalledVersions.php
  11. 0
    0
      websocket_print/vendor/composer/LICENSE
  12. 0
    0
      websocket_print/vendor/composer/autoload_classmap.php
  13. 0
    0
      websocket_print/vendor/composer/autoload_files.php
  14. 0
    0
      websocket_print/vendor/composer/autoload_namespaces.php
  15. 0
    0
      websocket_print/vendor/composer/autoload_psr4.php
  16. 0
    0
      websocket_print/vendor/composer/autoload_real.php
  17. 0
    0
      websocket_print/vendor/composer/autoload_static.php
  18. 0
    0
      websocket_print/vendor/composer/installed.json
  19. 0
    0
      websocket_print/vendor/composer/installed.php
  20. 0
    0
      websocket_print/vendor/composer/platform_check.php
  21. 0
    0
      websocket_print/vendor/hoa/consistency/.State
  22. 0
    0
      websocket_print/vendor/hoa/consistency/.gitignore
  23. 0
    0
      websocket_print/vendor/hoa/consistency/.travis.yml
  24. 0
    0
      websocket_print/vendor/hoa/consistency/Autoloader.php
  25. 0
    0
      websocket_print/vendor/hoa/consistency/CHANGELOG.md
  26. 0
    0
      websocket_print/vendor/hoa/consistency/Consistency.php
  27. 0
    0
      websocket_print/vendor/hoa/consistency/Exception.php
  28. 0
    0
      websocket_print/vendor/hoa/consistency/Prelude.php
  29. 0
    0
      websocket_print/vendor/hoa/consistency/README.md
  30. 0
    0
      websocket_print/vendor/hoa/consistency/Test/Unit/Autoloader.php
  31. 0
    0
      websocket_print/vendor/hoa/consistency/Test/Unit/Consistency.php
  32. 0
    0
      websocket_print/vendor/hoa/consistency/Test/Unit/Exception.php
  33. 0
    0
      websocket_print/vendor/hoa/consistency/Test/Unit/Xcallable.php
  34. 0
    0
      websocket_print/vendor/hoa/consistency/Xcallable.php
  35. 0
    0
      websocket_print/vendor/hoa/consistency/composer.json
  36. 0
    0
      websocket_print/vendor/hoa/event/.State
  37. 0
    0
      websocket_print/vendor/hoa/event/.gitignore
  38. 0
    0
      websocket_print/vendor/hoa/event/Bucket.php
  39. 0
    0
      websocket_print/vendor/hoa/event/CHANGELOG.md
  40. 0
    0
      websocket_print/vendor/hoa/event/Event.php
  41. 0
    0
      websocket_print/vendor/hoa/event/Exception.php
  42. 0
    0
      websocket_print/vendor/hoa/event/Listenable.php
  43. 0
    0
      websocket_print/vendor/hoa/event/Listener.php
  44. 0
    0
      websocket_print/vendor/hoa/event/Listens.php
  45. 0
    0
      websocket_print/vendor/hoa/event/README.md
  46. 0
    0
      websocket_print/vendor/hoa/event/Source.php
  47. 0
    0
      websocket_print/vendor/hoa/event/Test/Unit/Bucket.php
  48. 0
    0
      websocket_print/vendor/hoa/event/Test/Unit/Event.php
  49. 0
    0
      websocket_print/vendor/hoa/event/Test/Unit/Exception.php
  50. 0
    0
      websocket_print/vendor/hoa/event/Test/Unit/Listenable.php
  51. 0
    0
      websocket_print/vendor/hoa/event/Test/Unit/Listener.php
  52. 0
    0
      websocket_print/vendor/hoa/event/Test/Unit/Listens.php
  53. 0
    0
      websocket_print/vendor/hoa/event/Test/Unit/Source.php
  54. 0
    0
      websocket_print/vendor/hoa/event/composer.json
  55. 0
    0
      websocket_print/vendor/hoa/exception/.State
  56. 0
    0
      websocket_print/vendor/hoa/exception/.gitignore
  57. 0
    0
      websocket_print/vendor/hoa/exception/CHANGELOG.md
  58. 0
    0
      websocket_print/vendor/hoa/exception/Error.php
  59. 0
    0
      websocket_print/vendor/hoa/exception/Exception.php
  60. 0
    0
      websocket_print/vendor/hoa/exception/Group.php
  61. 0
    0
      websocket_print/vendor/hoa/exception/Idle.php
  62. 0
    0
      websocket_print/vendor/hoa/exception/README.md
  63. 0
    0
      websocket_print/vendor/hoa/exception/Test/Unit/Error.php
  64. 0
    0
      websocket_print/vendor/hoa/exception/Test/Unit/Exception.php
  65. 0
    0
      websocket_print/vendor/hoa/exception/Test/Unit/Group.php
  66. 0
    0
      websocket_print/vendor/hoa/exception/Test/Unit/Idle.php
  67. 0
    0
      websocket_print/vendor/hoa/exception/composer.json
  68. 0
    0
      websocket_print/vendor/hoa/http/.gitignore
  69. 0
    0
      websocket_print/vendor/hoa/http/CHANGELOG.md
  70. 0
    0
      websocket_print/vendor/hoa/http/Exception/CrossBufferization.php
  71. 0
    0
      websocket_print/vendor/hoa/http/Exception/Exception.php
  72. 0
    0
      websocket_print/vendor/hoa/http/Http.php
  73. 0
    0
      websocket_print/vendor/hoa/http/Request.php
  74. 0
    0
      websocket_print/vendor/hoa/http/Response/Download.php
  75. 0
    0
      websocket_print/vendor/hoa/http/Response/Response.php
  76. 0
    0
      websocket_print/vendor/hoa/http/Runtime.php
  77. 0
    0
      websocket_print/vendor/hoa/http/composer.json
  78. 0
    0
      websocket_print/vendor/hoa/protocol/.State
  79. 0
    0
      websocket_print/vendor/hoa/protocol/.gitignore
  80. 0
    0
      websocket_print/vendor/hoa/protocol/Bin/Resolve.php
  81. 0
    0
      websocket_print/vendor/hoa/protocol/CHANGELOG.md
  82. 0
    0
      websocket_print/vendor/hoa/protocol/Exception.php
  83. 0
    0
      websocket_print/vendor/hoa/protocol/Node/Library.php
  84. 0
    0
      websocket_print/vendor/hoa/protocol/Node/Node.php
  85. 0
    0
      websocket_print/vendor/hoa/protocol/Protocol.php
  86. 0
    0
      websocket_print/vendor/hoa/protocol/README.md
  87. 0
    0
      websocket_print/vendor/hoa/protocol/Test/Unit/Exception.php
  88. 0
    0
      websocket_print/vendor/hoa/protocol/Test/Unit/Node/Library.php
  89. 0
    0
      websocket_print/vendor/hoa/protocol/Test/Unit/Node/Node.php
  90. 0
    0
      websocket_print/vendor/hoa/protocol/Test/Unit/Protocol.php
  91. 0
    0
      websocket_print/vendor/hoa/protocol/Test/Unit/Wrapper.php
  92. 0
    0
      websocket_print/vendor/hoa/protocol/Wrapper.php
  93. 0
    0
      websocket_print/vendor/hoa/protocol/composer.json
  94. 0
    0
      websocket_print/vendor/hoa/socket/.State
  95. 0
    0
      websocket_print/vendor/hoa/socket/.gitignore
  96. 0
    0
      websocket_print/vendor/hoa/socket/.travis.yml
  97. 0
    0
      websocket_print/vendor/hoa/socket/CHANGELOG.md
  98. 0
    0
      websocket_print/vendor/hoa/socket/Client.php
  99. 0
    0
      websocket_print/vendor/hoa/socket/Connection/Connection.php
  100. 0
    0
      websocket_print/vendor/hoa/socket/Connection/Group.php

+ 1
- 1
app/Http/Controllers/ThermalPrintingController.php View File

@@ -29,7 +29,7 @@ class ThermalPrintingController extends Controller
29 29
 
30 30
         try {
31 31
             $socket = new WebsocketClient(
32
-                new SocketClient('ws://127.0.0.1:5544')
32
+                new SocketClient('ws://43.230.131.149:5544')
33 33
             );
34 34
             $socket->setHost('escpos-server');
35 35
             $socket->connect();

+ 1
- 1
app/Http/Controllers/TransactionController.php View File

@@ -156,7 +156,7 @@ class TransactionController extends Controller
156 156
             try {
157 157
                 $socket->connect();
158 158
                 $socket = new WebsocketClient(
159
-                    new SocketClient('ws://127.0.0.1:5544')
159
+                    new SocketClient('ws://43.230.131.149:5544')
160 160
                 );
161 161
                 $socket->setHost('escpos-server');
162 162
                 $socket->send(json_encode($transaction));

print_server/ThermalPrinting.php → websocket_print/ThermalPrinting.php View File


+ 25
- 0
websocket_print/client.php View File

@@ -0,0 +1,25 @@
1
+<?php
2
+
3
+require_once __DIR__ . '/vendor/autoload.php';
4
+require_once __DIR__ . '/ThermalPrinting.php';
5
+
6
+try {
7
+    $socket = new Hoa\Websocket\Client(
8
+        new Hoa\Socket\Client('ws://43.230.131.149:5544')
9
+    );
10
+    $socket->setHost('escpos-server');
11
+    $socket->on('message', function (\Hoa\Event\Bucket $bucket) {
12
+        $data = $bucket->getData();
13
+        $response = $data['message'];
14
+        $rdata = json_decode($data['message']);
15
+        echo '> Received request ', $data['message'], "\n";
16
+
17
+        $thermalPrinting = new ThermalPrinting($rdata);
18
+        $thermalPrinting->startPrinting(2);
19
+        // return $response;
20
+     });
21
+    $socket->run();
22
+    $socket->receive();
23
+} catch (Exception $e) {
24
+    echo '> Error: ', $e->getMessage(), "\n";
25
+}

print_server/composer.json → websocket_print/composer.json View File


print_server/composer.lock → websocket_print/composer.lock View File


print_server/server.php → websocket_print/server.php View File

@@ -1,7 +1,7 @@
1 1
 <?php
2 2
 
3 3
 require_once __DIR__ . '/vendor/autoload.php';
4
-require_once __DIR__ . '/ThermalPrinting.php';
4
+// require_once __DIR__ . '/ThermalPrinting.php';
5 5
 
6 6
 try {
7 7
 
@@ -18,18 +18,20 @@ try {
18 18
 
19 19
     $websocket->on('message', function (Hoa\Event\Bucket $bucket) {
20 20
         $data = $bucket->getData();
21
-        $rdata = json_decode($data['message']);
21
+        // $rdata = json_decode($data['message']);
22 22
         echo '> Received request ', $data['message'], "\n";
23
+        $bucket->getSource()->send($data['message']);
24
+        $bucket->getSource()->broadcast($data['message']);
23 25
 
24
-        $thermalPrinting = new ThermalPrinting($rdata);
25
-        $thermalPrinting->startPrinting(2);
26
+        // $thermalPrinting = new ThermalPrinting($rdata);
27
+        // $thermalPrinting->startPrinting(2);
26 28
 
27 29
 
28 30
         // if ($rdata['type'] == 'print-receipt') {
29 31
         //     echo '> Printing receipt... ', $rdata['data'], "\n";
30 32
         // }
31 33
 
32
-        echo '> Done print task ', "\n";
34
+        // echo '> Done print task ', "\n";
33 35
         return;
34 36
     });
35 37
 

print_server/vendor/autoload.php → websocket_print/vendor/autoload.php View File


print_server/vendor/composer/ClassLoader.php → websocket_print/vendor/composer/ClassLoader.php View File


print_server/vendor/composer/InstalledVersions.php → websocket_print/vendor/composer/InstalledVersions.php View File


print_server/vendor/composer/LICENSE → websocket_print/vendor/composer/LICENSE View File


print_server/vendor/composer/autoload_classmap.php → websocket_print/vendor/composer/autoload_classmap.php View File


print_server/vendor/composer/autoload_files.php → websocket_print/vendor/composer/autoload_files.php View File


print_server/vendor/composer/autoload_namespaces.php → websocket_print/vendor/composer/autoload_namespaces.php View File


print_server/vendor/composer/autoload_psr4.php → websocket_print/vendor/composer/autoload_psr4.php View File


print_server/vendor/composer/autoload_real.php → websocket_print/vendor/composer/autoload_real.php View File


print_server/vendor/composer/autoload_static.php → websocket_print/vendor/composer/autoload_static.php View File


print_server/vendor/composer/installed.json → websocket_print/vendor/composer/installed.json View File


print_server/vendor/composer/installed.php → websocket_print/vendor/composer/installed.php View File


print_server/vendor/composer/platform_check.php → websocket_print/vendor/composer/platform_check.php View File


print_server/vendor/hoa/consistency/.State → websocket_print/vendor/hoa/consistency/.State View File


print_server/vendor/hoa/consistency/.gitignore → websocket_print/vendor/hoa/consistency/.gitignore View File


print_server/vendor/hoa/consistency/.travis.yml → websocket_print/vendor/hoa/consistency/.travis.yml View File


print_server/vendor/hoa/consistency/Autoloader.php → websocket_print/vendor/hoa/consistency/Autoloader.php View File


print_server/vendor/hoa/consistency/CHANGELOG.md → websocket_print/vendor/hoa/consistency/CHANGELOG.md View File


print_server/vendor/hoa/consistency/Consistency.php → websocket_print/vendor/hoa/consistency/Consistency.php View File


print_server/vendor/hoa/consistency/Exception.php → websocket_print/vendor/hoa/consistency/Exception.php View File


print_server/vendor/hoa/consistency/Prelude.php → websocket_print/vendor/hoa/consistency/Prelude.php View File


print_server/vendor/hoa/consistency/README.md → websocket_print/vendor/hoa/consistency/README.md View File


print_server/vendor/hoa/consistency/Test/Unit/Autoloader.php → websocket_print/vendor/hoa/consistency/Test/Unit/Autoloader.php View File


print_server/vendor/hoa/consistency/Test/Unit/Consistency.php → websocket_print/vendor/hoa/consistency/Test/Unit/Consistency.php View File


print_server/vendor/hoa/consistency/Test/Unit/Exception.php → websocket_print/vendor/hoa/consistency/Test/Unit/Exception.php View File


print_server/vendor/hoa/consistency/Test/Unit/Xcallable.php → websocket_print/vendor/hoa/consistency/Test/Unit/Xcallable.php View File


print_server/vendor/hoa/consistency/Xcallable.php → websocket_print/vendor/hoa/consistency/Xcallable.php View File


print_server/vendor/hoa/consistency/composer.json → websocket_print/vendor/hoa/consistency/composer.json View File


print_server/vendor/hoa/event/.State → websocket_print/vendor/hoa/event/.State View File


print_server/vendor/hoa/event/.gitignore → websocket_print/vendor/hoa/event/.gitignore View File


print_server/vendor/hoa/event/Bucket.php → websocket_print/vendor/hoa/event/Bucket.php View File


print_server/vendor/hoa/event/CHANGELOG.md → websocket_print/vendor/hoa/event/CHANGELOG.md View File


print_server/vendor/hoa/event/Event.php → websocket_print/vendor/hoa/event/Event.php View File


print_server/vendor/hoa/event/Exception.php → websocket_print/vendor/hoa/event/Exception.php View File


print_server/vendor/hoa/event/Listenable.php → websocket_print/vendor/hoa/event/Listenable.php View File


print_server/vendor/hoa/event/Listener.php → websocket_print/vendor/hoa/event/Listener.php View File


print_server/vendor/hoa/event/Listens.php → websocket_print/vendor/hoa/event/Listens.php View File


print_server/vendor/hoa/event/README.md → websocket_print/vendor/hoa/event/README.md View File


print_server/vendor/hoa/event/Source.php → websocket_print/vendor/hoa/event/Source.php View File


print_server/vendor/hoa/event/Test/Unit/Bucket.php → websocket_print/vendor/hoa/event/Test/Unit/Bucket.php View File


print_server/vendor/hoa/event/Test/Unit/Event.php → websocket_print/vendor/hoa/event/Test/Unit/Event.php View File


print_server/vendor/hoa/event/Test/Unit/Exception.php → websocket_print/vendor/hoa/event/Test/Unit/Exception.php View File


print_server/vendor/hoa/event/Test/Unit/Listenable.php → websocket_print/vendor/hoa/event/Test/Unit/Listenable.php View File


print_server/vendor/hoa/event/Test/Unit/Listener.php → websocket_print/vendor/hoa/event/Test/Unit/Listener.php View File


print_server/vendor/hoa/event/Test/Unit/Listens.php → websocket_print/vendor/hoa/event/Test/Unit/Listens.php View File


print_server/vendor/hoa/event/Test/Unit/Source.php → websocket_print/vendor/hoa/event/Test/Unit/Source.php View File


print_server/vendor/hoa/event/composer.json → websocket_print/vendor/hoa/event/composer.json View File


print_server/vendor/hoa/exception/.State → websocket_print/vendor/hoa/exception/.State View File


print_server/vendor/hoa/exception/.gitignore → websocket_print/vendor/hoa/exception/.gitignore View File


print_server/vendor/hoa/exception/CHANGELOG.md → websocket_print/vendor/hoa/exception/CHANGELOG.md View File


print_server/vendor/hoa/exception/Error.php → websocket_print/vendor/hoa/exception/Error.php View File


print_server/vendor/hoa/exception/Exception.php → websocket_print/vendor/hoa/exception/Exception.php View File


print_server/vendor/hoa/exception/Group.php → websocket_print/vendor/hoa/exception/Group.php View File


print_server/vendor/hoa/exception/Idle.php → websocket_print/vendor/hoa/exception/Idle.php View File


print_server/vendor/hoa/exception/README.md → websocket_print/vendor/hoa/exception/README.md View File


print_server/vendor/hoa/exception/Test/Unit/Error.php → websocket_print/vendor/hoa/exception/Test/Unit/Error.php View File


print_server/vendor/hoa/exception/Test/Unit/Exception.php → websocket_print/vendor/hoa/exception/Test/Unit/Exception.php View File


print_server/vendor/hoa/exception/Test/Unit/Group.php → websocket_print/vendor/hoa/exception/Test/Unit/Group.php View File


print_server/vendor/hoa/exception/Test/Unit/Idle.php → websocket_print/vendor/hoa/exception/Test/Unit/Idle.php View File


print_server/vendor/hoa/exception/composer.json → websocket_print/vendor/hoa/exception/composer.json View File


print_server/vendor/hoa/http/.gitignore → websocket_print/vendor/hoa/http/.gitignore View File


print_server/vendor/hoa/http/CHANGELOG.md → websocket_print/vendor/hoa/http/CHANGELOG.md View File


print_server/vendor/hoa/http/Exception/CrossBufferization.php → websocket_print/vendor/hoa/http/Exception/CrossBufferization.php View File


print_server/vendor/hoa/http/Exception/Exception.php → websocket_print/vendor/hoa/http/Exception/Exception.php View File


print_server/vendor/hoa/http/Http.php → websocket_print/vendor/hoa/http/Http.php View File


print_server/vendor/hoa/http/Request.php → websocket_print/vendor/hoa/http/Request.php View File


print_server/vendor/hoa/http/Response/Download.php → websocket_print/vendor/hoa/http/Response/Download.php View File


print_server/vendor/hoa/http/Response/Response.php → websocket_print/vendor/hoa/http/Response/Response.php View File


print_server/vendor/hoa/http/Runtime.php → websocket_print/vendor/hoa/http/Runtime.php View File


print_server/vendor/hoa/http/composer.json → websocket_print/vendor/hoa/http/composer.json View File


print_server/vendor/hoa/protocol/.State → websocket_print/vendor/hoa/protocol/.State View File


print_server/vendor/hoa/protocol/.gitignore → websocket_print/vendor/hoa/protocol/.gitignore View File


print_server/vendor/hoa/protocol/Bin/Resolve.php → websocket_print/vendor/hoa/protocol/Bin/Resolve.php View File


print_server/vendor/hoa/protocol/CHANGELOG.md → websocket_print/vendor/hoa/protocol/CHANGELOG.md View File


print_server/vendor/hoa/protocol/Exception.php → websocket_print/vendor/hoa/protocol/Exception.php View File


print_server/vendor/hoa/protocol/Node/Library.php → websocket_print/vendor/hoa/protocol/Node/Library.php View File


print_server/vendor/hoa/protocol/Node/Node.php → websocket_print/vendor/hoa/protocol/Node/Node.php View File


print_server/vendor/hoa/protocol/Protocol.php → websocket_print/vendor/hoa/protocol/Protocol.php View File


print_server/vendor/hoa/protocol/README.md → websocket_print/vendor/hoa/protocol/README.md View File


print_server/vendor/hoa/protocol/Test/Unit/Exception.php → websocket_print/vendor/hoa/protocol/Test/Unit/Exception.php View File


print_server/vendor/hoa/protocol/Test/Unit/Node/Library.php → websocket_print/vendor/hoa/protocol/Test/Unit/Node/Library.php View File


print_server/vendor/hoa/protocol/Test/Unit/Node/Node.php → websocket_print/vendor/hoa/protocol/Test/Unit/Node/Node.php View File


print_server/vendor/hoa/protocol/Test/Unit/Protocol.php → websocket_print/vendor/hoa/protocol/Test/Unit/Protocol.php View File


print_server/vendor/hoa/protocol/Test/Unit/Wrapper.php → websocket_print/vendor/hoa/protocol/Test/Unit/Wrapper.php View File


print_server/vendor/hoa/protocol/Wrapper.php → websocket_print/vendor/hoa/protocol/Wrapper.php View File


print_server/vendor/hoa/protocol/composer.json → websocket_print/vendor/hoa/protocol/composer.json View File


print_server/vendor/hoa/socket/.State → websocket_print/vendor/hoa/socket/.State View File


print_server/vendor/hoa/socket/.gitignore → websocket_print/vendor/hoa/socket/.gitignore View File


print_server/vendor/hoa/socket/.travis.yml → websocket_print/vendor/hoa/socket/.travis.yml View File


print_server/vendor/hoa/socket/CHANGELOG.md → websocket_print/vendor/hoa/socket/CHANGELOG.md View File


print_server/vendor/hoa/socket/Client.php → websocket_print/vendor/hoa/socket/Client.php View File


print_server/vendor/hoa/socket/Connection/Connection.php → websocket_print/vendor/hoa/socket/Connection/Connection.php View File


print_server/vendor/hoa/socket/Connection/Group.php → websocket_print/vendor/hoa/socket/Connection/Group.php View File


Some files were not shown because too many files changed in this diff