Skip to content

Commit

Permalink
Compilation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojtek Urbanski committed Mar 16, 2021
1 parent 9d7ee5f commit f72cb19
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions core/src/main/scala/sttp/model/sse/ServerSentEvent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package sttp.model.sse
import scala.util.Try

case class ServerSentEvent(
data: Option[String] = None,
eventType: Option[String] = None,
id: Option[String] = None,
retry: Option[Int] = None
)
data: Option[String] = None,
eventType: Option[String] = None,
id: Option[String] = None,
retry: Option[Int] = None
)

object ServerSentEvent {
// https://html.spec.whatwg.org/multipage/server-sent-events.html
Expand All @@ -25,7 +25,7 @@ object ServerSentEvent {
}

def composeSSE(sse: ServerSentEvent): String = {
val data = sse.data.map(_.split("\n")).map(_.map(line => Some(s"data: $line"))).getOrElse(Array.empty)
val data = sse.data.map(_.split("\n")).map(_.map(line => Some(s"data: $line"))).getOrElse(Array.empty[Option[String]])
val event = sse.eventType.map(event => s"event: $event")
val id = sse.id.map(id => s"id: $id")
val retry = sse.retry.map(retryCount => s"retry: $retryCount")
Expand All @@ -34,8 +34,8 @@ object ServerSentEvent {

private def combineData(event: ServerSentEvent, newData: String): ServerSentEvent = {
event match {
case e @ ServerSentEvent(Some(oldData), _, _, _) => e.copy(data = Some(s"$oldData\n$newData"))
case e @ ServerSentEvent(None, _, _, _) => e.copy(data = Some(newData))
case e@ServerSentEvent(Some(oldData), _, _, _) => e.copy(data = Some(s"$oldData\n$newData"))
case e@ServerSentEvent(None, _, _, _) => e.copy(data = Some(newData))
}
}

Expand Down

0 comments on commit f72cb19

Please sign in to comment.