Giter Club home page Giter Club logo

Comments (10)

surendratiwari3 avatar surendratiwari3 commented on May 14, 2024

hi i added the pub-sub support. but there is one thing you have to open 2 redis connection 1 will listen for subscribe (redis messages) and other is used to do command to redis.

from redis.

surendratiwari3 avatar surendratiwari3 commented on May 14, 2024

but in the main.swift you need to make changes as per your requirements.

from redis.

jazeelkt avatar jazeelkt commented on May 14, 2024

@surendratiwari3 Can you please provide an example on how to use your implementation?

from redis.

surendratiwari3 avatar surendratiwari3 commented on May 14, 2024

do {
try client.command("SUBSCRIBE", params: ["hello"])

    print("Sending 'PING' to Redis server at \(client1.address):\(client1.port)")
    let response11 = try client1.command("PING", params: []).toString()
    print("Response: \(response11)")

    while true
    {
            let response2 = try client.read().toArray()
            var count = 0
            for element in response2
            {
                    count = count+1
                    let content = (element as! RespBulkString).content
                    if count==3
                    {
                            //published key
                            print(content)
                            //sending the command to redis
                            print("Sending HMGET \(content) to Redis server at \(client1.address):\(client1.port)")
                            let balance_res = try client1.command("HMGET", params: ["\(content)", "balance"]).toArray()
                            //get the balance from the redis
                            for ebal in balance_res
                            {
                                    let bal = (ebal as! RespBulkString).content
                                    print("Response: \(bal)")
                            }
                    }
            }
    }

} catch {
print("Encountered error (error)")
fatalError("(error)")
}

from redis.

surendratiwari3 avatar surendratiwari3 commented on May 14, 2024

please declare the client and client1 like this:

let client = try Redbird()
let client_ip = try Redbird(config: RedbirdConfig(address: "127.0.0.1"))

let client1 = try Redbird()
let client_ip1 = try Redbird(config: RedbirdConfig(address: "127.0.0.1"))

from redis.

jazeelkt avatar jazeelkt commented on May 14, 2024

Thanks @surendratiwari3 , got it working. Great job !!

from redis.

surendratiwari3 avatar surendratiwari3 commented on May 14, 2024

will you please do the same comment in the my pull request so they will accept it. and also please endorse me on linkledin . https://www.linkedin.com/in/surendra-tiwari-ab569a15?trk=nav_responsive_tab_profile
please also give comment also on linkedin

from redis.

cwoloszynski avatar cwoloszynski commented on May 14, 2024

I'm looking to dynamically change the list of topics that my pubsub connection subscribes to. It appears that the current Redbird code only lets me subscribe to one topic and then blocks.

Is there any way to allow me to send additional commands (subscribe/unsubscribe) while I am listening for messages using Redbird?

from redis.

surendratiwari3 avatar surendratiwari3 commented on May 14, 2024

yeah i provided a way to achieve that just take my pull request and enjoy!

from redis.

tanner0101 avatar tanner0101 commented on May 14, 2024

Added in #56

from redis.

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.