networkutils_0_0_4

Network utilities for JVM platform

License

License

Categories

Categories

Net
GroupId

GroupId

com.github.ushiosan23
ArtifactId

ArtifactId

networkutils
Last Version

Last Version

0.0.4
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

networkutils_0_0_4
Network utilities for JVM platform
Project URL

Project URL

https://github.com/Ushiosan23/JVM_NetworkUtils
Source Code Management

Source Code Management

https://github.com/Ushiosan23/JVM_NetworkUtils

Download networkutils

Dependencies

runtime (6)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib jar 1.4.10
org.jetbrains.kotlin : kotlin-reflect jar 1.4.10
org.jetbrains.kotlinx : kotlinx-serialization-core-jvm jar 1.0.0
org.jetbrains.kotlinx : kotlinx-serialization-json-jvm jar 1.0.0
org.jetbrains.kotlinx : kotlinx-coroutines-core-jvm jar 1.4.0-M1
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

JVM Network Utils

Utilities used to manage network actions in JVM (Java Virtual Machine).

Feature status

  • โ˜‘๏ธ Complete
  • ๐Ÿ”ณ Partial complete
  • ๐Ÿ”ฒ Incomplete

Features

  • Make Http request
    • โ˜‘๏ธ GET
      • โ˜‘๏ธ Sync
      • โ˜‘๏ธ Async
      • โ˜‘๏ธ Coroutines
    • โ˜‘๏ธ POST
      • โ˜‘๏ธ Sync
      • โ˜‘๏ธ Async
      • โ˜‘๏ธ Coroutines
    • โ˜‘๏ธ PUT
      • โ˜‘๏ธ Sync
      • โ˜‘๏ธ Async
      • โ˜‘๏ธ Coroutines
    • PATCH
      • Sync
      • Async
      • Coroutines
    • โ˜‘๏ธ DELETE
      • โ˜‘๏ธ Sync
      • โ˜‘๏ธ Async
      • โ˜‘๏ธ Coroutines
  • Download resources from server
    • โ˜‘๏ธ Get percentage of download
    • โ˜‘๏ธ Calculate file size
    • โ˜‘๏ธ Real time download status
    • โ˜‘๏ธ Cancel download
    • ๐Ÿ”ณ Pause download (Partial)
      • Resume download
  • ๐Ÿ”ณ Upload files to server
    • Get percentage of upload
    • Calculate time
    • Real time download status

Problems

It's not possible to upload large files. I'm working to fix this problem. If you know how to upload large files by chunks you can fork this repo and make a pull request.

Any help is good. ๐Ÿ‘Œ ๐Ÿ˜

Download

You can download jar file from Release section or put in your gradle project the next code:

Groovy DSL

    repositories {
	mavenCentral()
}

dependencies {
	implementation "com.github.ushiosan23:networkutils:0.0.4"
}

Kotlin DSL

    repositories {
	mavenCentral()
}

dependencies {
	implementation("com.github.ushiosan23:networkutils:0.0.4")
}

Maven POM File

    <dependencies>
        <dependency>
            <groupId>com.github.ushiosan23</groupId>
            <artifactId>networkutils</artifactId>
            <version>0.0.4</version>
        </dependency>
    </dependencies>

How to use

Simple http request

  • Java
import com.github.ushiosan23.networkutils.http.HttpRequestAction;

class SimpleHttpRequest {

	HttpRequestAction action = new HttpRequestAction("https://api.github.com/users/Ushiosan23");

	// Create asynchronous request
	public void makeSyncRequest() throws Exception {
		System.out.println(action.get().body());
	}

	// Create asynchronous request
	public void makeAsyncRequest() {
		// Action always return the same action
		action.getAsync(action -> {
			System.out.println(action.body());
			return action;
		});
	}

	public static void main(String[] args) throws Exception {
		SimpleHttpRequest request = new SimpleHttpRequest();
		request.makeAsyncRequest();
		request.makeSyncRequest();

		Thread.sleep(5000);
	}
}
  • Kotlin
import com.github.ushiosan23.networkutils.http.HttpRequestAction


fun main() {
	val request = HttpRequestAction("https://api.github.com/users/Ushiosan23")

	// Asynchronous request
	request.getAsync { action ->
		println(action.body())
		return@getAsync action
	}

	// Synchronous request
	println(request.get().body())
	Thread.sleep(5000)
}
  • Kotlin Coroutines
import com.github.ushiosan23.networkutils.http.HttpRequestAction
import com.github.ushiosan23.networkutils.http.getAsyncC

suspend fun main() {
	val request = HttpRequestAction("https://api.github.com/users/Ushiosan23")

	// Asynchronous request with coroutines
	println(request.getAsyncC().body())

	// Synchronous request
	println(request.get().body())
}

Versions

Version
0.0.4
0.0.3
0.0.2
0.0.1