Skip to content

Commit

Permalink
chore: params update for efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
koraykoska committed Oct 10, 2023
1 parent 4778cf5 commit 0d31675
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Sources/libwebsockets/WebsocketClientContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ internal final class WebsocketClientContext {
lwsProtocols.callback = _lws_swift_websocketClientCallback
lwsProtocols.per_session_data_size = 0
// TODO: Per instance customization?
lwsProtocols.rx_buffer_size = 1000000
lwsProtocols.rx_buffer_size = 4000000

protocolsPointer.initialize(to: lwsProtocols)

Expand Down
18 changes: 7 additions & 11 deletions Sources/libwebsockets/WebsocketFrameSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,21 @@ public struct WebsocketSimpleAppendFrameSequence: WebsocketFrameSequence {
private(set) public var binaryBuffer: Data
private(set) public var textBuffer: Data
public let type: WebsocketOpcode
private let lock: NIOLock

public init(type: WebsocketOpcode) {
self.binaryBuffer = Data()
self.textBuffer = Data()
self.type = type
self.lock = .init()
}

public mutating func append(_ frame: Data) {
self.lock.withLockVoid {
switch type {
case .binary:
self.binaryBuffer.append(frame)
case .text:
self.textBuffer.append(frame)
default:
break
}
switch type {
case .binary:
self.binaryBuffer.append(frame)
case .text:
self.textBuffer.append(frame)
default:
break
}
}
}

0 comments on commit 0d31675

Please sign in to comment.