-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ryccoatika/snapshot
v0.6.9
- Loading branch information
Showing
57 changed files
with
1,910 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Android CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- snapshot | ||
- main | ||
|
||
jobs: | ||
builds: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'zulu' | ||
java-version: 17 | ||
|
||
- name: Set variables for versions | ||
run: | | ||
VERSION_NAME=`cat gradle.properties | grep "VERSION_NAME" | cut -d'=' -f2` | ||
IS_SNAPSHOT=$( [[ github.ref == "refs/heads/snapshot" ]] && echo "1" || echo "0" ) | ||
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV | ||
echo "IS_SNAPSHOT=$IS_SNAPSHOT" >> $GITHUB_ENV | ||
- name: Generate release notes | ||
if: github.ref == 'refs/heads/main' | ||
run: ./gradlew -q getChangelog >> RELEASE_NOTES.md | ||
|
||
- name: Release on Github | ||
if: github.ref == 'refs/heads/main' | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: ${{ env.VERSION_NAME }} | ||
body_path: RELEASE_NOTES.md | ||
files: | | ||
socket-server/build/outputs/aar/socket-client-release.aar | ||
socket-client/build/outputs/aar/socket-client-release.aar | ||
- name: Release to sonatype | ||
run: ./gradlew publish --no-daemon --no-parallel | ||
env: | ||
ORG_GRADLE_PROJECT_IS_SNAPSHOT: ${{ env.IS_SNAPSHOT }} | ||
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | ||
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} | ||
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} | ||
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} | ||
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} |
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,11 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/ | ||
.DS_Store | ||
**/*/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
/release/*.gpg |
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,7 @@ | ||
# Changelog | ||
|
||
## [0.6.9] | ||
|
||
Initial release of Simple Socket, including modules for | ||
- Socket Server: Serve socket server with useful callback | ||
- Socket Client: Connect to socket server and sending message |
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,148 @@ | ||
Simple Socket | ||
------- | ||
[![Android CI](https://github.com/ryccoatika/simple-socket/actions/workflows/android.yml/badge.svg)](https://github.com/ryccoatika/simple-socket/actions/workflows/android.yml) | ||
[![Release](https://img.shields.io/github/v/release/ryccoatika/simple-socket.svg?include_prereleases)](https://github.com/ryccoatika/simple-socket/releases) | ||
|
||
<img src="art/video_sample.gif" title="Animated example."/> | ||
|
||
--- | ||
|
||
Usage | ||
------- | ||
|
||
Don't worry about exception, This library has handle all of the exceptions and throw it through callback. | ||
|
||
### Socket Server | ||
|
||
Passing port to the constructor argument if you want to specify the port. | ||
|
||
```kotlin | ||
val socketServer = SocketServer() | ||
val port = socketServer.port | ||
``` | ||
|
||
Set listener for socket server | ||
```kotlin | ||
val socketServerCallback = object : SocketServerCallback { | ||
override fun onClientConnected(client: Client) { | ||
// you may want to store all of the connected client | ||
} | ||
|
||
override fun onClientDisconnected(client: Client) { | ||
// when client disconnected | ||
} | ||
|
||
override fun onMessageReceived(client: Client, message: String) { | ||
// message received from client | ||
} | ||
} | ||
socketServer.setSocketServerCallback(socketServerCallback) | ||
``` | ||
|
||
Start the server | ||
```kotlin | ||
socketServer.startServer() | ||
``` | ||
|
||
### Socket Client | ||
|
||
Create an object from class `SocketClient` with server host and port as arguments | ||
```kotlin | ||
val socketClient = SocketClient(host, port) | ||
``` | ||
|
||
Set listener for socket client | ||
```kotlin | ||
val socketClientCallback = object : SocketClientCallback { | ||
override fun onConnected() { | ||
// when connected to the server | ||
} | ||
|
||
override fun onConnectionFailure(e: Exception) { | ||
// any failure occurs would be thrown here | ||
} | ||
|
||
override fun onDisconnected() { | ||
// called when client call disconnect() or server has gone | ||
} | ||
} | ||
socketClient.setSocketClientCallback(socketClientCallback) | ||
``` | ||
|
||
Connect the client to server | ||
```kotlin | ||
socketClient.connect() | ||
``` | ||
|
||
--- | ||
|
||
Sample apps | ||
------- | ||
|
||
I have built [sample app](https://github.com/ryccoatika/simple-socket/blob/main/sample-app) using jetpack compose. | ||
|
||
--- | ||
|
||
Download | ||
------- | ||
All artifacts are up on Maven Central | ||
|
||
For socket server library | ||
``` | ||
com.ryccoatika.simplesocket:socket-server:<version> | ||
``` | ||
For socket client library | ||
``` | ||
com.ryccoatika.simplesocket:socket-client:<version> | ||
``` | ||
|
||
latest stable version is [![Release](https://img.shields.io/github/v/release/ryccoatika/simple-socket.svg?include_prereleases)](https://github.com/ryccoatika/simple-socket/releases) | ||
|
||
### Snapshots | ||
|
||
Snapshots are also available by adding the repository | ||
```kotlin | ||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") | ||
``` | ||
Letting you specify | ||
``` | ||
com.ryccoatika.simplesocket:socket-server:0.6.9-SNAPSHOT | ||
com.ryccoatika.simplesocket:socket-client:0.6.9-SNAPSHOT | ||
``` | ||
|
||
--- | ||
|
||
Contributing | ||
------- | ||
Pull requests are welcome. | ||
|
||
TODO: | ||
- Add callback for server message to client | ||
- Generate mkdocs | ||
- Thread safe optimization (have to make sure for thread safe) | ||
|
||
--- | ||
|
||
License | ||
------- | ||
MIT License | ||
|
||
Copyright (c) 2023 Rycco Atika | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,58 @@ | ||
@file:Suppress("UnstableApiUsage") | ||
|
||
import com.android.build.gradle.BaseExtension | ||
import com.vanniktech.maven.publish.MavenPublishBaseExtension | ||
|
||
plugins { | ||
id("com.android.application") version "8.1.1" apply false | ||
id("com.android.library") version "8.1.1" apply false | ||
id("org.jetbrains.kotlin.android") version "1.8.10" apply false | ||
id("com.vanniktech.maven.publish") version "0.25.3" apply false | ||
id("org.jetbrains.changelog") version "2.2.0" | ||
} | ||
|
||
allprojects { | ||
group = properties["GROUP"]!! | ||
version = properties["VERSION_NAME"]!! | ||
if (properties["IS_SNAPSHOT"] == "1") { | ||
version = "$version-SNAPSHOT" | ||
} | ||
|
||
pluginManager.withPlugin("com.android.application") { | ||
configureAndroidProject() | ||
} | ||
pluginManager.withPlugin("com.android.library") { | ||
configureAndroidProject() | ||
configureAndroidLibraryPublication() | ||
} | ||
} | ||
|
||
fun Project.configureAndroidProject() { | ||
extensions.configure<BaseExtension> { | ||
compileSdkVersion(34) | ||
|
||
defaultConfig { | ||
minSdk = 21 | ||
targetSdk = 34 | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
} | ||
|
||
fun Project.configureAndroidLibraryPublication() { | ||
apply(plugin = "com.vanniktech.maven.publish") | ||
extensions.configure<MavenPublishBaseExtension> { | ||
beforeEvaluate { | ||
pomFromGradleProperties() | ||
configure( | ||
com.vanniktech.maven.publish.AndroidSingleVariantLibrary( | ||
variant = "release", | ||
) | ||
) | ||
} | ||
} | ||
} |
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,24 @@ | ||
org.gradle.jvmargs=-Xmx1536m | ||
android.useAndroidX=true | ||
org.gradle.caching=true | ||
org.gradle.parallel=true | ||
|
||
GROUP=com.ryccoatika.simplesocket | ||
VERSION_NAME=0.6.9 | ||
|
||
SONATYPE_HOST=S01 | ||
RELEASE_SIGNING_ENABLED=true | ||
|
||
POM_URL=https://github.com/ryccoatika/simple-socket | ||
|
||
POM_SCM_URL=https://github.com/ryccoatika/simple-socket | ||
POM_SCM_CONNECTION=scm:git:https://github.com/ryccoatika/simple-socket.git | ||
POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/ryccoatika/simple-socket.git | ||
|
||
POM_LICENCE_NAME=The MIT License | ||
POM_LICENCE_URL=https://opensource.org/licenses/MIT | ||
POM_LICENCE_DIST=repo | ||
|
||
POM_DEVELOPER_ID=ryccoatika | ||
POM_DEVELOPER_NAME=Rycco Atika | ||
POM_DEVELOPER_URL=https://github.com/ryccoatika/ |
Binary file not shown.
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,6 @@ | ||
#Thu Oct 12 20:45:13 WIB 2023 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.