forked from tonyofrancis/Fetch
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5accbe6
commit 0364aa3
Showing
27 changed files
with
540 additions
and
463 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
2 changes: 2 additions & 0 deletions
2
fetch2/src/main/java/com/tonyodev/fetch2/util/InterruptMonitor.kt
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package com.tonyodev.fetch2.util | ||
|
||
/** Object used to monitor work interruption. */ | ||
interface InterruptMonitor { | ||
|
||
val isInterrupted: Boolean | ||
} |
9 changes: 0 additions & 9 deletions
9
...erver/src/main/java/com/tonyodev/fetch2fileserver/AbstractFetchFileServerAuthenticator.kt
This file was deleted.
Oops, something went wrong.
42 changes: 39 additions & 3 deletions
42
...fileserver/src/main/java/com/tonyodev/fetch2fileserver/AbstractFetchFileServerDelegate.kt
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
17 changes: 0 additions & 17 deletions
17
...rver/src/main/java/com/tonyodev/fetch2fileserver/AbstractFetchTransferProgressListener.kt
This file was deleted.
Oops, something went wrong.
60 changes: 0 additions & 60 deletions
60
fetch2fileserver/src/main/java/com/tonyodev/fetch2fileserver/ContentFile.kt
This file was deleted.
Oops, something went wrong.
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
7 changes: 7 additions & 0 deletions
7
fetch2fileserver/src/main/java/com/tonyodev/fetch2fileserver/FetchFileServerAuthenticator.kt
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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
package com.tonyodev.fetch2fileserver | ||
|
||
/** Used to authenticate clients trying to connect to the Fetch File Server | ||
* instance this authenticator instance is attached to.*/ | ||
interface FetchFileServerAuthenticator { | ||
|
||
/** Method called when a client is attempting to connect to the Fetch File Server. | ||
* @param authorization the authorization token | ||
* @param fileRequest the fileRequest the client sent. | ||
* @return true if the authorize token is accepted. False otherwise. | ||
* */ | ||
fun accept(authorization: String, fileRequest: FileRequest): Boolean | ||
|
||
} |
44 changes: 40 additions & 4 deletions
44
fetch2fileserver/src/main/java/com/tonyodev/fetch2fileserver/FetchFileServerDelegate.kt
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 |
---|---|---|
@@ -1,20 +1,56 @@ | ||
package com.tonyodev.fetch2fileserver | ||
|
||
import com.tonyodev.fetch2.util.InterruptMonitor | ||
import com.tonyodev.fetch2fileserver.transporter.ContentFileTransporterWriter | ||
import com.tonyodev.fetch2fileserver.transporter.FileResourceTransporterWriter | ||
import java.io.InputStream | ||
|
||
/** | ||
* Delegate that can be attached to a Fetch File Server instance to take certain actions | ||
* on a FileRequested by the client. | ||
* */ | ||
interface FetchFileServerDelegate { | ||
|
||
/** Called when a client is successfully connected to the Fetch File Server and | ||
* the request has been authorized. | ||
* @param client Client identifier | ||
* @param fileRequest File request by the client | ||
* */ | ||
fun onClientConnected(client: String, fileRequest: FileRequest) | ||
|
||
/** | ||
* Called when a client provides custom data that the file server device can used or act on. | ||
* @param client Client identifier | ||
* @param customData Custom data | ||
* @param fileRequest File request by the client | ||
* */ | ||
fun onClientDidProvideCustomData(client: String, customData: String, fileRequest: FileRequest) | ||
|
||
/** Called when a client disconnects from the Fetch File Server. | ||
* @param client Client identifier | ||
* */ | ||
fun onClientDisconnected(client: String) | ||
|
||
fun getFileInputStream(contentFile: ContentFile, fileOffset: Long): InputStream? | ||
|
||
/** Called when the Fetch File Server needs to provide the client the requested file input stream. | ||
* If null is returned, Fetch File Server will provide the InputSteam. Use this method if you need | ||
* to provide a custom InputStream. For example an encrypted input stream. | ||
* @param fileResource Resource File that Fetch file Server will provide the client. | ||
* @param fileOffset The offset reading will begin from. Use this value to seek to the right | ||
* offset position. Note: Not seeking to the right position will cause the server to send | ||
* invalid data to the client. | ||
* @return file input stream. Can be null. | ||
* */ | ||
fun getFileInputStream(fileResource: FileResource, fileOffset: Long): InputStream? | ||
|
||
/** Called if the client requested a custom request that the Fetch File Server cannot | ||
* serve. Use this callback to provide a custom response. | ||
* @param client Client identifier | ||
* @param fileRequest File request by the client | ||
* @param fileResourceTransporterWriter Writer used to transport byte data to the requesting client. | ||
* @param interruptMonitor used this object to monitor interruption. | ||
* A request may have been cancelled by the server because it is shutting down or the client | ||
* has closed the connection. | ||
* **/ | ||
fun onCustomRequest(client: String, fileRequest: FileRequest, | ||
contentFileTransporterWriter: ContentFileTransporterWriter, interruptMonitor: InterruptMonitor) | ||
fileResourceTransporterWriter: FileResourceTransporterWriter, interruptMonitor: InterruptMonitor) | ||
|
||
} |
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
Oops, something went wrong.