├── .gitattributes ├── .gitignore ├── Android ├── Blink │ ├── .gitignore │ ├── build.gradle │ ├── gradle.properties │ ├── gradlew │ ├── gradlew.bat │ ├── library │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── net │ │ │ │ └── qiujuer │ │ │ │ └── blink │ │ │ │ └── ApplicationTest.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── net │ │ │ │ └── qiujuer │ │ │ │ └── blink │ │ │ │ ├── Blink.java │ │ │ │ ├── async │ │ │ │ ├── AsyncEventArgs.java │ │ │ │ ├── AsyncReceiveDispatcher.java │ │ │ │ ├── AsyncSendDispatcher.java │ │ │ │ ├── AsyncSocketAdapter.java │ │ │ │ └── HandleSelector.java │ │ │ │ ├── box │ │ │ │ ├── BaseReceivePacket.java │ │ │ │ ├── BaseSendPacket.java │ │ │ │ ├── ByteReceivePacket.java │ │ │ │ ├── ByteSendPacket.java │ │ │ │ ├── FileReceivePacket.java │ │ │ │ ├── FileSendPacket.java │ │ │ │ ├── StringReceivePacket.java │ │ │ │ └── StringSendPacket.java │ │ │ │ ├── core │ │ │ │ ├── BlinkConn.java │ │ │ │ ├── BlinkDelivery.java │ │ │ │ ├── BlinkPacket.java │ │ │ │ ├── BlinkParser.java │ │ │ │ ├── Packet.java │ │ │ │ ├── ReceiveDelivery.java │ │ │ │ ├── ReceivePacket.java │ │ │ │ ├── Receiver.java │ │ │ │ ├── Resource.java │ │ │ │ ├── SendDelivery.java │ │ │ │ ├── SendPacket.java │ │ │ │ └── Sender.java │ │ │ │ ├── kit │ │ │ │ ├── BitConverter.java │ │ │ │ ├── BlinkLog.java │ │ │ │ ├── BlinkParserImpl.java │ │ │ │ ├── DiskResource.java │ │ │ │ ├── Disposable.java │ │ │ │ ├── ExecutorDelivery.java │ │ │ │ └── HashConverter.java │ │ │ │ └── listener │ │ │ │ ├── BlinkListener.java │ │ │ │ ├── ReceiveListener.java │ │ │ │ └── SendListener.java │ │ │ └── res │ │ │ └── values │ │ │ └── strings.xml │ ├── old │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── net │ │ │ │ └── qiujuer │ │ │ │ └── blink │ │ │ │ └── ApplicationTest.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── net │ │ │ │ └── qiujuer │ │ │ │ └── blink │ │ │ │ ├── Blink.java │ │ │ │ ├── BlinkLog.java │ │ │ │ ├── DiskResource.java │ │ │ │ ├── ExecutorDelivery.java │ │ │ │ ├── SocketAdapter.java │ │ │ │ ├── box │ │ │ │ ├── ByteReceivePacket.java │ │ │ │ ├── ByteSendPacket.java │ │ │ │ ├── FileReceivePacket.java │ │ │ │ ├── FileSendPacket.java │ │ │ │ ├── StringReceivePacket.java │ │ │ │ └── StringSendPacket.java │ │ │ │ ├── core │ │ │ │ ├── BlinkConn.java │ │ │ │ ├── BlinkPacket.java │ │ │ │ ├── EntityNode.java │ │ │ │ ├── HeadNode.java │ │ │ │ ├── ReceiveDelivery.java │ │ │ │ ├── ReceiveDispatcher.java │ │ │ │ ├── ReceivePacket.java │ │ │ │ ├── ReceiveParser.java │ │ │ │ ├── Receiver.java │ │ │ │ ├── Resource.java │ │ │ │ ├── SendDelivery.java │ │ │ │ ├── SendDispatcher.java │ │ │ │ ├── SendPacket.java │ │ │ │ └── Sender.java │ │ │ │ └── listener │ │ │ │ ├── ReceiveListener.java │ │ │ │ └── SendListener.java │ │ │ └── res │ │ │ └── values │ │ │ └── strings.xml │ ├── sample │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── net │ │ │ │ └── qiujuer │ │ │ │ └── sample │ │ │ │ └── blink │ │ │ │ └── ApplicationTest.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── net │ │ │ │ └── qiujuer │ │ │ │ └── sample │ │ │ │ └── blink │ │ │ │ └── MainActivity.java │ │ │ └── res │ │ │ ├── layout │ │ │ └── activity_main.xml │ │ │ ├── menu │ │ │ └── menu_main.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ │ └── values │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ └── settings.gradle └── Sample │ └── Client.apk ├── Art ├── Client.png ├── FlowChart.png ├── Logo.png ├── Server.png └── Src │ ├── Blink.bmpr │ └── Logo.ai ├── C Sharp ├── Blink │ ├── .gitignore │ ├── Blink.sln │ ├── Blink.v12.suo │ ├── Blink │ │ ├── Async │ │ │ ├── AsyncAbsDispatcher.cs │ │ │ ├── AsyncReceiveDispatcher.cs │ │ │ ├── AsyncSendDispatcher.cs │ │ │ ├── AsyncSocketAdapter.cs │ │ │ └── SocketAsyncEventArgsPool.cs │ │ ├── Blink.cs │ │ ├── Blink.csproj │ │ ├── Blink_Key.pfx │ │ ├── Box │ │ │ ├── BaseReceivePacket.cs │ │ │ ├── BaseSendPacket.cs │ │ │ ├── ByteReceivePacket.cs │ │ │ ├── ByteSendPacket.cs │ │ │ ├── FileReceivePacket.cs │ │ │ ├── FileSendPacket.cs │ │ │ ├── StringReceivePacket.cs │ │ │ └── StringSendPacket.cs │ │ ├── ClassDiagram1.cd │ │ ├── Core │ │ │ ├── BlinkConn.cs │ │ │ ├── BlinkDelivery.cs │ │ │ ├── BlinkPacket.cs │ │ │ ├── BlinkParser.cs │ │ │ ├── Packet.cs │ │ │ ├── ReceiveDelivery.cs │ │ │ ├── ReceivePacket.cs │ │ │ ├── Receiver.cs │ │ │ ├── Resource.cs │ │ │ ├── SendDelivery.cs │ │ │ ├── SendPacket.cs │ │ │ └── Sender.cs │ │ ├── Kit │ │ │ ├── BlinkLog.cs │ │ │ ├── BlinkParserImpl.cs │ │ │ ├── CallBackDelivery.cs │ │ │ ├── DelegateDelivery.cs │ │ │ ├── DiskResource.cs │ │ │ ├── EventDelivery.cs │ │ │ └── Runnable.cs │ │ ├── Listener │ │ │ ├── BlinkListener.cs │ │ │ ├── ReceiveListener.cs │ │ │ └── SendListener.cs │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ ├── BlinkTest │ │ ├── .gitignore │ │ ├── App.config │ │ ├── BlinkTest.csproj │ │ ├── Program.cs │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ ├── Client │ │ ├── .gitignore │ │ ├── App.config │ │ ├── Client.csproj │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── SendCallBack.cs │ └── Server │ │ ├── .gitignore │ │ ├── App.config │ │ ├── BlinkCallBack.cs │ │ ├── Program.cs │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ └── Server.csproj └── Sample │ ├── Client │ ├── Blink.dll │ └── Client.exe │ └── Server │ ├── Blink.dll │ └── Server.exe ├── Java ├── Blink │ ├── .gitignore │ ├── build.gradle │ ├── gradlew │ ├── gradlew.bat │ ├── library │ │ ├── .classpath │ │ ├── .project │ │ ├── .settings │ │ │ └── org.eclipse.jdt.core.prefs │ │ ├── build.gradle │ │ └── src │ │ │ └── net │ │ │ └── qiujuer │ │ │ └── blink │ │ │ ├── BlinkClient.java │ │ │ ├── BlinkConnect.java │ │ │ ├── BlinkServer.java │ │ │ ├── async │ │ │ ├── AsyncDispatcher.java │ │ │ ├── AsyncFormatter.java │ │ │ ├── AsyncParser.java │ │ │ ├── AsyncReceiveDispatcher.java │ │ │ ├── AsyncSendDispatcher.java │ │ │ ├── AsyncSocketAdapter.java │ │ │ ├── IoEventArgs.java │ │ │ └── SelectorFactory.java │ │ │ ├── box │ │ │ ├── BaseReceivePacket.java │ │ │ ├── BaseSendPacket.java │ │ │ ├── ByteReceivePacket.java │ │ │ ├── ByteSendPacket.java │ │ │ ├── FileReceivePacket.java │ │ │ ├── FileSendPacket.java │ │ │ ├── StringReceivePacket.java │ │ │ └── StringSendPacket.java │ │ │ ├── core │ │ │ ├── BlinkParser.java │ │ │ ├── Connector.java │ │ │ ├── ExecutorDelivery.java │ │ │ ├── Packet.java │ │ │ ├── PacketFilter.java │ │ │ ├── PacketFormatter.java │ │ │ ├── PacketParser.java │ │ │ ├── PacketType.java │ │ │ ├── ReceiveDispatcher.java │ │ │ ├── ReceivePacket.java │ │ │ ├── Receiver.java │ │ │ ├── SendDispatcher.java │ │ │ ├── SendPacket.java │ │ │ ├── Sender.java │ │ │ ├── delivery │ │ │ │ ├── ConnectDelivery.java │ │ │ │ ├── ReceiveDelivery.java │ │ │ │ └── SendDelivery.java │ │ │ └── listener │ │ │ │ ├── ConnectListener.java │ │ │ │ ├── ReceiveListener.java │ │ │ │ └── SendListener.java │ │ │ └── kit │ │ │ ├── BlinkParserImpl.java │ │ │ ├── DiskResource.java │ │ │ ├── Disposable.java │ │ │ ├── Resource.java │ │ │ └── convert │ │ │ ├── BitConverter.java │ │ │ └── HashConverter.java │ ├── sample │ │ ├── .classpath │ │ ├── .project │ │ ├── .settings │ │ │ └── org.eclipse.jdt.core.prefs │ │ ├── build.gradle │ │ └── src │ │ │ └── net │ │ │ └── qiujuer │ │ │ └── sample │ │ │ └── blink │ │ │ ├── CallBack.java │ │ │ ├── Client.java │ │ │ ├── Server.java │ │ │ └── Utils.java │ └── settings.gradle └── Sample │ └── Sample.zip ├── LICENSE ├── README.md └── Release ├── Android ├── Blink.jar └── blink.aar ├── C Sharp └── 1.0.0.0 │ ├── Blink.dll │ └── Blink.pdb └── Java └── blink.jar /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.ap_ 3 | 4 | # Files for the Dalvik VM 5 | *.dex 6 | 7 | # Java class files 8 | *.class 9 | 10 | # Generated files 11 | bin/ 12 | gen/ 13 | obj/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | /*/build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | -------------------------------------------------------------------------------- /Android/Blink/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/ 4 | /gradle 5 | .DS_Store 6 | /build 7 | /captures 8 | *.iml -------------------------------------------------------------------------------- /Android/Blink/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.3.0' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Android/Blink/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /Android/Blink/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /Android/Blink/library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Android/Blink/library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 22 5 | buildToolsVersion "22.0.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 22 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | task clear(type: Delete) { 22 | delete '../../../Release/Android/blink.jar' 23 | delete '../../../Release/Android/blink.aar' 24 | } 25 | 26 | task make(type: Copy) { 27 | // Jar 28 | from('build/intermediates/bundles/release/') 29 | into('../../../Release/Android/') 30 | include('classes.jar') 31 | rename('classes.jar', 'blink.jar') 32 | // aar 33 | from('build/outputs/aar/') 34 | into('../../../Release/Android/') 35 | include('library-release.aar') 36 | rename('library-release.aar', 'blink.aar') 37 | } 38 | make.dependsOn(clear, build) -------------------------------------------------------------------------------- /Android/Blink/library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\ToolKits\Android\SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /Android/Blink/library/src/androidTest/java/net/qiujuer/blink/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package net.qiujuer.blink; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /Android/Blink/library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/box/BaseReceivePacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.box; 21 | 22 | import net.qiujuer.blink.core.ReceivePacket; 23 | 24 | import java.io.OutputStream; 25 | 26 | /** 27 | * The Receive base class 28 | */ 29 | public abstract class BaseReceivePacket extends ReceivePacket { 30 | protected OutputStream mStream; 31 | protected T mEntity; 32 | 33 | public BaseReceivePacket(long id, byte type, long len) { 34 | super(id, type, len); 35 | } 36 | 37 | public T getEntity() { 38 | return mEntity; 39 | } 40 | 41 | @Override 42 | public void write(byte[] buffer, int offset, int count) { 43 | OutputStream stream = mStream; 44 | if (stream != null) { 45 | try { 46 | stream.write(buffer, offset, count); 47 | stream.flush(); 48 | } catch (Exception e) { 49 | e.printStackTrace(); 50 | } 51 | } 52 | } 53 | 54 | protected void closeStream() { 55 | OutputStream stream = mStream; 56 | mStream = null; 57 | if (stream != null) { 58 | try { 59 | stream.flush(); 60 | stream.close(); 61 | } catch (Exception e) { 62 | e.printStackTrace(); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/box/BaseSendPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.box; 21 | 22 | import net.qiujuer.blink.core.SendPacket; 23 | import net.qiujuer.blink.listener.SendListener; 24 | 25 | import java.io.InputStream; 26 | 27 | /** 28 | * The Send base class 29 | */ 30 | public abstract class BaseSendPacket extends SendPacket { 31 | protected T mEntity; 32 | protected InputStream mStream; 33 | 34 | public BaseSendPacket(T entity, byte type, SendListener listener) { 35 | super(type, listener); 36 | mEntity = entity; 37 | } 38 | 39 | 40 | public T getEntity() { 41 | return mEntity; 42 | } 43 | 44 | @Override 45 | public int read(byte[] buffer, int offset, int count) { 46 | InputStream stream = mStream; 47 | if (stream == null) 48 | return -1; 49 | try { 50 | return stream.read(buffer, offset, count); 51 | } catch (Exception e) { 52 | return -1; 53 | } 54 | } 55 | 56 | protected void closeStream() { 57 | InputStream stream = mStream; 58 | mStream = null; 59 | if (stream != null) { 60 | try { 61 | stream.close(); 62 | } catch (Exception e) { 63 | e.printStackTrace(); 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/box/ByteReceivePacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.box; 21 | 22 | import java.io.ByteArrayOutputStream; 23 | 24 | /** 25 | * Bytes receive class 26 | */ 27 | public class ByteReceivePacket extends BaseReceivePacket { 28 | public ByteReceivePacket(long id, byte type, long len) { 29 | super(id, type, len); 30 | } 31 | 32 | @Override 33 | public boolean startPacket() { 34 | try { 35 | mStream = new ByteArrayOutputStream((int) getLength()); 36 | return true; 37 | } catch (Exception e) { 38 | return false; 39 | } 40 | } 41 | 42 | @Override 43 | public void endPacket() { 44 | if (mStream != null) { 45 | mEntity = ((ByteArrayOutputStream) mStream).toByteArray(); 46 | closeStream(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/box/ByteSendPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.box; 21 | 22 | import net.qiujuer.blink.listener.SendListener; 23 | 24 | import java.io.ByteArrayInputStream; 25 | 26 | /** 27 | * Bytes send class 28 | */ 29 | public class ByteSendPacket extends BaseSendPacket { 30 | public ByteSendPacket(byte[] entity) { 31 | this(entity, null); 32 | } 33 | 34 | public ByteSendPacket(byte[] entity, SendListener listener) { 35 | super(entity, PacketType.BYTES, listener); 36 | mLength = mEntity.length; 37 | } 38 | 39 | @Override 40 | public boolean startPacket() { 41 | try { 42 | mStream = new ByteArrayInputStream(mEntity); 43 | return true; 44 | } catch (Exception e) { 45 | return false; 46 | } 47 | } 48 | 49 | @Override 50 | public void endPacket() { 51 | closeStream(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/box/FileSendPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.box; 21 | 22 | import net.qiujuer.blink.listener.SendListener; 23 | 24 | import java.io.File; 25 | import java.io.FileInputStream; 26 | import java.io.FileNotFoundException; 27 | 28 | /** 29 | * File send class 30 | */ 31 | public class FileSendPacket extends BaseSendPacket { 32 | 33 | public FileSendPacket(File file) { 34 | this(file, null); 35 | } 36 | 37 | public FileSendPacket(File entity, SendListener listener) { 38 | super(entity, PacketType.FILE, listener); 39 | mLength = mEntity.length(); 40 | } 41 | 42 | @Override 43 | public boolean startPacket() { 44 | try { 45 | mStream = new FileInputStream(mEntity); 46 | return true; 47 | } catch (FileNotFoundException e) { 48 | return false; 49 | } 50 | } 51 | 52 | @Override 53 | public void endPacket() { 54 | closeStream(); 55 | } 56 | 57 | @Override 58 | public short readInfo(byte[] buffer, int index) { 59 | try { 60 | byte[] info = mEntity.getName().getBytes("UTF-8"); 61 | short len = (short) info.length; 62 | System.arraycopy(info, 0, buffer, index, len); 63 | return len; 64 | } catch (Exception e) { 65 | return 0; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/box/StringReceivePacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.box; 21 | 22 | import java.io.ByteArrayOutputStream; 23 | import java.io.UnsupportedEncodingException; 24 | 25 | /** 26 | * String receive class 27 | */ 28 | public class StringReceivePacket extends BaseReceivePacket { 29 | public StringReceivePacket(long id, byte type, long len) { 30 | super(id, type, len); 31 | } 32 | 33 | @Override 34 | public boolean startPacket() { 35 | try { 36 | mStream = new ByteArrayOutputStream((int) getLength()); 37 | return true; 38 | } catch (Exception e) { 39 | return false; 40 | } 41 | } 42 | 43 | @Override 44 | public void endPacket() { 45 | if (mStream != null) { 46 | byte[] bytes = ((ByteArrayOutputStream) mStream).toByteArray(); 47 | try { 48 | mEntity = new String(bytes, 0, bytes.length, "UTF-8"); 49 | } catch (UnsupportedEncodingException e) { 50 | e.printStackTrace(); 51 | } 52 | 53 | closeStream(); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/box/StringSendPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.box; 21 | 22 | import net.qiujuer.blink.listener.SendListener; 23 | 24 | import java.io.UnsupportedEncodingException; 25 | 26 | /** 27 | * String send class 28 | */ 29 | public class StringSendPacket extends ByteSendPacket { 30 | public StringSendPacket(String entity) throws UnsupportedEncodingException { 31 | this(entity, null); 32 | } 33 | 34 | public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException { 35 | super(entity.getBytes("UTF-8"), listener); 36 | 37 | mType = PacketType.STRING; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/core/BlinkDelivery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | import net.qiujuer.blink.kit.Disposable; 23 | 24 | /** 25 | * Blink status delivery interface 26 | */ 27 | public interface BlinkDelivery extends Disposable { 28 | /** 29 | * On Socket Disconnect Post CallBack 30 | */ 31 | void postBlinkDisconnect(); 32 | } 33 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/core/BlinkPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | /** 23 | * Blink Data Packet 24 | */ 25 | public abstract class BlinkPacket implements Packet { 26 | private boolean mSucceed; 27 | protected byte mType; 28 | protected long mLength; 29 | 30 | public BlinkPacket(byte type) { 31 | mType = type; 32 | } 33 | 34 | 35 | @Override 36 | public byte getPacketType() { 37 | return mType; 38 | } 39 | 40 | @Override 41 | public long getLength() { 42 | return mLength; 43 | } 44 | 45 | @Override 46 | public void setSuccess(boolean isSuccess) { 47 | mSucceed = isSuccess; 48 | } 49 | 50 | @Override 51 | public boolean isSucceed() { 52 | return mSucceed; 53 | } 54 | 55 | /** 56 | * On Send or Receive start call this 57 | * 58 | * @return Init status 59 | */ 60 | public abstract boolean startPacket(); 61 | 62 | /** 63 | * On Send or Receive end call this 64 | */ 65 | public abstract void endPacket(); 66 | 67 | /** 68 | * Blink Packet Type 69 | */ 70 | public static class PacketType { 71 | public final static byte STRING = 1; 72 | public final static byte BYTES = 2; 73 | public final static byte FILE = 3; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/core/BlinkParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | /** 23 | * Blink parse interface 24 | */ 25 | public interface BlinkParser { 26 | 27 | /** 28 | * Parse receiver receive data 29 | * 30 | * @param type Data type 31 | * @param len Data Len 32 | * @return ReceivePacket 33 | */ 34 | ReceivePacket parseReceive(byte type, long len); 35 | } 36 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/core/Packet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | /** 23 | * Bink Packet Interface 24 | */ 25 | public interface Packet { 26 | 27 | /** 28 | * Get packet type 29 | * 30 | * @return Type 31 | */ 32 | byte getPacketType(); 33 | 34 | /** 35 | * Get packet length 36 | * 37 | * @return Size 38 | */ 39 | long getLength(); 40 | 41 | /** 42 | * Set packet send or receive status 43 | * 44 | * @param isSuccess Status 45 | */ 46 | void setSuccess(boolean isSuccess); 47 | 48 | /** 49 | * Get the packet is succeed 50 | * 51 | * @return Status 52 | */ 53 | boolean isSucceed(); 54 | } 55 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/core/ReceiveDelivery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | /** 23 | * Receiver delivery interface 24 | */ 25 | public interface ReceiveDelivery { 26 | /** 27 | * Parses a start response from the receiver. 28 | * 29 | * @param entity ReceivePacket 30 | */ 31 | void postReceiveStart(ReceivePacket entity); 32 | 33 | /** 34 | * Parses a end response from the receiver. 35 | * 36 | * @param entity ReceivePacket 37 | * @param isSuccess isSuccess 38 | */ 39 | void postReceiveEnd(ReceivePacket entity, boolean isSuccess); 40 | 41 | /** 42 | * Parses a progress response from the receiver. 43 | * 44 | * @param entity ReceivePacket 45 | * @param progress Receive progress 46 | */ 47 | void postReceiveProgress(ReceivePacket entity, float progress); 48 | } 49 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/core/ReceivePacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | /** 23 | * Receive Packet 24 | */ 25 | public abstract class ReceivePacket extends BlinkPacket { 26 | private final long mId; 27 | private String mHash; 28 | 29 | public ReceivePacket(long id, byte type, long len) { 30 | super(type); 31 | mId = id; 32 | mLength = len; 33 | } 34 | 35 | public long getId() { 36 | return mId; 37 | } 38 | 39 | /** 40 | * Set Packet Hash Code 41 | * 42 | * @param hashCode HashCode 43 | */ 44 | public void setHash(String hashCode) { 45 | mHash = hashCode; 46 | } 47 | 48 | /** 49 | * Get Packet Hash Code 50 | * 51 | * @return HashCode 52 | */ 53 | public String getHash() { 54 | return mHash; 55 | } 56 | 57 | /** 58 | * On Receiver receive same info buffer call this 59 | * 60 | * @param buffer Info data 61 | * @param offset Buffer offset 62 | * @param count Buffer Count 63 | */ 64 | public void writeInfo(byte[] buffer, int offset, int count) { 65 | } 66 | 67 | /** 68 | * Receiver write buffer 69 | * 70 | * @param buffer Buffer 71 | * @param offset Buffer offset 72 | * @param count Buffer Count 73 | */ 74 | public abstract void write(byte[] buffer, int offset, int count); 75 | } 76 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/core/Receiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | import net.qiujuer.blink.async.AsyncEventArgs; 23 | import net.qiujuer.blink.kit.Disposable; 24 | 25 | /** 26 | * This socket receiver 27 | */ 28 | public interface Receiver extends Disposable { 29 | /** 30 | * Get receive buffer size 31 | * 32 | * @return Buffer Size 33 | */ 34 | int getReceiveBufferSize(); 35 | 36 | /** 37 | * Async receive same data to buffer 38 | * 39 | * @param e SocketAsyncEventArgs 40 | * @return Status 41 | */ 42 | boolean receiveAsync(AsyncEventArgs e); 43 | } 44 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/core/Resource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | import java.io.File; 23 | 24 | /** 25 | * Blink Files Resource 26 | */ 27 | public interface Resource { 28 | /** 29 | * Create a file from resource. 30 | * 31 | * @return New file path 32 | */ 33 | File create(long id); 34 | 35 | /** 36 | * Empties the resource by oneself 37 | */ 38 | void clear(); 39 | 40 | /** 41 | * Empties the resource by the path 42 | */ 43 | void clearAll(); 44 | 45 | /** 46 | * Get the Mark 47 | * 48 | * @return Receive Mark 49 | */ 50 | String getMark(); 51 | } 52 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendDelivery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | import net.qiujuer.blink.kit.Disposable; 23 | 24 | /** 25 | * Send delivery interface 26 | */ 27 | public interface SendDelivery extends Disposable { 28 | 29 | /** 30 | * Parses a progress response from the sender. 31 | * 32 | * @param entity SendPacket 33 | * @param progress Send progress 34 | */ 35 | void postSendProgress(SendPacket entity, float progress); 36 | } 37 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | import net.qiujuer.blink.listener.SendListener; 23 | 24 | /** 25 | * Blink SendPacket 26 | */ 27 | public abstract class SendPacket extends BlinkPacket { 28 | private final SendListener mListener; 29 | private boolean mCanceled; 30 | private BlinkConn mBlinkConn; 31 | 32 | 33 | public SendPacket(byte type, SendListener listener) { 34 | super(type); 35 | mListener = listener; 36 | } 37 | 38 | public SendListener getListener() { 39 | return mListener; 40 | } 41 | 42 | /** 43 | * Cancel the packet to send 44 | * If the packet on sending you can't cancel it 45 | * But you can cancel sending notify callback 46 | */ 47 | public void cancel() { 48 | mCanceled = true; 49 | if (mBlinkConn != null) { 50 | mBlinkConn.cancel(this); 51 | mBlinkConn = null; 52 | } 53 | } 54 | 55 | /** 56 | * Get the packet iscanceled 57 | * 58 | * @return Is Canceled 59 | */ 60 | public boolean isCanceled() { 61 | return mCanceled; 62 | } 63 | 64 | /** 65 | * Set The BlinkConn to Cancel from queue 66 | * 67 | * @param blinkConn BlinkConn 68 | * @return SendPacket 69 | */ 70 | SendPacket setBlinkConn(BlinkConn blinkConn) { 71 | mBlinkConn = blinkConn; 72 | return this; 73 | } 74 | 75 | /** 76 | * On Sender send the packet call this to send packet info 77 | * The bytes in 0~32767 size 78 | * 79 | * @param buffer Send buffer 80 | * @param index Buffer start index 81 | * @return Read to buffer count 82 | */ 83 | public short readInfo(byte[] buffer, int index) { 84 | return 0; 85 | } 86 | 87 | /** 88 | * Sender read same data to send 89 | * 90 | * @param buffer Buffer 91 | * @param offset Buffer offset 92 | * @param count Buffer count 93 | * @return Read to buffer count 94 | */ 95 | public abstract int read(byte[] buffer, int offset, int count); 96 | } 97 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/core/Sender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | import net.qiujuer.blink.async.AsyncEventArgs; 23 | import net.qiujuer.blink.kit.Disposable; 24 | 25 | /** 26 | * This socket sender 27 | */ 28 | public interface Sender extends Disposable { 29 | /** 30 | * Get socket send buffer size 31 | * 32 | * @return Buffer Size 33 | */ 34 | int getSendBufferSize(); 35 | 36 | /** 37 | * Async send same byte 38 | * 39 | * @param e SocketAsyncEventArgs 40 | * @return Status 41 | */ 42 | boolean sendAsync(AsyncEventArgs e); 43 | } 44 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/kit/BlinkParserImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.kit; 21 | 22 | import net.qiujuer.blink.box.ByteReceivePacket; 23 | import net.qiujuer.blink.box.FileReceivePacket; 24 | import net.qiujuer.blink.box.StringReceivePacket; 25 | import net.qiujuer.blink.core.BlinkPacket; 26 | import net.qiujuer.blink.core.BlinkParser; 27 | import net.qiujuer.blink.core.ReceivePacket; 28 | import net.qiujuer.blink.core.Resource; 29 | 30 | import java.io.File; 31 | 32 | 33 | public class BlinkParserImpl implements BlinkParser { 34 | private long mId = 0; 35 | protected Resource mResource; 36 | 37 | public BlinkParserImpl(Resource resource) { 38 | mResource = resource; 39 | } 40 | 41 | @Override 42 | public ReceivePacket parseReceive(byte type, long len) { 43 | long id = ++mId; 44 | ReceivePacket packet = null; 45 | switch (type) { 46 | case BlinkPacket.PacketType.STRING: 47 | packet = new StringReceivePacket(id, type, len); 48 | break; 49 | case BlinkPacket.PacketType.BYTES: 50 | packet = new ByteReceivePacket(id, type, len); 51 | break; 52 | case BlinkPacket.PacketType.FILE: 53 | File file = mResource.create(id); 54 | if (file != null) 55 | packet = new FileReceivePacket(id, type, len, file); 56 | break; 57 | } 58 | return packet; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/kit/Disposable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.kit; 21 | 22 | /** 23 | * Define a way to release resources allocated. 24 | */ 25 | public interface Disposable { 26 | /** 27 | * Perform related to release or reset unmanaged resources application defined tasks. 28 | */ 29 | void dispose(); 30 | } 31 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/kit/HashConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.kit; 21 | 22 | /** 23 | * Hash Converter 24 | */ 25 | public class HashConverter { 26 | private static final char HEX_DIGITS[] = {'0', '1', '2', '3', '4', '5', 27 | '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; 28 | 29 | /** 30 | * Convert bytes to md5 string 31 | * 32 | * @param b bytes 33 | * @return md5 34 | */ 35 | public static String toMd5(byte[] b) { 36 | StringBuilder sb = new StringBuilder(b.length * 2); 37 | for (byte a : b) { 38 | sb.append(HEX_DIGITS[(a & 0xf0) >>> 4]); 39 | sb.append(HEX_DIGITS[a & 0x0f]); 40 | } 41 | return sb.toString(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/listener/BlinkListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.listener; 21 | 22 | /** 23 | * Blink notify listener 24 | */ 25 | public interface BlinkListener { 26 | 27 | /** 28 | * On Receive or Sender error by socket err call this 29 | */ 30 | void onBlinkDisconnect(); 31 | } 32 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/listener/ReceiveListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.listener; 21 | 22 | import net.qiujuer.blink.core.ReceivePacket; 23 | 24 | /** 25 | * Receive notify listener 26 | */ 27 | public interface ReceiveListener { 28 | /** 29 | * On Receiver receive new packet call this 30 | * 31 | * @param type Packet Type 32 | * @param id Packet Id 33 | */ 34 | void onReceiveStart(byte type, long id); 35 | 36 | /** 37 | * Receiver receive packet progress 38 | * 39 | * @param packet ReceivePacket 40 | * @param progress Receive Progress 41 | */ 42 | void onReceiveProgress(ReceivePacket packet, float progress); 43 | 44 | /** 45 | * On Receiver end receive packet call this 46 | * 47 | * @param packet ReceivePacket 48 | */ 49 | void onReceiveEnd(ReceivePacket packet); 50 | } 51 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 04/16/2015 5 | * Changed 04/19/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.listener; 21 | 22 | /** 23 | * Send notify listener 24 | */ 25 | public interface SendListener { 26 | /** 27 | * On sender send the packet call this 28 | * On start progress == 0 29 | * On end progress ==1 30 | * 31 | * @param progress Send progress (0~1) 32 | */ 33 | void onSendProgress(float progress); 34 | } 35 | -------------------------------------------------------------------------------- /Android/Blink/library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | library 3 | 4 | -------------------------------------------------------------------------------- /Android/Blink/old/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Android/Blink/old/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 22 5 | buildToolsVersion "22.0.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 22 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | task clearJar(type: Delete) { 22 | delete '../../Release/blink_android.jar' 23 | } 24 | 25 | task makeJar(type: Copy) { 26 | from('build/intermediates/bundles/release/') 27 | into('../../Release/') 28 | include('classes.jar') 29 | rename('classes.jar', 'blink_android.jar') 30 | } 31 | makeJar.dependsOn(clearJar, build) -------------------------------------------------------------------------------- /Android/Blink/old/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\ToolKits\Android\SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /Android/Blink/old/src/androidTest/java/net/qiujuer/blink/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package net.qiujuer.blink; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /Android/Blink/old/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/box/ByteReceivePacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.box; 21 | 22 | import net.qiujuer.blink.core.ReceivePacket; 23 | 24 | import java.io.ByteArrayOutputStream; 25 | 26 | /** 27 | * Bytes receive class 28 | */ 29 | public class ByteReceivePacket extends ReceivePacket { 30 | 31 | public ByteReceivePacket(long id, int type, int len) { 32 | super(id, type, len); 33 | } 34 | 35 | 36 | @Override 37 | protected void adjustStream() { 38 | mOutStream = new ByteArrayOutputStream(getLength()); 39 | } 40 | 41 | @Override 42 | protected void adjustPacket() { 43 | if (mOutStream != null) { 44 | mEntity = ((ByteArrayOutputStream) mOutStream).toByteArray(); 45 | mOutStream = null; 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/box/ByteSendPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.box; 21 | 22 | import net.qiujuer.blink.core.SendPacket; 23 | import net.qiujuer.blink.listener.SendListener; 24 | 25 | import java.io.ByteArrayInputStream; 26 | import java.io.InputStream; 27 | 28 | /** 29 | * Bytes send class 30 | */ 31 | public class ByteSendPacket extends SendPacket { 32 | 33 | public ByteSendPacket(byte[] entity) { 34 | this(entity, null); 35 | } 36 | 37 | public ByteSendPacket(byte[] entity, SendListener listener) { 38 | super(Type.BYTES, entity, listener); 39 | mLength = mEntity.length; 40 | } 41 | 42 | @Override 43 | public InputStream getInputStream() { 44 | return new ByteArrayInputStream(mEntity); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/box/FileReceivePacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.box; 21 | 22 | import net.qiujuer.blink.core.ReceivePacket; 23 | 24 | import java.io.File; 25 | import java.io.FileNotFoundException; 26 | import java.io.FileOutputStream; 27 | 28 | /** 29 | * File receive class 30 | */ 31 | public class FileReceivePacket extends ReceivePacket { 32 | public FileReceivePacket(long id, int type, int len, File file) { 33 | super(id, type, len); 34 | mEntity = file; 35 | } 36 | 37 | @Override 38 | protected void adjustStream() { 39 | try { 40 | mOutStream = new FileOutputStream(mEntity); 41 | } catch (FileNotFoundException e) { 42 | e.printStackTrace(); 43 | } 44 | } 45 | 46 | @Override 47 | protected void adjustPacket() { 48 | mOutStream = null; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/box/FileSendPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.box; 21 | 22 | import net.qiujuer.blink.core.SendPacket; 23 | import net.qiujuer.blink.listener.SendListener; 24 | 25 | import java.io.File; 26 | import java.io.FileInputStream; 27 | import java.io.FileNotFoundException; 28 | import java.io.InputStream; 29 | 30 | /** 31 | * File send class 32 | */ 33 | public class FileSendPacket extends SendPacket { 34 | 35 | public FileSendPacket(File file) { 36 | this(file, null); 37 | } 38 | 39 | public FileSendPacket(File entity, SendListener listener) { 40 | super(Type.FILE, entity, listener); 41 | } 42 | 43 | @Override 44 | public InputStream getInputStream() { 45 | try { 46 | return new FileInputStream(mEntity); 47 | } catch (FileNotFoundException e) { 48 | return null; 49 | } 50 | } 51 | 52 | @Override 53 | public int getLength() { 54 | return (int) mEntity.length(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/box/StringReceivePacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.box; 21 | 22 | import net.qiujuer.blink.core.ReceivePacket; 23 | 24 | import java.io.ByteArrayOutputStream; 25 | import java.io.UnsupportedEncodingException; 26 | 27 | /** 28 | * String receive class 29 | */ 30 | public class StringReceivePacket extends ReceivePacket { 31 | public StringReceivePacket(long id, int type, int len) { 32 | super(id, type, len); 33 | } 34 | 35 | @Override 36 | protected void adjustStream() { 37 | mOutStream = new ByteArrayOutputStream(getLength()); 38 | } 39 | 40 | @Override 41 | protected void adjustPacket() { 42 | if (mOutStream != null) { 43 | byte[] bytes = ((ByteArrayOutputStream) mOutStream).toByteArray(); 44 | try { 45 | mEntity = new String(bytes, 0, bytes.length, "UTF-8"); 46 | } catch (UnsupportedEncodingException e) { 47 | e.printStackTrace(); 48 | } 49 | mOutStream = null; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/box/StringSendPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.box; 21 | 22 | import net.qiujuer.blink.listener.SendListener; 23 | 24 | import java.io.UnsupportedEncodingException; 25 | 26 | /** 27 | * String send class 28 | */ 29 | public class StringSendPacket extends ByteSendPacket { 30 | 31 | public StringSendPacket(String entity) throws UnsupportedEncodingException { 32 | this(entity, null); 33 | } 34 | 35 | public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException { 36 | super(entity.getBytes("UTF-8"), listener); 37 | mType = Type.STRING; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/core/BlinkPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | /** 23 | * Blink Data Packet 24 | */ 25 | public abstract class BlinkPacket extends EntityNode implements HeadNode { 26 | protected int mType; 27 | protected int mLength; 28 | private boolean mSucceed; 29 | 30 | public BlinkPacket(int type) { 31 | mType = type; 32 | } 33 | 34 | @Override 35 | public int getType() { 36 | return mType; 37 | } 38 | 39 | @Override 40 | public int getLength() { 41 | return mLength; 42 | } 43 | 44 | public void setSuccess(boolean isSuccess) { 45 | this.mSucceed = isSuccess; 46 | } 47 | 48 | public boolean isSucceed() { 49 | return mSucceed; 50 | } 51 | 52 | /** 53 | * Blink Entity Type 54 | */ 55 | public interface Type { 56 | int STRING = 0; 57 | int BYTES = 1; 58 | int FILE = 2; 59 | } 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/core/EntityNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | /** 23 | * Blink Entity Node 24 | */ 25 | public abstract class EntityNode { 26 | protected T mEntity; 27 | 28 | public T getEntity() { 29 | return mEntity; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/core/HeadNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | /** 23 | * Bink Head Node 24 | */ 25 | public interface HeadNode { 26 | int getType(); 27 | 28 | int getLength(); 29 | } -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/core/ReceiveDelivery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | import net.qiujuer.blink.listener.ReceiveListener; 23 | 24 | /** 25 | * Receiver delivery interface 26 | */ 27 | public abstract class ReceiveDelivery { 28 | private final ReceiveListener mListener; 29 | 30 | public ReceiveDelivery(ReceiveListener listener) { 31 | mListener = listener; 32 | } 33 | 34 | 35 | /** 36 | * Get ReceiveListener 37 | * 38 | * @return ReceiveListener 39 | */ 40 | protected ReceiveListener getReceiveListener() { 41 | return mListener; 42 | } 43 | 44 | /** 45 | * Parses a start response from the receiver. 46 | */ 47 | public abstract void postReceiveStart(ReceivePacket entity); 48 | 49 | /** 50 | * Parses a end response from the receiver. 51 | */ 52 | public abstract void postReceiveEnd(ReceivePacket entity, boolean isSuccess); 53 | 54 | /** 55 | * Parses a progress response from the receiver. 56 | */ 57 | public abstract void postReceiveProgress(ReceivePacket entity, int total, int cur); 58 | } 59 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/core/ReceivePacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | import java.io.OutputStream; 23 | 24 | /** 25 | * Receive Entity 26 | */ 27 | public abstract class ReceivePacket extends BlinkPacket { 28 | private final long mId; 29 | protected OutputStream mOutStream; 30 | private String mHashCode; 31 | 32 | public ReceivePacket(long id, int type, int len) { 33 | super(type); 34 | mId = id; 35 | mLength = len; 36 | } 37 | 38 | public long getId() { 39 | return mId; 40 | } 41 | 42 | public OutputStream getOutputStream() { 43 | return mOutStream; 44 | } 45 | 46 | public void setHashCode(String hashCode) { 47 | mHashCode = hashCode; 48 | } 49 | 50 | public String getHashCode() { 51 | return mHashCode; 52 | } 53 | 54 | protected abstract void adjustStream(); 55 | 56 | protected abstract void adjustPacket(); 57 | } 58 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/core/ReceiveParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | import net.qiujuer.blink.box.ByteReceivePacket; 23 | import net.qiujuer.blink.box.FileReceivePacket; 24 | import net.qiujuer.blink.box.StringReceivePacket; 25 | 26 | import java.io.File; 27 | 28 | /** 29 | * Blink receive entity parse 30 | */ 31 | public class ReceiveParser { 32 | private long mId = 0; 33 | protected Resource mResource; 34 | 35 | public ReceiveParser(Resource resource) { 36 | mResource = resource; 37 | } 38 | 39 | public ReceivePacket parseReceive(int type, int len) { 40 | final long id = ++mId; 41 | ReceivePacket entity = null; 42 | switch (type) { 43 | case BlinkPacket.Type.STRING: 44 | entity = new StringReceivePacket(id, type, len); 45 | break; 46 | case BlinkPacket.Type.BYTES: 47 | entity = new ByteReceivePacket(id, type, len); 48 | break; 49 | case BlinkPacket.Type.FILE: 50 | File file = mResource.create(id); 51 | if (file != null) 52 | entity = new FileReceivePacket(id, type, len, file); 53 | break; 54 | } 55 | return entity; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/core/Receiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | /** 23 | * Receive entity interface 24 | */ 25 | public interface Receiver { 26 | 27 | /** 28 | * Receive the entity's information 29 | * 30 | * @return ReceiveEntity 31 | */ 32 | ReceivePacket receiveHead(); 33 | 34 | 35 | /** 36 | * Receive entity 37 | * 38 | * @param entity ReceiveEntity 39 | * @param delivery ReceiveDelivery 40 | * @return ReceiveEntity 41 | */ 42 | boolean receiveEntity(ReceivePacket entity, ReceiveDelivery delivery); 43 | 44 | /** 45 | * Destroy the receive IO stream 46 | */ 47 | void destroyReceiveIO(); 48 | } 49 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/core/Resource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | import java.io.File; 23 | 24 | /** 25 | * Blink files Resource 26 | */ 27 | public interface Resource { 28 | /** 29 | * Create a file from resource. 30 | * 31 | * @return New file 32 | */ 33 | File create(long id); 34 | 35 | /** 36 | * Change a file name 37 | * 38 | * @param file File 39 | * @param newName New name 40 | * @return Status 41 | */ 42 | boolean rename(File file, String newName); 43 | 44 | 45 | /** 46 | * Cut a file to new path 47 | * 48 | * @param oldFile File 49 | * @param newPath New path 50 | * @return New File 51 | */ 52 | File cut(File oldFile, String newPath); 53 | 54 | /** 55 | * Cut a file to new path 56 | * 57 | * @param oldFile Old file 58 | * @param newFile New file 59 | * @return New file 60 | */ 61 | File cut(File oldFile, File newFile); 62 | 63 | 64 | /** 65 | * Removes a file from the resource. 66 | * 67 | * @param name File name 68 | */ 69 | void remove(String name); 70 | 71 | /** 72 | * Removes a file from the resource. 73 | * 74 | * @param file File 75 | */ 76 | void remove(File file); 77 | 78 | /** 79 | * Empties the resource by oneself 80 | */ 81 | void clear(); 82 | 83 | /** 84 | * Empties the resource by the path 85 | */ 86 | void clearAll(); 87 | 88 | /** 89 | * Get the Mark 90 | * 91 | * @return T 92 | */ 93 | T getMark(); 94 | } 95 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/core/SendDelivery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | /** 23 | * Send delivery interface 24 | */ 25 | public interface SendDelivery { 26 | /** 27 | * Parses a start response from the sender. 28 | */ 29 | void postSendStart(SendPacket entity); 30 | 31 | /** 32 | * Parses a end response from the sender. 33 | */ 34 | void postSendEnd(SendPacket entity, boolean isSuccess); 35 | 36 | /** 37 | * Parses a progress response from the sender. 38 | */ 39 | void postSendProgress(SendPacket entity, int total, int cur); 40 | } 41 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/core/Sender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.core; 21 | 22 | /** 23 | * Send entity interface 24 | */ 25 | public interface Sender { 26 | 27 | /** 28 | * Send the entity's information 29 | * 30 | * @param entity SendEntity 31 | * @return Status 32 | */ 33 | boolean sendHead(SendPacket entity); 34 | 35 | /** 36 | * Send entity 37 | * 38 | * @param entity SendEntity 39 | * @return Status 40 | */ 41 | boolean sendEntity(SendPacket entity, SendDelivery delivery); 42 | 43 | /** 44 | * Destroy the sender IO stream 45 | */ 46 | void destroySendIO(); 47 | } 48 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/listener/ReceiveListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.listener; 21 | 22 | import net.qiujuer.blink.core.ReceivePacket; 23 | 24 | /** 25 | * Receive notify listener 26 | */ 27 | public interface ReceiveListener { 28 | void onReceiveStart(int type, long id); 29 | 30 | void onReceiveProgress(int type, long id, int total, int cur); 31 | 32 | void onReceiveEnd(ReceivePacket entity); 33 | } 34 | -------------------------------------------------------------------------------- /Android/Blink/old/src/main/java/net/qiujuer/blink/listener/SendListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Qiujuer 3 | * WebSite http://www.qiujuer.net 4 | * Created 03/31/2015 5 | * Changed 04/02/2015 6 | * Version 1.0.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | package net.qiujuer.blink.listener; 21 | 22 | /** 23 | * Send notify listener 24 | */ 25 | public interface SendListener { 26 | void onSendStart(); 27 | 28 | void onSendProgress(int total, int cur); 29 | 30 | void onSendEnd(boolean isSuccess); 31 | } -------------------------------------------------------------------------------- /Android/Blink/old/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Blink Library 3 | 4 | -------------------------------------------------------------------------------- /Android/Blink/sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Android/Blink/sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 22 5 | buildToolsVersion "22.0.1" 6 | 7 | defaultConfig { 8 | applicationId "net.qiujuer.sample.blink" 9 | minSdkVersion 15 10 | targetSdkVersion 22 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | compile 'com.android.support:appcompat-v7:22.2.1' 25 | compile project(':library') 26 | } 27 | -------------------------------------------------------------------------------- /Android/Blink/sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\ToolKits\Android\SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /Android/Blink/sample/src/androidTest/java/net/qiujuer/sample/blink/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package net.qiujuer.sample.blink; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /Android/Blink/sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Android/Blink/sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 16 | 17 | 23 | 24 | 28 | 29 | 35 | 36 |