|
- {"identifier":{"interfaceLanguage":"swift","url":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/WebSocketViewModel\/sendUpdateOverTCP()"},"hierarchy":{"paths":[["doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling","doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/WebSocketViewModel"]]},"kind":"symbol","sections":[],"abstract":[{"type":"text","text":"Sends an update over TCP."}],"metadata":{"externalID":"s:7Fueling18WebSocketViewModelC17sendUpdateOverTCPyyF","symbolKind":"method","modules":[{"name":"Fueling"}],"fragments":[{"text":"func","kind":"keyword"},{"text":" ","kind":"text"},{"text":"sendUpdateOverTCP","kind":"identifier"},{"kind":"text","text":"()"}],"roleHeading":"Instance Method","title":"sendUpdateOverTCP()","role":"symbol"},"primaryContentSections":[{"declarations":[{"tokens":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"text":"sendUpdateOverTCP","kind":"identifier"},{"text":"()","kind":"text"}],"platforms":["iOS"],"languages":["swift"]}],"kind":"declarations"},{"kind":"content","content":[{"anchor":"discussion","level":2,"text":"Discussion","type":"heading"},{"type":"paragraph","inlineContent":[{"text":"This method sends an update file to the specified host and port using a TCP connection.","type":"text"}]},{"type":"codeListing","code":["func sendUpdateOverTCP() {"," let hostName: String = \"192.168.4.1\""," let portNumber: Int = 111"," let filePath = Bundle.main.path(forResource: \"STC\", ofType: \"bin\")"," let ReadData = NSMutableData()"," let streamTask: URLSessionStreamTask = URLSession.shared.streamTask(withHostName: hostName, port: portNumber)"," "," if FileManager.default.fileExists(atPath: filePath!) {"," if let fileAttributes = try? FileManager.default.attributesOfItem(atPath: filePath!) {"," guard let size = fileAttributes[.size] as? Int else { return }"," let fileSize = \"\\(String(describing: size))\""," streamTask.write(fileSize.data(using: .nonLossyASCII)!, timeout: 60) { error in"," if let error = error {"," print(\"File Size Error: .\\(error)\")"," }"," streamTask.resume()"," DispatchQueue.main.async {"," self.updateFileSize = Float(fileSize) ?? 1"," }"," }"," let updateFileHanddle = try! FileHandle(forReadingFrom: URL(fileURLWithPath: filePath!))"," let data = updateFileHanddle.readDataToEndOfFile()"," ReadData.append(data)"," "," streamTask.write(ReadData as Data, timeout: 60) { error in"," if let error = error {"," print(\"File Send Error: .\\(error)\")"," }"," DispatchQueue.main.async {"," self.updateComplete = true"," }"," }"," streamTask.resume()"," }"," }","}"],"syntax":"swift"}]}],"schemaVersion":{"minor":3,"major":0,"patch":0},"variants":[{"traits":[{"interfaceLanguage":"swift"}],"paths":["\/documentation\/fueling\/websocketviewmodel\/sendupdateovertcp()"]}],"references":{"doc://rpm.com.production.Scanner/documentation/Fueling/WebSocketViewModel/sendUpdateOverTCP()":{"abstract":[{"text":"Sends an update over TCP.","type":"text"}],"kind":"symbol","identifier":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/WebSocketViewModel\/sendUpdateOverTCP()","type":"topic","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"text":"sendUpdateOverTCP","kind":"identifier"},{"kind":"text","text":"()"}],"url":"\/documentation\/fueling\/websocketviewmodel\/sendupdateovertcp()","title":"sendUpdateOverTCP()","role":"symbol"},"doc://rpm.com.production.Scanner/documentation/Fueling/WebSocketViewModel":{"kind":"symbol","role":"symbol","fragments":[{"kind":"keyword","text":"class"},{"text":" ","kind":"text"},{"kind":"identifier","text":"WebSocketViewModel"}],"navigatorTitle":[{"kind":"identifier","text":"WebSocketViewModel"}],"abstract":[{"text":"The ","type":"text"},{"type":"codeVoice","code":"WebSocketViewModel"},{"type":"text","text":" class is responsible for managing WebSocket connections, handling messages, and updating application state based on WebSocket events."}],"url":"\/documentation\/fueling\/websocketviewmodel","type":"topic","identifier":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/WebSocketViewModel","title":"WebSocketViewModel"},"doc://rpm.com.production.Scanner/documentation/Fueling":{"kind":"symbol","url":"\/documentation\/fueling","title":"Fueling","identifier":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling","abstract":[{"type":"text","text":"The Scanner app is designed to facilitate secure and efficient fuel management operations, primarily focusing on user authentication, fuel data collection, and network communication. The app includes several key features to ensure seamless and reliable interactions between users and the backend systems, leveraging technologies like WebSockets, Core Data, and biometric authentication."}],"type":"topic","role":"collection"}}}
|