by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jul 28 13:21
    pmukhin commented #44
  • Jun 25 07:21
    bellatoris starred Spinoco/fs2-http
  • May 11 14:59
    mfirry commented #43
  • May 05 18:37
    FXHibon starred Spinoco/fs2-http
  • May 03 08:19
    AdamChlupacek synchronize #44
  • May 03 08:19

    AdamChlupacek on upgrade-to-fs2.3

    Address review comments, remove… (compare)

  • May 02 18:40
    AdamChlupacek synchronize #44
  • May 02 18:40

    AdamChlupacek on upgrade-to-fs2.3

    Fix travis dependencies. (compare)

  • May 02 18:35

    AdamChlupacek on 0.5

    Fix travis dependencies. (compare)

  • May 02 18:33
    AdamChlupacek review_requested #44
  • May 02 18:33
    AdamChlupacek review_requested #44
  • May 02 18:33
    AdamChlupacek opened #44
  • May 02 18:27

    AdamChlupacek on upgrade-to-fs2.3

    Setting version to 0.4.0-SNAPSH… Updated to fs2 1.0.0 final Fixes #29 and 16 more (compare)

  • May 02 18:14

    AdamChlupacek on 0.5

    Merge branch 'series/0.4' of gi… (compare)

  • May 02 18:09

    AdamChlupacek on upgrade-to-fs2.3

    Migrate fs2-http to fs2 2.3.0 +… (compare)

  • Apr 23 07:28
    nebtrx starred Spinoco/fs2-http
  • Apr 10 12:43
    mfirry opened #43
  • Apr 10 12:31
  • Feb 21 01:06
    vascorsd starred Spinoco/fs2-http
  • Jan 19 16:13
    jhnsmth commented #42
Pavel Chlupacek
@pchlupacek
@srnb_gitlab sorry this somehow went under radar. I guess you are talking about the client. Un that case you just simply analyze the returned error code, and then you may decide to process body depending ob that code.
Soren
@srnb_gitlab
@lJoublanc Yeah, I think that helps.
I'm still wholly confused on the websocket stuff though
Luciano
@lJoublanc
Hmmm. Do you get how to 'post' on standard http?
i.e. that you need to use a flatMap for this too?
It should be similar for websocket, I suspect.
Soren
@srnb_gitlab
Websockets are just Pipe[F, Frame[String], Frame[String]] and the http client just makes a request using that pipe
I want client code to be able to call myClient.pushWSEvent(e) somehow and I'm not understanding how to work that into a Pipe
Luciano
@lJoublanc
Yeah, sorry. I just read that now. I haven't used this feature before.
Ok, that I think I can help with.
Soren
@srnb_gitlab
This is probably a basic fs2 thing I need to learn about, right?
Luciano
@lJoublanc
Yes, you can ask about that in the fs2 channel. It's a common pattern: create a stream out of a callback. That's what you're doing right?
Soren
@srnb_gitlab
Well ok so
I'm getting events in from the websocket
Luciano
@lJoublanc
In that case I suggest you look at the guide, linked from README.md. At the end there is examples of "how to talk to the external world"
Soren
@srnb_gitlab
I match those to some set of event handlers
Luciano
@lJoublanc
Ah ok... In that case, let me see ...
Soren
@srnb_gitlab
And the event handlers should be able to have an effect on what is sent through the WS
Luciano
@lJoublanc
Yeah, I think this is straightforward. Create a pipe like this:
in => in.evalMap( x => IO {mycallback(x) } )
You need to use evalMap rather than map to show there is a side-effect (your callback).
The input type in will be a stream from the websocket. The output type will be the return type of your callback.
Does that make sense?
You'll also need to implement codecs for Frame according to the readme. I.e. this translates between the binary representation sent to the server, and your scala objects. You can get help for that on the scodec channel; I can help out here too.
Soren
@srnb_gitlab
It's just Json in this case, I'll be using Circe to parse
Soren
@srnb_gitlab
So does that mean every event handler needs to be fed an IO with some sort of callback?
I don't understand how that helps event handlers to send things to the WS
Adam Chlupacek
@AdamChlupacek
@srnb_gitlab Sending to WS and processing messages from WS is usually done via queues. That way you can direct the data where ever you want.
Soren
@srnb_gitlab
Apparently the websocket docs are way out of date; Stream#mergeDrainL no longer exists meaning I can't follow what those docs do
Luciano
@lJoublanc
I think this can be replaced with concurrently without probs.
(you may have to swap the arguments possibly).
Soren
@srnb_gitlab
Well, I'm not getting errors
case class EventSocket[F[_]](myShard: Int, maxShards: Int, queue: Queue[F, Event])(implicit concurrent: Concurrent[F]) {

  def wsPipe(matcher: EventMatcher, handler: PartialFunction[Event, Option[Event]]): Pipe[F, Frame[String], Frame[String]] = { inbound =>
    val output = queue.dequeue.map(e => Frame.Text(e.asJson.noSpaces))
    output.concurrently(inbound.flatMap { in =>
      val json: Json = parse(in.a).right.toOption.get
      val matched: Stream[F, Option[Event]] = matcher[F](json)
      val handeled: Stream[F, Option[Event]] = matched.map(_.flatMap(handler))
      val queued: Stream[F, Unit] = handeled.flatMap(_.fold[Stream[F, Unit]](Stream.empty)(e => Stream.eval(queue.enqueue1(e))))
      queued
    })
  }

}
Am I doing this correctly?
Luciano
@lJoublanc
Just check the concurrently signature in the scaladoc; make sure it matches mergeDrainL i.e. the Nothing has to be on the correct side.
Soren
@srnb_gitlab
Any ADT to represent Websocket URIs?
Huh, URI can do wss but WebSocketRequest can't do URI
Soren
@srnb_gitlab
I just made my own match case for now
Media Type must be text, but is DefaultMediaType(application,json,true,true,WrappedArray(json))
How do I fix this? I'm using circe, should I just do bodyAs[Json] instead?
Soren
@srnb_gitlab
java.lang.Throwable: Failed to decode value: cannot acquire 16526844176 bits from a vector that contains 728 bits, content: ByteVector(95 bytes, 0x7b2274223a6e756c6c2c2273223a6e756c6c2c226f70223a31302c2264223a7b226865617274626561745f696e74657276616c223a34313235302c225f7472616365223a5b22676174657761792d7072642d6d61696e2d6b673677225d7d7d)
Why does fs2-http want 2GB
Soren
@srnb_gitlab
The first issue is an issue with normal requests, and the second is an issue with websockets, by the way
Soren
@srnb_gitlab
Should I make an issue on GitHub or is there something I need to fix on my end?
Pavel Chlupacek
@pchlupacek
@srnb_gitlab please feel free open issue. Even when this will be on your end, it us easier for us to respond, hence we will see you source code. I likely say that it is the case, hence both ws and http are used in production.
Soren
@srnb_gitlab
@pchlupacek #32 #33 #34
Pavel Chlupacek
@pchlupacek
@srnb_gitlab thanks, will reply you back. On the documentation/sample could do you have some free time to perhaps suggest P/R to fix that?
Soren
@srnb_gitlab
Yep, I can do that
#35
Soren
@srnb_gitlab
I need a plain text value option for the Authorization header
Adam Chlupacek
@AdamChlupacek
Hello @srnb_gitlab what do you mean plain text value? is the BasicHttpCredentials not enough?
Soren
@srnb_gitlab
@AdamChlupacek I didn't see a BasicHttpCredentials. I just recently had to move from DigestHttpCredentials to OAuthToken due to some sort of java error (But the only reason I can use OAuth token is because the token has a space in it)
Adam Chlupacek
@AdamChlupacek
@srnb_gitlab yeah no problem
Soren
@srnb_gitlab
How do I tell a websocket to close with some sort of code?