|
| 1 | +# DEMO 1: |
| 2 | + |
| 3 | +##### Purpose: have a router, have a realm with authentication, internal client registering RPC methods, call the RPC methos usin internal client 2 and browser client. |
| 4 | + |
| 5 | +**This demo consists of:** |
| 6 | + |
| 7 | +* Router: based on Examples/SimpleWsRouter.php |
| 8 | +* Realm Authentication: based on Examples/Authentication/SimpleAuthProviderClient.php |
| 9 | +* Internal Client 1: based on Examples/ClientClass/FreeSpaceClient.php |
| 10 | +* Autobahn client: based on the autobahn-js [repo](https://github.com/crossbario/autobahn-js) and Examples/Authentication/simpleAutobahnAuth.html |
| 11 | +* Internal Client 2 (connection object): based on Examples/SimpleClient.php |
| 12 | + |
| 13 | + |
| 14 | +### How to use demo 1 |
| 15 | + |
| 16 | +Open 3 terminals and a browser tab with console in js option (F12 in Chrome, select js tab) |
| 17 | + |
| 18 | +navigate to root dir, at the same level of composer.json, |
| 19 | +so if you do ls/dir command, you should see composer.json |
| 20 | + |
| 21 | +**in terminal 1:** |
| 22 | + |
| 23 | +> php DEMO1/bin/router.php |
| 24 | +
|
| 25 | +This will launch the router, add auth manager and auth client, and add transport provider. |
| 26 | + |
| 27 | + |
| 28 | +**in terminal 2:** |
| 29 | + |
| 30 | +> php DEMO1/bin/launchInternalClient.php |
| 31 | +
|
| 32 | +This will start the internal client using an instance of the InternalClient.php, using a client authenticator to enter the realm. |
| 33 | + |
| 34 | + |
| 35 | +**in terminal 3**, choose one of the following, but try them all at least once: |
| 36 | + |
| 37 | +All of these act like a second internal client. the idea is that internal client 2 can be used by the main app to interface with the WAMP server. |
| 38 | + |
| 39 | + |
| 40 | +**option 1**, using use Thruway\Connection object: |
| 41 | + |
| 42 | +> php DEMO1/bin/launchInternalClientAsConnectionObject.php |
| 43 | +
|
| 44 | + |
| 45 | +**option 2**, using Thruway\Peer\Client object: |
| 46 | + |
| 47 | +> php DEMO1/bin/launchInternalClientAsClientObject.php |
| 48 | +
|
| 49 | + |
| 50 | +**option 3** using Thruway\Peer\Client subclass: |
| 51 | + |
| 52 | +> php bin/launchInternalCLient2.php |
| 53 | +
|
| 54 | +**in browser:** in file index.php in a script tag there is a function defined, in the console in JS tab, call the function |
| 55 | +> runConnectionObjectUsingAjax(); |
0 commit comments