Skip to content

Commit be56a60

Browse files
committed
lint
1 parent 781e272 commit be56a60

File tree

5 files changed

+49
-23
lines changed

5 files changed

+49
-23
lines changed

Sources/AutobahnServer/AutohahnServer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct AutohahnServer {
3737
let portIndex = portCmdIndex + 1
3838
port = Int(args[portIndex]) ?? port
3939
}
40-
40+
4141
let elg = MultiThreadedEventLoopGroup(numberOfThreads: 4)
4242
var server = LCLWebSocket.server(on: elg)
4343

Sources/LCLWebSocket/Client/WebSocketClient.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,14 @@ extension WebSocketClient {
290290

291291
func makeClientBootstrap() -> EventLoopFuture<Channel> {
292292
ClientBootstrap(group: self.eventloopGroup)
293-
.channelOption(.socketOption(.so_reuseaddr), value: SocketOptionValue(configuration.socketReuseAddress ? 1 : 0))
294-
.channelOption(.tcpOption(.tcp_nodelay), value: SocketOptionValue(configuration.socketTcpNoDelay ? 1 : 0))
293+
.channelOption(
294+
.socketOption(.so_reuseaddr),
295+
value: SocketOptionValue(configuration.socketReuseAddress ? 1 : 0)
296+
)
297+
.channelOption(
298+
.tcpOption(.tcp_nodelay),
299+
value: SocketOptionValue(configuration.socketTcpNoDelay ? 1 : 0)
300+
)
295301
.channelOption(.socketOption(.so_sndbuf), value: configuration.socketSendBufferSize)
296302
.channelOption(.socketOption(.so_rcvbuf), value: configuration.socketReceiveBufferSize)
297303
.connectTimeout(configuration.connectionTimeout)
@@ -307,7 +313,10 @@ extension WebSocketClient {
307313

308314
return NIOTSConnectionBootstrap(group: self.eventloopGroup)
309315
.tcpOptions(tcpOptions)
310-
.channelOption(.socketOption(.so_reuseaddr), value: SocketOptionValue(configuration.socketReuseAddress ? 1 : 0))
316+
.channelOption(
317+
.socketOption(.so_reuseaddr),
318+
value: SocketOptionValue(configuration.socketReuseAddress ? 1 : 0)
319+
)
311320
.channelInitializer(channelInitializer)
312321
.connect(to: resolvedAddress)
313322
}
@@ -333,7 +342,8 @@ extension WebSocketClient {
333342
@Sendable
334343
func makeChannelInitializer(_ channel: Channel) -> EventLoopFuture<Void> {
335344
if let deviceName = configuration.deviceName,
336-
let device = findDevice(with: deviceName, protocol: resolvedAddress.protocol) {
345+
let device = findDevice(with: deviceName, protocol: resolvedAddress.protocol)
346+
{
337347
// bind to selected device, if any
338348
return bindTo(device: device, on: channel).flatMap { () -> EventLoopFuture<Void> in
339349
if scheme.enableTLS {

Sources/LCLWebSocket/Server/WebSocketServer.swift

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,22 @@ extension WebSocketServer {
251251

252252
func makeServerBootstrap() -> EventLoopFuture<Channel> {
253253
ServerBootstrap(group: self.eventloopGroup)
254-
.serverChannelOption(.socketOption(.so_reuseaddr), value: SocketOptionValue(configuration.socketReuseAddress ? 1 : 0))
255-
.serverChannelOption(.tcpOption(.tcp_nodelay), value: SocketOptionValue(configuration.socketTcpNoDelay ? 1 : 0))
256-
.childChannelOption(.socketOption(.so_reuseaddr), value: SocketOptionValue(configuration.socketReuseAddress ? 1 : 0))
257-
.childChannelOption(.tcpOption(.tcp_nodelay), value: SocketOptionValue(configuration.socketTcpNoDelay ? 1 : 0))
254+
.serverChannelOption(
255+
.socketOption(.so_reuseaddr),
256+
value: SocketOptionValue(configuration.socketReuseAddress ? 1 : 0)
257+
)
258+
.serverChannelOption(
259+
.tcpOption(.tcp_nodelay),
260+
value: SocketOptionValue(configuration.socketTcpNoDelay ? 1 : 0)
261+
)
262+
.childChannelOption(
263+
.socketOption(.so_reuseaddr),
264+
value: SocketOptionValue(configuration.socketReuseAddress ? 1 : 0)
265+
)
266+
.childChannelOption(
267+
.tcpOption(.tcp_nodelay),
268+
value: SocketOptionValue(configuration.socketTcpNoDelay ? 1 : 0)
269+
)
258270
.childChannelOption(.socketOption(.so_sndbuf), value: configuration.socketSendBufferSize)
259271
.childChannelOption(.socketOption(.so_rcvbuf), value: configuration.socketReceiveBufferSize)
260272
.serverChannelInitializer { channel in
@@ -282,8 +294,14 @@ extension WebSocketServer {
282294

283295
return NIOTSListenerBootstrap(group: self.eventloopGroup)
284296
.tcpOptions(tcpOptions)
285-
.serverChannelOption(.socketOption(.so_reuseaddr), value: SocketOptionValue(configuration.socketReuseAddress ? 1 : 0))
286-
.childChannelOption(.socketOption(.so_reuseaddr), value: SocketOptionValue(configuration.socketReuseAddress ? 1 : 0))
297+
.serverChannelOption(
298+
.socketOption(.so_reuseaddr),
299+
value: SocketOptionValue(configuration.socketReuseAddress ? 1 : 0)
300+
)
301+
.childChannelOption(
302+
.socketOption(.so_reuseaddr),
303+
value: SocketOptionValue(configuration.socketReuseAddress ? 1 : 0)
304+
)
287305
.serverChannelInitializer { channel in
288306
logger.info("Server is listening on \(resolvedAddress)")
289307

Sources/LCLWebSocket/WebSocket.swift

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public final class WebSocket: Sendable {
110110
func onError(_ callback: (@Sendable (Error) -> Void)?) {
111111
self._onError.value = callback
112112
}
113-
113+
114114
/// Send the provided buffer, opcode, fin to the remote WebSocket peer.
115115
///
116116
/// - Parameters:
@@ -167,9 +167,8 @@ public final class WebSocket: Sendable {
167167
return promise.futureResult
168168
}
169169

170-
171170
/// Send the close frame to the WebSocket peer to initiate the closing handshake.
172-
///
171+
///
173172
/// - Parameters:
174173
/// - code: the `WebSocketErrorCode` describe the reason for the closure.
175174
/// - reason: the textual description of the reason why the WebSocket connection is closed.
@@ -233,7 +232,6 @@ public final class WebSocket: Sendable {
233232
return promise.futureResult
234233
}
235234

236-
237235
/// Send the ping frame to the remote peer.
238236
///
239237
/// Calling this function if the WebSocket connection is not active will result in a failure in the given promise.
@@ -425,7 +423,7 @@ public final class WebSocket: Sendable {
425423
return nil
426424
}
427425
}
428-
426+
429427
private func closeChannel() {
430428
if self.channel.isActive && self.channel.isWritable {
431429
logger.debug("Closing underying tcp connection.")
@@ -511,12 +509,12 @@ extension WebSocket {
511509
}
512510

513511
extension WebSocket {
514-
512+
515513
/// The type of the WebSocket instance.
516514
public enum WebSocketType: Sendable, Equatable {
517515
/// WebSocket client
518516
case client
519-
517+
520518
/// WebSocket server
521519
case server
522520
}
@@ -530,13 +528,13 @@ extension WebSocket {
530528
}
531529

532530
extension WebSocket {
533-
531+
534532
/// A collection of information that the WebSocket uses to make the connection
535533
public struct ConnectionInfo: Sendable {
536-
534+
537535
/// The URL that the WebSocket client connects to
538536
let url: URLComponents
539-
537+
540538
/// The protocol, "ws" or "wss", that the WebSocket follows
541539
let `protocol`: String?
542540
// TODO: extension

Sources/LCLWebSocket/WebSocketHandler.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ final class WebSocketHandler: ChannelInboundHandler {
2020
init(websocket: WebSocket) {
2121
self.websocket = websocket
2222
}
23-
23+
2424
func channelInactive(context: ChannelHandlerContext) {
2525
logger.debug("WebSocketHandler channelInactive")
2626
}
27-
27+
2828
func channelUnregistered(context: ChannelHandlerContext) {
2929
logger.debug("WebSocketHandler channelUnregistered")
3030
}

0 commit comments

Comments
 (0)