Skip to content

Commit

Permalink
Kitura/Kitura#33 Added initial code to create a frame "header"
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuelk committed Nov 1, 2016
1 parent 5d071b9 commit 1c49db0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Sources/KituraWebSocket/WSFrame.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,20 @@ struct WSFrame {
var opCode = FrameOpcode.unknown

let payload = NSMutableData()

static func createFrameHeader(finalFrame: Bool, opCode: FrameOpcode, payloadLength: Int, buffer: NSMutableData) {

var bytes: [UInt8] = [(finalFrame ? 0x80 : 0x00) | UInt8(opCode.rawValue), 0, 0,0,0,0,0,0,0,0]
var length = 1

if payloadLength < 126 {
bytes[1] = UInt8(payloadLength)
length += 1
} else if payloadLength < Int(UInt16.max) {

} else {

}
buffer.append(bytes, length: length)
}
}

0 comments on commit 1c49db0

Please sign in to comment.