rxphp / rxwebsocket Goto Github PK
View Code? Open in Web Editor NEWWebsockets for PHP using Rx
Websockets for PHP using Rx
The RFC classes were pulled out of https://github.com/ratchetphp/RFC6455 while waiting for a release. Now that there is a release we can reintegrate that package.
Should rework this area and maybe not use a subject:
RxWebsocket/src/Websocket/Server.php
Line 134 in 2a8c361
Hello,
I've attempted to use your package to set up a simple server to print a message, hello. I have failed to get any output on the console or in the browser. My code appears as follows:
$server = new Rx\Websocket\Server('127.0.0.1:8020');
$server->subscribe(
function (Rx\Websocket\MessageSubject $subject) {
$subject->subscribe(
function ($message) {
echo $message . PHP_EOL;
}
);
$sayHello = function () use ($subject) {
$subject->onNext('Hello');
};
$sayHello();
\EventLoop\addPeriodicTimer(5, $sayHello);
},
function ($error) {
echo "Connection Error";
},
function () {
echo "Completed";
}
);
I do however get a 500 server error.
Currently it isn't possible to use this package together with react/http 0.8
With the following:
$client = new \Rx\Websocket\Client('ws://127.0.0.1:9090/ws');
$client->subscribe(function (MessageSubject $ms) {
$disp = $ms->subscribe();
addTimer(2, function () use ($disp) {
echo "Dispose...\n";
$disp->dispose();
});
});
The websocket should close when there are no more subscriptions.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.