Code Monkey home page Code Monkey logo

Comments (9)

allinurl avatar allinurl commented on May 17, 2024

You should be able to. But it depends how redis outputs its data. gwsocket simply uses a file descriptor, so you could handle it differently in here. Do you know how redis outputs the results? If you could pipe the results of a command then you are golden...

from gwsocket.

KabDeveloper avatar KabDeveloper commented on May 17, 2024

Thank you for your answer !

I think it's possible to implement REDIS using your script, here is the REDIS client in C:
https://github.com/EulerianTechnologies/eredis
OR one of this clients:
https://redis.io/clients#c

Since my level in C is very low, it would be possible to catch new entered values on REDIS using this code in PHP:

$r = new Redis();
$r->connect("127.0.0.1", "6379");

while(true){
    while($xdata = $r->spop("data_pipe")){
        $data = unserialize($xdata);

        // Send the data
        // Here a code to send the data to client's browser
    }

    // No more data
    sleep(30);
}

What is the part of your code that is responsible to read the file and return the LINE & Send it ?

Thank you again

from gwsocket.

allinurl avatar allinurl commented on May 17, 2024

If you want to handle this with PHP, you could keep doing what you are doing and output the data in PHP to the gwosocket fifo. It should work fine. Please take a look at these examples

from gwsocket.

KabDeveloper avatar KabDeveloper commented on May 17, 2024

I already checked that, but fetching datas from REDIS and then writting them each time to a file will take more time than returning them directly from REDIS to websocket.

Since there a way doing it in C then i bet on this, i need only to identify the part of code responsible to:
1- Read the file line by line
2- The code that return the line and then send it to websocket

There will be many users interested on this combination, with small help i will be able to achieve this and post it here or in a fork.

Thank's :)

from gwsocket.

allinurl avatar allinurl commented on May 17, 2024

It's all in here. Reads, writes and accept. Let me know how it goes. Thanks.

from gwsocket.

KabDeveloper avatar KabDeveloper commented on May 17, 2024

Thank you for your help !

Last question please, when your script read the lines from the file ... do it remove the lines when it send it to the clients ?

from gwsocket.

allinurl avatar allinurl commented on May 17, 2024

Yes it does that automatically.

from gwsocket.

KabDeveloper avatar KabDeveloper commented on May 17, 2024

What is the line responsible for doing that please ?

What if new lines added while he is sending to clients ? There will be no disfunction or no error ?

from gwsocket.

allinurl avatar allinurl commented on May 17, 2024

What is the line responsible for doing that please ?

https://github.com/allinurl/gwsocket/blob/master/src/websocket.c#L532

What if new lines added while he is sending to clients ? There will be no disfunction or no error ?
It will handle that just fine.

from gwsocket.

Related Issues (20)

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.