Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use maxUnanswered parameter in ws pings #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wedens
Copy link

@wedens wedens commented Jul 4, 2017

It was unused.

Also deleted unused flag parameter.

@pchlupacek
Copy link
Member

@wedens thanks for this. Any chance you can drop in test verifying the behaviour? Thanks

@wedens
Copy link
Author

wedens commented Jul 5, 2017

I'll try to do that. Should I just add tests for controlStream to WebSocketSpec ?

@pchlupacek
Copy link
Member

yes, that would be awesome @wedens.

@wedens
Copy link
Author

wedens commented Jul 17, 2017

Sorry, I don't know how to implement such test :/

My best attempt so far was something ridiculous like:

  property("fail-on-unanswered-pings") = secure {
    val s = Stream.eval(async.unboundedQueue[Task, Unit]).flatMap { pingsQ =>
      Stream.eval(async.unboundedQueue[Task, PingPong]).flatMap { pongsQ =>
        val s = time.awakeEvery[Task](1.second).mapAccumulate(0) {
          case (x, _) if x >= 3 =>
            val s = Stream.eval_(pingsQ.enqueue1(()))
            (x + 1, s)
          case (x, _) =>
            val s = Stream.eval_(pingsQ.enqueue1(())) ++
              Stream.eval_(pongsQ.enqueue1(PingPong.Pong))
            (x + 1, s)
        }.flatMap(_._2)

        val s0 = WebSocket.impl.controlStream(pongsQ.dequeue, pingsQ.dequeue, 3)

        s mergeHaltR s0
      }
    }

    Prop.throws(classOf[Throwable]) {
      s.run.unsafeRun ?= (())
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants