Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished preliminary layer of upload support through WebSocket
- Loading branch information
1 parent
200db9d
commit ce0e1a2
Showing
13 changed files
with
135 additions
and
74 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,6 @@ | |
target/ | ||
node_modules/ | ||
npm-debug.log | ||
*.js | ||
*.js.map | ||
package-lock.json | ||
temp/ | ||
utilities/config.json | ||
|
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
5 changes: 5 additions & 0 deletions
5
communication/.js/src/main/scala/io/youi/communication/CommunicationPlatform.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.youi.communication | ||
|
||
object CommunicationPlatform { | ||
def createWriter(fileName: String, bytes: Long): ByteBufferWriter = throw new UnsupportedOperationException("Generating files in the browser is not yet supported") | ||
} |
18 changes: 18 additions & 0 deletions
18
communication/.jvm/src/main/scala/io/youi/communication/ChannelWriter.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.youi.communication | ||
|
||
import java.nio.ByteBuffer | ||
import java.nio.channels.FileChannel | ||
|
||
case class ChannelWriter(fileName: String, actualFileName: String, channel: FileChannel, bytes: Long) extends ByteBufferWriter { | ||
private var _written: Long = 0L | ||
|
||
override def written: Long = _written | ||
|
||
override def remaining: Long = bytes - written | ||
|
||
override def write(bb: ByteBuffer): Unit = { | ||
_written += channel.write(bb) | ||
} | ||
|
||
override def close(): Unit = channel.close() | ||
} |
12 changes: 12 additions & 0 deletions
12
communication/.jvm/src/main/scala/io/youi/communication/CommunicationPlatform.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.youi.communication | ||
|
||
import java.io.{File, FileOutputStream} | ||
|
||
object CommunicationPlatform { | ||
def createWriter(fileName: String, bytes: Long): ByteBufferWriter = { | ||
// TODO: configure temp directory | ||
val file = File.createTempFile("youi-", fileName) | ||
val channel = new FileOutputStream(file).getChannel | ||
ChannelWriter(fileName, file.getName, channel, bytes) | ||
} | ||
} |
48 changes: 0 additions & 48 deletions
48
communication/.jvm/src/main/scala/io/youi/communication/ConnectionPlatform.scala
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
communication/src/main/scala/io/youi/communication/ByteBufferWriter.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.youi.communication | ||
|
||
import java.nio.ByteBuffer | ||
|
||
import scala.concurrent.Promise | ||
|
||
trait ByteBufferWriter { | ||
val promise: Promise[Unit] = Promise[Unit] | ||
|
||
def fileName: String | ||
def actualFileName: String | ||
def written: Long | ||
def remaining: Long | ||
def write(bb: ByteBuffer): Unit | ||
def close(): Unit | ||
} |
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
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
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
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
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
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