Skip to content

Commit dcd3424

Browse files
committed
Formating
1 parent 599e9ab commit dcd3424

File tree

9 files changed

+43
-64
lines changed

9 files changed

+43
-64
lines changed

src/main/scala/play/engineio/EngineIO.scala

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ object EngineIOConfig {
5757
}
5858

5959
@Singleton
60-
class EngineIOConfigProvider @Inject()(configuration: Configuration) extends Provider[EngineIOConfig] {
60+
class EngineIOConfigProvider @Inject() (configuration: Configuration) extends Provider[EngineIOConfig] {
6161
override lazy val get: EngineIOConfig = EngineIOConfig.fromConfiguration(configuration)
6262
}
6363

@@ -111,9 +111,7 @@ final class EngineIOController(
111111
case (Some(sid), Some(payload)) =>
112112
log.debug(s"Received push request for $sid")
113113

114-
(engineIOManager ? Packets(sid, transport, payload.packets, requestId)).map { _ =>
115-
Ok("ok")
116-
}
114+
(engineIOManager ? Packets(sid, transport, payload.packets, requestId)).map { _ => Ok("ok") }
117115

118116
// sid no payload, we're retrieving packets
119117
case (Some(sid), None) =>
@@ -169,9 +167,7 @@ final class EngineIOController(
169167

170168
val in = Flow[EngineIOPacket]
171169
.batch(4, Vector(_))(_ :+ _)
172-
.mapAsync(1) { packets =>
173-
engineIOManager ? Packets(sid, transport, packets, requestId)
174-
}
170+
.mapAsync(1) { packets => engineIOManager ? Packets(sid, transport, packets, requestId) }
175171
.to(Sink.ignore.mapMaterializedValue(_.onComplete {
176172
case Success(s) =>
177173
engineIOManager ! Close(sid, transport, requestId)
@@ -192,7 +188,7 @@ final class EngineIOController(
192188
}
193189
.takeWhile(!_.isInstanceOf[Close])
194190
.mapConcat {
195-
case Packets(_, _, packets: Seq[EngineIOPacket], _) => collection.immutable.Seq[EngineIOPacket](packets:_*)
191+
case Packets(_, _, packets: Seq[EngineIOPacket], _) => collection.immutable.Seq[EngineIOPacket](packets: _*)
196192
}
197193

198194
Flow.fromSinkAndSourceCoupled(in, out)
@@ -204,7 +200,7 @@ final class EngineIOController(
204200
* The engine.io system. Allows you to create engine.io controllers for handling engine.io connections.
205201
*/
206202
@Singleton
207-
final class EngineIO @Inject()(
203+
final class EngineIO @Inject() (
208204
config: EngineIOConfig,
209205
httpErrorHandler: HttpErrorHandler,
210206
controllerComponents: ControllerComponents,

src/main/scala/play/engineio/EngineIOSessionActor.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ class EngineIOSessionActor[SessionData](
128128
case (transport, (RetrieveRequester(requester, requestId))) =>
129129
requester ! Close(sid, transport, requestId)
130130
}
131-
messagesReceivedSenders.foreach { messageSender =>
132-
messageSender ! Status.Failure(SessionClosed)
133-
}
131+
messagesReceivedSenders.foreach { messageSender => messageSender ! Status.Failure(SessionClosed) }
134132

135133
if (sourceQueue != null) {
136134
sourceQueue.complete()

src/main/scala/play/socketio/SocketIOConfig.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ object SocketIOConfig {
3131
}
3232

3333
@Singleton
34-
class SocketIOConfigProvider @Inject()(configuration: Configuration) extends Provider[SocketIOConfig] {
34+
class SocketIOConfigProvider @Inject() (configuration: Configuration) extends Provider[SocketIOConfig] {
3535
override lazy val get: SocketIOConfig = SocketIOConfig.fromConfiguration(configuration)
3636
}

src/main/scala/play/socketio/SocketIOSessionFlow.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,7 @@ private class SocketIOSessionStage[SessionData](
344344
connectNamespace(
345345
namespace,
346346
connectToNamespaceCallback.applyOrElse(
347-
(session, ns), { _: (SocketIOSession[SessionData], String) =>
348-
throw NamespaceNotFound(namespace)
349-
}
347+
(session, ns), { _: (SocketIOSession[SessionData], String) => throw NamespaceNotFound(namespace) }
350348
)
351349
)
352350
}

src/main/scala/play/socketio/protocol/SocketIOProtocol.scala

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ object SocketIOPacket {
128128
}
129129

130130
// Encode namespace
131-
packet.namespace.foreach { ns =>
132-
message ++= ns
133-
}
131+
packet.namespace.foreach { ns => message ++= ns }
134132

135133
def encodeData(data: JsValue, id: Option[Long]): Unit = {
136134
if (packet.namespace.isDefined) {
@@ -183,16 +181,17 @@ object SocketIOPacket {
183181
if (placeholdersSeparator == -1) {
184182
throw SocketIOEncodingException(text, s"Malformed binary socket.io packet, missing placeholder separator")
185183
}
186-
val placeholders = try {
187-
text.substring(1, placeholdersSeparator).toInt
188-
} catch {
189-
case _: NumberFormatException =>
190-
throw SocketIOEncodingException(
191-
text,
192-
"Malformed binary socket.io packet, num placeholders is not a number: '" +
193-
text.substring(1, placeholdersSeparator) + "'"
194-
)
195-
}
184+
val placeholders =
185+
try {
186+
text.substring(1, placeholdersSeparator).toInt
187+
} catch {
188+
case _: NumberFormatException =>
189+
throw SocketIOEncodingException(
190+
text,
191+
"Malformed binary socket.io packet, num placeholders is not a number: '" +
192+
text.substring(1, placeholdersSeparator) + "'"
193+
)
194+
}
196195
(placeholders, placeholdersSeparator + 1)
197196
} else {
198197
(0, 1)
@@ -230,12 +229,13 @@ object SocketIOPacket {
230229
}
231230

232231
val argsData = text.substring(argsStart)
233-
val args = try {
234-
Json.parse(argsData)
235-
} catch {
236-
case e: Exception =>
237-
throw SocketIOEncodingException(text, "Error parsing socket.io args", e)
238-
}
232+
val args =
233+
try {
234+
Json.parse(argsData)
235+
} catch {
236+
case e: Exception =>
237+
throw SocketIOEncodingException(text, "Error parsing socket.io args", e)
238+
}
239239

240240
(index, Some(args))
241241
} else {

src/main/scala/play/socketio/scaladsl/SocketIO.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import scala.concurrent.Future
2626
/**
2727
* The engine.io system. Allows you to create engine.io controllers for handling engine.io connections.
2828
*/
29-
final class SocketIO @Inject()(config: SocketIOConfig, engineIO: EngineIO)(
29+
final class SocketIO @Inject() (config: SocketIOConfig, engineIO: EngineIO)(
3030
implicit ec: ExecutionContext,
3131
mat: Materializer
3232
) {
@@ -193,9 +193,7 @@ final class SocketIO @Inject()(config: SocketIOConfig, engineIO: EngineIO)(
193193
connectCallback,
194194
errorHandler,
195195
defaultNamespaceCallback,
196-
connectToNamespaceCallback.orElse(callback.andThen { flow =>
197-
createNamespace(decoder, encoder, flow)
198-
})
196+
connectToNamespaceCallback.orElse(callback.andThen { flow => createNamespace(decoder, encoder, flow) })
199197
)
200198
}
201199

src/main/scala/play/socketio/scaladsl/SocketIOEventCodec.scala

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ object SocketIOEventCodec {
6565
override def applyOrElse[A1 <: SocketIOEvent, B1 >: T](event: A1, default: (A1) => B1) = {
6666
decoders
6767
.andThen(decoder => decoder.apply(event))
68-
.applyOrElse(event.name, { _: String =>
69-
default(event)
70-
})
68+
.applyOrElse(event.name, { _: String => default(event) })
7169
}
7270
}
7371

@@ -192,9 +190,7 @@ object SocketIOEventCodec {
192190
def withMaybeAckEncoder[A](
193191
encoder: SocketIOArgsEncoder[A]
194192
): SocketIOEventCodec.SocketIOEventDecoder[(T, Option[A => Unit])] = { event =>
195-
(first(event), event.ack.map { ack =>
196-
ack.compose(encoder.encodeArgs)
197-
})
193+
(first(event), event.ack.map { ack => ack.compose(encoder.encodeArgs) })
198194
}
199195
}
200196

@@ -258,9 +254,7 @@ object SocketIOEventCodec {
258254
encoder: SocketIOArgsEncoder[A]
259255
): SocketIOEventCodec.SocketIOEventDecoder[(T1, T2, Option[A => Unit])] = { event =>
260256
val args = init(event)
261-
(args._1, args._2, event.ack.map { ack =>
262-
ack.compose(encoder.encodeArgs)
263-
})
257+
(args._1, args._2, event.ack.map { ack => ack.compose(encoder.encodeArgs) })
264258
}
265259
}
266260

@@ -324,9 +318,7 @@ object SocketIOEventCodec {
324318
encoder: SocketIOArgsEncoder[A]
325319
): SocketIOEventCodec.SocketIOEventDecoder[(T1, T2, T3, Option[A => Unit])] = { event =>
326320
val args = init(event)
327-
(args._1, args._2, args._3, event.ack.map { ack =>
328-
ack.compose(encoder.encodeArgs)
329-
})
321+
(args._1, args._2, args._3, event.ack.map { ack => ack.compose(encoder.encodeArgs) })
330322
}
331323
}
332324

@@ -602,7 +594,5 @@ object SocketIOArgEncoder {
602594
/**
603595
* Create a json arg encoder.
604596
*/
605-
def json[T: Writes]: SocketIOArgEncoder[T] = apply { t =>
606-
Left(Json.toJson(t))
607-
}
597+
def json[T: Writes]: SocketIOArgEncoder[T] = apply { t => Left(Json.toJson(t)) }
608598
}

src/test/scala/play/socketio/RunSocketIOTests.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@ object RunSocketIOTests extends App {
3737
def run(): Unit = driver.quit()
3838
}))
3939

40-
val passed = try {
40+
val passed =
41+
try {
4142

42-
runTests("Scala support", TestSocketIOScalaApplication) &&
43-
runTests("Java support", new TestSocketIOJavaApplication) &&
44-
runTests("Multi-node support", TestMultiNodeSocketIOApplication)
43+
runTests("Scala support", TestSocketIOScalaApplication) &&
44+
runTests("Java support", new TestSocketIOJavaApplication) &&
45+
runTests("Multi-node support", TestMultiNodeSocketIOApplication)
4546

46-
} finally {
47-
driver.quit()
48-
}
47+
} finally {
48+
driver.quit()
49+
}
4950

5051
if (!passed) {
5152
System.exit(1)

src/test/scala/play/socketio/scaladsl/SocketIOEventCodecSpec.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ class SocketIOEventCodecSpec extends AnyWordSpec with Matchers with OptionValues
181181
val encoder = encodeByType[Any] {
182182
case _: String => "string" -> encodeJson[String]
183183
case _: Int =>
184-
"int" -> encodeJson[String].compose { i: Int =>
185-
i.toString
186-
}
184+
"int" -> encodeJson[String].compose { i: Int => i.toString }
187185
}
188186

189187
val e1 = encoder("arg")

0 commit comments

Comments
 (0)