Created
May 28, 2019 11:48
-
-
Save elyphas/7e61e28c424ee4fe605425ab7650c7c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sendFileReader(f: dom.Blob, typeFile: String, idPedido: IdPedido, eof: Boolean) = { //Original para enviar el archivo completo | |
val fileReader = new dom.FileReader() | |
fileReader.onload = { e: dom.UIEvent => | |
val buffer = fileReader.result.asInstanceOf[ArrayBuffer] | |
val bb = TypedArrayBuffer.wrap(buffer) | |
val arraybuf: Array[Byte] = new Array[Byte](bb.remaining()) | |
bb.get(arraybuf) | |
val msgFile = IncomingFile( idPedido = idPedido, file = arraybuf, typeFile = typeFile, eof = eof) | |
//val bytesFile = Pickle.intoBytes[WebSocketEvent](msgFile).arrayBuffer() | |
//wsMain.ws.send(bytesFile) | |
val payload = Pickle.intoBytes[WebSocketEvent](msgFile).arrayBuffer() | |
type Event = String | |
type Failure = String //Int | |
val client = WebsocketClient.withPayload[ByteBuffer, ArrayBuffer, Event, Failure]( | |
new JsWebsocketConnection, WebsocketClientConfig(), new IncidentHandler[Event]) | |
client.run(s"ws://$ipWS:$portWS/ws/socketMycelium") | |
val respondWS = client.send ( "saveImage" :: Nil, payload, SendType.WhenConnected, 30 seconds ) | |
} | |
fileReader.readAsArrayBuffer(f) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment