Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Andrej Lamov
    @andrejlamov
    Hi!
    Andrej Lamov
    @andrejlamov
    Playing around with akka-wamp. Is it possible to publish from within a subscribe handler?
     subscription <- session.subscribe("counter") {
          _.payload.map(_.arguments.map{
            args =>
            println(args)
            session.publish (
              topic = "somedata",
              acknowledge = true,
              payload = Some(Payload(List("hello")))
            )
        }
      )
    The whole App gets stuck after the first publish.
    Maybe I got the whole monadic Future thing wrong?
    Andrej Lamov
    @andrejlamov
    @angiolep
    Andrej Lamov
    @andrejlamov
    Ok, got it working.
    Andrej Lamov
    @andrejlamov
    Just removed the acknowledge flag.
    Paolo Angioletti
    @angiolep
    Hi Andrej, thanks for playing with akka-wamp
    I just released a new version 0.8.0 with many improvements
    Publishing from within an event handler? To be honest I never tried ... I'm just writing a unit test for it and let you know if there's something wrong
    Cheers
    Paolo Angioletti
    @angiolep
    object PublishWithinEventHandler extends App {
    
      import akka.wamp.client._
      val client = Client()
    
      implicit val ec = client.executionContext
    
      for {
        session1 <- client.openSession(
          url = "ws://127.0.0.1:8080/router")
        sub1 <- session1.subscribe(
          topic = "tick")(
          event => 
            session1.publish(
              topic = "greetings",
              ack = true, 
              data = List("Hello!"))
        )
      } yield ()
    
    
      val session2 = 
        for {
          session2 <- client.openSession(
            url = "ws://127.0.0.1:8080/router")
          subscription2 <- session2.subscribe(
            topic = "greetings") (
            event => 
              event.data.map(println)
          )
        } yield session2
    
    
      // Publish to tick so to trigger the above subscriber1
      session2.map(_.publish(topic="tick"))
    }
    I just gave you a working Scala application to publish events from within an event handler
    Paolo Angioletti
    @angiolep
    Hi everyone, akka-wamp now support TLS/SSL WebSockets and provides a nice API for Java 8 developers too!
    Andrii B.
    @421p
    Hi @angiolep ! is it possible to provide some configurations to futures-based client? For now it's not possible to use 2 clients on the same actor system b/c of hardcoded actor name
    Gergő Törcsvári
    @tg44

    so I want to use this lib to connect to poloniex wamp feed, and beside I will PR some subscribe function with more parameters, I have a small code with a lot of warn:

     def main(args: Array[String]): Unit = {
        val system = ActorSystem()
        val client = Client(system)
        implicit val executionContext = system.dispatcher
    
        client.connect("wss://api.poloniex.com","json").map { conn =>
          conn.open("realm1").map { implicit session =>
            subscribe("BTC_XMR", (arg1: AnyRef) => {
              println(s"got $arg1")
            })
          }
        }
      }

    And I get these:

    22:33:47.800 |-WARN  in a.w.c.Connector - !!! akka.wamp.client.ClientException: Couldn't invoke lambda consumer for 'BTC_XMR': key not found: arg1
    got Map(type -> orderBookModify, data -> Map(type -> ask, amount -> 55.60500000, rate -> 0.01083997))
    22:33:48.116 |-WARN  in a.w.c.Connector - !!! akka.wamp.client.ClientException: Couldn't invoke lambda consumer for 'BTC_XMR': key not found: arg1
    got Map(type -> orderBookRemove, data -> Map(type -> ask, rate -> 0.01083999))
    22:33:48.332 |-WARN  in a.w.c.Connector - !!! akka.wamp.client.ClientException: Couldn't invoke lambda consumer for 'BTC_XMR': key not found: arg1
    22:33:48.359 |-WARN  in a.w.c.Connector - !!! akka.wamp.client.ClientException: Couldn't invoke lambda consumer for 'BTC_XMR': key not found: arg1

    Any useful idea?

    Gergő Törcsvári
    @tg44
    looool
    why this complicated this api?
    instead of that 30 line macro you could add a more simpler implementation and let the programmer choose what to do with args and kwargs
    Gergő Törcsvári
    @tg44
    or just under documented
    Paolo Angioletti
    @angiolep
    @421p Hi. Thanks for using akka-wamp. In version 0.15.x you can create two client instances passing the same actor system
    @421p Please advice which kind of configuration you wish to add, so we can create a new GitHub issue for it
    Paolo Angioletti
    @angiolep
    @tg44 Following example demonstrates how to subscribe and event handler to the Poloniex feed without Scala macros (as you would normally do with other WAMP libraries)
    @tg44 Please note
    session.subscribe("BTC_XMR", event =>  
      // access event.kwargs ... no macro here ;-) 
    }
    That's just an event consumer with no macro expansion as I (badly) tried to explain in http://angiolep.github.io/projects/akka-wamp/client/futures.html#consumer
    In addition to that, I also introduced some Scala macros in akka-wamp in the hope to provide a simpler API to users (where complexity is hidden inside the macro definition) ... but ... unfortunately I didn't documented it properly ... and maybe not achieved my objective .. yet :-(
    Next version (0.16.0) will come with better docs and examples
    Paolo Angioletti
    @angiolep
    Any advice is welcome. Cheers
    Gergő Törcsvári
    @tg44
    Thx I found that out just not as fast as I wanted first :P
    Bojan Šernek
    @baadc0de
    @angiolep is it possible to integrate the router with an akka-http application?
    Paolo Angioletti
    @angiolep
    At the moment it is NOT possible. I filed a new GitHub issue for it angiolep/akka-wamp#49
    chandru-jsr
    @chandru-jsr
    Even , i see this problem, which has only waning when i ran PoloniexScalaClient
    But no messages consuming
    Gergo, is it working for you Sir?
    thetuyo
    @thetuyo
    All, is there a simple way (without forking the code, or configuring in applications.conf) to create a Router for a specific end point programatically ?