Thruway | PHP Client and Router Library | Websocket library
kandi X-RAY | Thruway Summary
kandi X-RAY | Thruway Summary
PHP Client and Router Library for Autobahn and WAMP (Web Application Messaging Protocol) for Real-Time Application Messaging
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Process Hello message
- Handles Hello authentication .
- Checks if an action is authorized by a set of roles
- Get the invocation message
- Process invocation error .
- Get all sessions
- On HTTP request .
- Process a subscribe message
- Handle the start of the router .
- Add a registration message to the procedure .
Thruway Key Features
Thruway Examples and Code Snippets
Community Discussions
Trending Discussions on Thruway
QUESTION
I have a job that times out and once it fails it dispatches another one just like itself so that it can run infinitely and without overlapping. However the job that fails stays in the queue and gets re-tried so I eventually have more than one job running which breaks the whole purpose.
Here is how I handle the failing of the job:
...ANSWER
Answered 2019-Jul-04 at 21:08The reason why failed is not executed, it is only triggered when a job exceeds it's maximum tries. The flow looks something like this.
QUESTION
I have this JSON response:
...ANSWER
Answered 2019-Sep-22 at 13:23Change this:
QUESTION
I am trying to import a CSV from Dropbox into RStudio Cloud and it seems that RStudio is not reading the file correctly. The dataset has 7 columns, 5 million+ rows of toll collection data but the RStudio seems to be pulling something completely different.
I downloaded the CSV from https://data.ny.gov/Transportation/NYS-Thruway-Origin-and-Destination-Points-for-All-/chzq-388p onto my computer and then uploaded the file to Dropbox. The Dropbox file link for the file is https://www.dropbox.com/s/y76m7r7wuzlj7oo/NYS_Thruway_Origin_and_Destination_Points_for_All_Vehicles_-_1_Hour_Intervals__2019%20%283%29.csv?dl=0.
I have used both rempis and read.csv to load the file but RStudio is not reading the data set. Instead of the data set, RStudio Cloud is instead reading a file with two columns (row.names and X.Docutype).
Using read.csv:
...ANSWER
Answered 2019-Apr-22 at 14:04You need to find a better link. You can troubleshoot by using readLines("https://...")
instead of read.csv
(beware, don't dump the whole thing to the console, it's annoyingly big). The character vector is 211 long (for me), and the first few lines start with:
QUESTION
I try to set up a websocket server via Thruway which can manage multiple groups. Something like a chat application where each client may subscribe to one or multiple ones at the same time and broadcast messages to an entire chat room. I managed to do that with an ancient version of Ratchet but since it doesn't run very smooth, I wanted to switch to Thruway. Sadly I can't find anything to manage groups. So far I have the following as the websocket-manager and the clients are using the current version of Autobahn|js (18.x).
Does anyone have any clue if it is possible to manage subscription groups with something like the following?
...ANSWER
Answered 2018-May-07 at 17:50With ThruWay, things are a little different than old Ratchet. First of all Thruway is not a WAMP Server. It is just a router. So it doesn't have a server instance like old Rathcet has lets you wrap all your server side functionality wrapped up. But it will only get the message packet and will route
them to other sessions in same realm depending on their subscriptions. If you ever used socket.io, realm idea is similar to different connections so you can limit your sessions or connections to a single namespace or split functionality of different socket instances like administration, visitors etc.
On client side with autobahn ( latest version ) once you subscribe to a topic, then publish in that topic, thruway will automatically detect topic subscribers and emit message to them in same realm. But in old ratchet you need to handle this manually by keeping an array of available channels, and add users to each channel when they subscribes as well as broadcast message to these users in topic by iterating over them. This was really painful.
If you want to use RPC calls in server side and don't want to include some of your stuff on client side, you can still use a class called internalClient on server side. Conceptually Internal Client is another session connects to your thruway client and handles some functions internally without exposing other clients. It receives message packages and does stuff in it then returns result back to requested client connection. It took a while for me to understand how it works but once I figured out the idea behind made more sense.
so little bit code to explain better,
In your router instance you will need to add a module, ( note that, in voxys/thruway package examples are little confusing about internal client )
server.php
QUESTION
How can I get rid of the following warning out in my project? My team doesn't have this warning like me.
...npm WARN @angular/compiler-cli@5.0.1 requires a peer of typescript@>=2.4.2 <2.5 but none is installed. You must install peer dependencies yourself.
npm WARN angular2-daterangepicker@0.0.5 requires a peer of @angular/core@2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angular2-daterangepicker@0.0.5 requires a peer of bootstrap@^3.3.6 but none is installed. You must install peer dependencies yourself.
npm WARN angular2-daterangepicker@0.0.5 requires a peer of jquery@^2.2.4 but none is installed. You must install peer dependencies yourself.
npm WARN angular2-daterangepicker@0.0.5 requires a peer of rxjs@5.0.0-beta.6 but none is installed. You must install peer dependencies yourself.
npm WARN angular2-daterangepicker@0.0.5 requires a peer of zone.js@^0.6.12 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-daterangepicker@2.0.12 requires a peer of @types/jquery@^3.2.12 but none is installed. You must install peer dependencies yourself.
npm WARN thruway.js@1.2.13 requires a peer of ws@^2.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN tsickle@0.24.1 requires a peer of typescript@2.4.2 but none is installed. You must install peer dependencies yourself.
ANSWER
Answered 2017-Nov-15 at 11:51You can try updating all angular packages as follows:
QUESTION
I want to develop real time chat with channels and these are my needs:
- PHP backend to manage site
- Redis as session and data primary storage
- Pub/Sub to send messages only to channel's interested users
- one WebSocket connection with which the messages will be send and received.
- (optional) NodeJS to use great npm packages like timesync or socket.io
I see two different architectures to achieve this:
with Socket.io
with Crossbar.io
These are my questions:
- Which architecture I should choose and why?
- The key is the user id cannot be obtained from client, because it can be malformed. So in the first architecture I think on every socket message I should attach PHPSESSID value from cookie and on sever-side retrieve PHP session from Redis. Am I right or there is better way to get user id?
- I wonder if getting user id in second architecture can be done differently?
Edit:
I choosed Crossbar.io, cause it is very powerful and allows to communicate many different language applications in real time. After studying examples, I come up with this:
On every login user have generated secret key in database.
PHP client (Thruway) connect to Crossbar server and register custom WAMP-CRA authenticator
User's browser connect to Crossbar server and is challenged. Secret and auth_id (user id) are loaded from DB with page load, so it can accomplish challenge and send response.
PHP authenticator search in DB for user with provided secret and id equal to auth_id. If there is, then it successfully authenticate session. Now we can trust that auth_id is real user id.
These are my question:
How I can get auth_id on subscribe?
I also added cookie authentication and browser is remembered after authentication. But when I look in Chrome DevTools there is any cookie nor value in local storage. Even after clearing cache my browser is still remember by Crossbar. I wonder how it is possible?
Edit2:
Maybe I was misunderstood, but the main question was choosing appropriate architecture and getting trusted user id. There was no attention so I awarded bounty and after that I was downvoted. I read a lot about real-time apps and finally decided to use Crossbar.io, so I edited question to be related to it. Then people started upvoting, proposing another architectures, but not really answering my questions. After all I managed to do it myself and presented my answer.
...ANSWER
Answered 2017-Mar-17 at 10:13PHP Ratchet is one of the best implementations I've used for real-time communications via WebSockets. Its based on ZMQ Sockets which is used in several online gaming applications and chat applications.
The following examples will get you started pretty quick and will answer your questions around auth_id and subscriptions:
http://socketo.me/docs/hello-world
Overview of the Architecture:
http://socketo.me/docs/push#networkarchitecture
I would advice creating individual connections(toppics) per conversation as it doesn't really take a hit on performance and will add an additional layer of security per chat.
QUESTION
I want to use websocket for a voting application. There is two parts: one is a chat channel and an other one is a command channel where information about the question, the available answers, the countdown etc will travel.
On the client side, I use Autobahn|JS as library. I can subscribe to my two channels easily (I can see it on server logs)
On the server side, I use Thruway because it's WAMP v2 compliant.
My problem: I don't know how I can hook the messages on the server side to broadcast them on each topics. Seems easy but I can find any solution.
I guess it's by using InternalClient, but I am not really sure…
Some code:
JS Client
...ANSWER
Answered 2017-Jan-06 at 22:24class TestInternalClient extends Thruway\Peer\Client {
public function __construct() {
parent::__construct('com.test.dev');
}
public function onSessionStart($session, $transport) {
echo "--------------- Hello from InternalClient ------------\n";
$session->subscribe('chat.test', function ($args, $kwArgs, $options) use ($session) {
// Get message contents
$token = $args[0]->token;
$message = $args[0]->message;
// publish to other people
$session->publish('some.topic', [[ 'message' => $message ]]);
});
//////////////////////////////////////////
// Subscribe to everything in the system
$session->subscribe('', function ($args, $argsKw, $details, $publicationId) {
$value = isset($args[0]) ? $args[0] : '';
echo 'Received ' . json_encode($value) . ' on topic ' . $details->topic . PHP_EOL;
}, [ 'match' => 'prefix' ]);
}
}
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Thruway
PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page