├── app
├── .gitignore
├── src.zip
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_action_camera.png
│ │ │ │ └── ic_action_attachment.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── ic_action_camera.png
│ │ │ │ └── ic_action_attachment.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── ic_action_camera.png
│ │ │ │ └── ic_action_attachment.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── ic_action_camera.png
│ │ │ │ └── ic_action_attachment.png
│ │ │ ├── values
│ │ │ │ ├── styles.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── strings.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── menu
│ │ │ │ ├── menu_socket.xml
│ │ │ │ └── socket_activity_actions.xml
│ │ │ └── layout
│ │ │ │ ├── activity_socket.xml
│ │ │ │ ├── layout_message.xml
│ │ │ │ └── fragment_chat.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── kriyatma
│ │ │ └── nodesocket
│ │ │ ├── Message.java
│ │ │ ├── MessageAdapter.java
│ │ │ ├── SocketActivity.java
│ │ │ └── ChatFragment.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── kriyatma
│ │ └── nodesocket
│ │ └── ApplicationTest.java
├── libs
│ └── socket.io-client.java-master
│ │ ├── .travis.yml
│ │ ├── src
│ │ ├── test
│ │ │ ├── resources
│ │ │ │ ├── keystore.jks
│ │ │ │ ├── package.json
│ │ │ │ ├── logging.properties
│ │ │ │ ├── key.pem
│ │ │ │ ├── cert.pem
│ │ │ │ └── server.js
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── github
│ │ │ │ └── nkzawa
│ │ │ │ ├── socketio
│ │ │ │ ├── client
│ │ │ │ │ ├── ServerConnectionNamespaceTest.java
│ │ │ │ │ ├── executions
│ │ │ │ │ │ ├── Connection.java
│ │ │ │ │ │ ├── ImmediateClose.java
│ │ │ │ │ │ └── ConnectionFailure.java
│ │ │ │ │ ├── ExecutionTest.java
│ │ │ │ │ ├── UrlTest.java
│ │ │ │ │ ├── SocketTest.java
│ │ │ │ │ ├── Connection.java
│ │ │ │ │ ├── SSLConnectionTest.java
│ │ │ │ │ ├── ServerConnectionTest.java
│ │ │ │ │ └── ConnectionTest.java
│ │ │ │ └── parser
│ │ │ │ │ ├── ParserTest.java
│ │ │ │ │ ├── ByteArrayTest.java
│ │ │ │ │ └── Helpers.java
│ │ │ │ ├── backo
│ │ │ │ └── BackoffTest.java
│ │ │ │ ├── util
│ │ │ │ └── Optional.java
│ │ │ │ └── hasbinary
│ │ │ │ └── HasBinaryTest.java
│ │ └── main
│ │ │ └── java
│ │ │ └── com
│ │ │ └── github
│ │ │ └── nkzawa
│ │ │ ├── socketio
│ │ │ ├── client
│ │ │ │ ├── Ack.java
│ │ │ │ ├── SocketIOException.java
│ │ │ │ ├── On.java
│ │ │ │ ├── Url.java
│ │ │ │ ├── IO.java
│ │ │ │ ├── Socket.java
│ │ │ │ └── Manager.java
│ │ │ └── parser
│ │ │ │ ├── Packet.java
│ │ │ │ ├── Binary.java
│ │ │ │ └── Parser.java
│ │ │ ├── backo
│ │ │ └── Backoff.java
│ │ │ └── hasbinary
│ │ │ └── HasBinary.java
│ │ ├── .gitignore
│ │ ├── History.md
│ │ ├── LICENSE
│ │ ├── README.md
│ │ └── pom.xml
├── proguard-rules.pro
├── build.gradle
└── app.iml
├── settings.gradle
├── .gradle
└── 2.2.1
│ └── taskArtifacts
│ ├── cache.properties
│ ├── fileHashes.bin
│ ├── fileSnapshots.bin
│ ├── taskArtifacts.bin
│ ├── outputFileStates.bin
│ └── cache.properties.lock
├── README.md
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── local.properties
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/.gradle/2.2.1/taskArtifacts/cache.properties:
--------------------------------------------------------------------------------
1 | #Sun May 10 11:04:01 IST 2015
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # android-socket.io-client-demo
2 | client side java code for android socket.o-demo
3 |
--------------------------------------------------------------------------------
/app/src.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/app/src.zip
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gradle/2.2.1/taskArtifacts/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/.gradle/2.2.1/taskArtifacts/fileHashes.bin
--------------------------------------------------------------------------------
/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin
--------------------------------------------------------------------------------
/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gradle/2.2.1/taskArtifacts/outputFileStates.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/.gradle/2.2.1/taskArtifacts/outputFileStates.bin
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | install: mvn install -DskipTests=true -Dgpg.skip=true
3 | jdk:
4 | - openjdk7
5 | - oraclejdk8
6 |
--------------------------------------------------------------------------------
/.gradle/2.2.1/taskArtifacts/cache.properties.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/.gradle/2.2.1/taskArtifacts/cache.properties.lock
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/app/src/main/res/drawable-hdpi/ic_action_camera.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/app/src/main/res/drawable-mdpi/ic_action_camera.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/app/src/main/res/drawable-xhdpi/ic_action_camera.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/app/src/main/res/drawable-xxhdpi/ic_action_camera.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_attachment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/app/src/main/res/drawable-hdpi/ic_action_attachment.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_attachment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/app/src/main/res/drawable-mdpi/ic_action_attachment.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_attachment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/app/src/main/res/drawable-xhdpi/ic_action_attachment.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_attachment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/app/src/main/res/drawable-xxhdpi/ic_action_attachment.png
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/resources/keystore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sreejesh79/android-socket.io-client-demo/HEAD/app/libs/socket.io-client.java-master/src/test/resources/keystore.jks
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/resources/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "socket.io-client.java-test",
3 | "version": "0.0.0",
4 | "private": true,
5 | "dependencies": {
6 | "socket.io": "1.3.2"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 |
3 | # Package Files #
4 | *.jar
5 | *.war
6 | *.ear
7 |
8 | # Intellij project files
9 | *.iml
10 | *.ipr
11 | *.iws
12 | .idea/
13 |
14 | .DS_Store
15 | target/
16 | node_modules/
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/main/java/com/github/nkzawa/socketio/client/Ack.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.client;
2 |
3 | /**
4 | * Acknowledgement.
5 | */
6 | public interface Ack {
7 |
8 | public void call(Object... args);
9 |
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 8dp
6 |
7 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/resources/logging.properties:
--------------------------------------------------------------------------------
1 | handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
2 | .level = ALL
3 |
4 | java.util.logging.ConsoleHandler.level = INFO
5 |
6 | java.util.logging.FileHandler.level = ALL
7 | java.util.logging.FileHandler.pattern = ./target/test.log
8 | java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_socket.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/socketio/client/ServerConnectionNamespaceTest.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.client;
2 |
3 | import org.junit.runner.RunWith;
4 | import org.junit.runners.JUnit4;
5 |
6 | @RunWith(JUnit4.class)
7 | public class ServerConnectionNamespaceTest extends ServerConnectionTest {
8 |
9 | protected String nsp() {
10 | return "/foo";
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/kriyatma/nodesocket/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.kriyatma.nodesocket;
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 | }
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file should *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | sdk.dir=/Users/sreejeshpillai/Library/Android/sdk
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/main/java/com/github/nkzawa/socketio/parser/Packet.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.parser;
2 |
3 |
4 | public class Packet {
5 |
6 | public int type = -1;
7 | public int id = -1;
8 | public String nsp;
9 | public T data;
10 | public int attachments;
11 |
12 | public Packet() {}
13 |
14 | public Packet(int type) {
15 | this.type = type;
16 | }
17 |
18 | public Packet(int type, T data) {
19 | this.type = type;
20 | this.data = data;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/resources/key.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIIBOwIBAAJBALqx14U+WqTk9qn3CgXHVE7TmAuJ3Dgw1wv5lFLHL+w14Tg+FP9E
3 | sVwS+deIdz3bBPxgHln5YIyT+NFDSrX0808CAwEAAQJAIdwLSIEsk2drTRwe1zl1
4 | ku5RTxZruE0zU1qqifDSQjab1StAK1tapxBVRlRlyLCfD704UClsU8sjGtq0Nh6n
5 | kQIhAO2YJM1g0w9bWYet3zC2UdEASPzaQ7llpZmc51NRBx2NAiEAyShICAaclEuy
6 | wwuD4hibV+b6I8CLYoyPBo32EaceN0sCIQCUed6NxfM/houlgV+Xtmfcnzv9X3yx
7 | EDdzjpz08Q7sRQIgZFv1fBOYYSBXQppnJRFzx2pUmCvDHtrTrMh84RfIqnsCIQCf
8 | JjNXXxOaHn1PNZpi6EHReiFQmy1Swt+AxpTsKixsfA==
9 | -----END RSA PRIVATE KEY-----
10 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/main/java/com/github/nkzawa/socketio/client/SocketIOException.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.client;
2 |
3 | public class SocketIOException extends Exception {
4 |
5 | public SocketIOException() {
6 | super();
7 | }
8 |
9 | public SocketIOException(String message) {
10 | super(message);
11 | }
12 |
13 | public SocketIOException(String message, Throwable cause) {
14 | super(message, cause);
15 | }
16 |
17 | public SocketIOException(Throwable cause) {
18 | super(cause);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_socket.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | NodeSocket
3 |
4 | Hello world!
5 | Settings
6 | SEND
7 | Send
8 | Message
9 | ATTACH
10 | CAPTURE IMAGE
11 |
12 |
13 | Hello blank fragment
14 |
15 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/main/java/com/github/nkzawa/socketio/client/On.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.client;
2 |
3 | import com.github.nkzawa.emitter.Emitter;
4 |
5 | public class On {
6 |
7 | private On() {}
8 |
9 | public static Handle on(final Emitter obj, final String ev, final Emitter.Listener fn) {
10 | obj.on(ev, fn);
11 | return new Handle() {
12 | @Override
13 | public void destroy() {
14 | obj.off(ev, fn);
15 | }
16 | };
17 | }
18 |
19 | public static interface Handle {
20 |
21 | public void destroy();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/resources/cert.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIBfDCCASYCCQDTnGd/oOyF1DANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
3 | VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
4 | cyBQdHkgTHRkMB4XDTE0MDcwNzEzMTUzN1oXDTQxMTEyMTEzMTUzN1owRTELMAkG
5 | A1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0
6 | IFdpZGdpdHMgUHR5IEx0ZDBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC6sdeFPlqk
7 | 5Pap9woFx1RO05gLidw4MNcL+ZRSxy/sNeE4PhT/RLFcEvnXiHc92wT8YB5Z+WCM
8 | k/jRQ0q19PNPAgMBAAEwDQYJKoZIhvcNAQEFBQADQQCnmm1N/yZiMBZw2JDfbsx3
9 | ecc0BGQ2BwWQuGHzP07TMi1AuOyNZSczl907OphYb9iRC8shZ4O+oXjQAuGTQ1Hp
10 | -----END CERTIFICATE-----
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/socket_activity_actions.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/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 /Users/sreejeshpillai/Library/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 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "22.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.kriyatma.nodesocket"
9 | minSdkVersion 14
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(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:22.0.0'
25 | compile "com.android.support:recyclerview-v7:21.0.0"
26 | compile "com.github.nkzawa:socket.io-client:0.5.0"
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
22 |
23 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/socketio/client/executions/Connection.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.client.executions;
2 |
3 | import com.github.nkzawa.emitter.Emitter;
4 | import com.github.nkzawa.socketio.client.IO;
5 | import com.github.nkzawa.socketio.client.Socket;
6 |
7 | import java.net.URISyntaxException;
8 |
9 | public class Connection {
10 |
11 | public static void main(String[] args) throws URISyntaxException {
12 | IO.Options options = new IO.Options();
13 | options.forceNew = true;
14 | final Socket socket = IO.socket("http://localhost:" + System.getenv("PORT"), options);
15 | socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
16 | @Override
17 | public void call(Object... args) {
18 | System.out.println("connect");
19 | socket.close();
20 | }
21 | });
22 | socket.open();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/backo/BackoffTest.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.backo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.assertTrue;
6 |
7 | public class BackoffTest {
8 |
9 | @Test
10 | public void durationShouldIncreaseTheBackoff() {
11 | Backoff b = new Backoff();
12 |
13 | assertTrue(100 == b.duration());
14 | assertTrue(200 == b.duration());
15 | assertTrue(400 == b.duration());
16 | assertTrue(800 == b.duration());
17 |
18 | b.reset();
19 | assertTrue(100 == b.duration());
20 | assertTrue(200 == b.duration());
21 | }
22 |
23 | @Test
24 | public void durationOverflow() {
25 | Backoff b = new Backoff();
26 | b.setMin(100);
27 | b.setMax(10000);
28 | b.setJitter(1.0);
29 |
30 | for (int i = 0; i < 100; i++) {
31 | long duration = b.duration();
32 | assertTrue(100 <= duration && duration <= 10000);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/History.md:
--------------------------------------------------------------------------------
1 | 0.5.0 / 2015-05-02
2 | ==================
3 |
4 | * bump `engine.io-client`.
5 | * enhance parser decode [niqo01]
6 | * add a wrong event name check
7 | * add setDefaultHostnameVerifier method
8 |
9 | 0.4.2 / 2015-03-07
10 | ==================
11 |
12 | * fix error on reconnection attemps
13 |
14 | 0.4.1 / 2015-02-08
15 | ==================
16 |
17 | * bump `engine.io-client`.
18 | * fix program doesn't terminate when closing socket before eatablishing connection.
19 |
20 | 0.4.0 / 2015-01-26
21 | ==================
22 |
23 | * compatible with socket.io 1.3.2
24 | * bump `engine.io-client`.
25 | * added `Socket#id()` pointing to session id
26 | * add exponential backoff with randomization
27 | * reset reconnection attempts state after a successul connection
28 | * fix binary arguments in emit with ack [AlfioEmanueleFresta]
29 |
30 | 0.3.0 / 2014-11-04
31 | ==================
32 |
33 | * compatible with socket.io 1.2.0
34 | * bump `engine.io-client`.
35 | * fix reconnection after reconnecting manually
36 | * enable to stop reconnecting
37 | * enable to reconnect manually
38 | * add `Socket#connected()`
39 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/socketio/client/executions/ImmediateClose.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.client.executions;
2 |
3 | import com.github.nkzawa.emitter.Emitter;
4 | import com.github.nkzawa.socketio.client.IO;
5 | import com.github.nkzawa.socketio.client.Socket;
6 |
7 | import java.net.URISyntaxException;
8 |
9 | public class ImmediateClose {
10 |
11 | public static void main(String[] args) throws URISyntaxException {
12 | IO.Options options = new IO.Options();
13 | options.forceNew = true;
14 | final Socket socket = IO.socket("http://localhost:" + System.getenv("PORT"), options);
15 | socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
16 | @Override
17 | public void call(Object... args) {
18 | System.out.println("connect");
19 | }
20 | }).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
21 | @Override
22 | public void call(Object... args) {
23 | System.out.println("disconnect");
24 | }
25 | });
26 | socket.connect();
27 | socket.disconnect();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/util/Optional.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.util;
2 |
3 | import java.util.NoSuchElementException;
4 |
5 | public class Optional {
6 |
7 | static final Optional EMPTY = Optional.ofNullable(null);
8 |
9 | private T value;
10 |
11 | public static Optional of(T value) {
12 | if (value == null) {
13 | throw new NullPointerException();
14 | }
15 | return new Optional(value);
16 | }
17 |
18 | public static Optional ofNullable(T value) {
19 | return new Optional(value);
20 | }
21 |
22 | public static Optional empty() {
23 | return EMPTY;
24 | }
25 |
26 | private Optional(T value) {
27 | this.value = value;
28 | }
29 |
30 | public boolean isPresent() {
31 | return this.value != null;
32 | }
33 |
34 | public T get() {
35 | if (this.value == null) {
36 | throw new NoSuchElementException();
37 | }
38 | return this.value;
39 | }
40 |
41 | public T orElse(T other) {
42 | return this.value != null ? this.value : other;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/socketio/client/executions/ConnectionFailure.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.client.executions;
2 |
3 | import com.github.nkzawa.emitter.Emitter;
4 | import com.github.nkzawa.socketio.client.IO;
5 | import com.github.nkzawa.socketio.client.Socket;
6 |
7 | import java.net.URISyntaxException;
8 |
9 | public class ConnectionFailure {
10 |
11 | public static void main(String[] args) throws URISyntaxException {
12 | int port = Integer.parseInt(System.getenv("PORT"));
13 | port++;
14 | IO.Options options = new IO.Options();
15 | options.forceNew = true;
16 | options.reconnection = false;
17 | final Socket socket = IO.socket("http://localhost:" + port, options);
18 | socket.on(Socket.EVENT_CONNECT_TIMEOUT, new Emitter.Listener() {
19 | @Override
20 | public void call(Object... args) {
21 | System.out.println("connect timeout");
22 | }
23 | }).on(Socket.EVENT_CONNECT_ERROR, new Emitter.Listener() {
24 | @Override
25 | public void call(Object... args) {
26 | System.out.println("connect error");
27 | }
28 | }).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
29 | @Override
30 | public void call(Object... args) {
31 | System.out.println("disconnect");
32 | }
33 | });
34 | socket.open();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kriyatma/nodesocket/Message.java:
--------------------------------------------------------------------------------
1 | package com.kriyatma.nodesocket;
2 |
3 | import android.graphics.Bitmap;
4 |
5 | /**
6 | * Created by sreejeshpillai on 10/05/15.
7 | */
8 | public class Message {
9 |
10 | public static final int TYPE_MESSAGE = 0;
11 | public static final int TYPE_LOG = 1;
12 | public static final int TYPE_ACTION = 2;
13 |
14 | private int mType;
15 | private String mMessage;
16 | private Bitmap mImage;
17 |
18 | private Message() {}
19 |
20 | public int getType() {
21 | return mType;
22 | };
23 |
24 | public String getMessage() {
25 | return mMessage;
26 | };
27 |
28 | public Bitmap getImage() {
29 | return mImage;
30 | };
31 |
32 |
33 | public static class Builder {
34 | private final int mType;
35 | private Bitmap mImage;
36 | private String mMessage;
37 |
38 | public Builder(int type) {
39 | mType = type;
40 | }
41 |
42 | public Builder image(Bitmap image) {
43 | mImage = image;
44 | return this;
45 | }
46 |
47 | public Builder message(String message) {
48 | mMessage = message;
49 | return this;
50 | }
51 |
52 | public Message build() {
53 | Message message = new Message();
54 | message.mType = mType;
55 | message.mImage = mImage;
56 | message.mMessage = mMessage;
57 | return message;
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/main/java/com/github/nkzawa/backo/Backoff.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.backo;
2 |
3 | public class Backoff {
4 |
5 | private long ms = 100;
6 | private long max = 10000;
7 | private int factor = 2;
8 | private double jitter = 0.0;
9 | private int attempts = 0;
10 |
11 | public Backoff() {}
12 |
13 | public long duration() {
14 | long ms = this.ms * (long) Math.pow(this.factor, this.attempts++);
15 | if (jitter != 0.0) {
16 | double rand = Math.random();
17 | int deviation = (int) Math.floor(rand * this.jitter * ms);
18 | ms = (((int) Math.floor(rand * 10)) & 1) == 0 ? ms - deviation : ms + deviation;
19 | }
20 | if (ms < this.ms) {
21 | // overflow happened
22 | ms = Long.MAX_VALUE;
23 | }
24 | return Math.min(ms, this.max);
25 | }
26 |
27 | public void reset() {
28 | this.attempts = 0;
29 | }
30 |
31 | public Backoff setMin(long min) {
32 | this.ms = min;
33 | return this;
34 | }
35 |
36 | public Backoff setMax(long max) {
37 | this.max = max;
38 | return this;
39 | }
40 |
41 | public Backoff setFactor(int factor) {
42 | this.factor = factor;
43 | return this;
44 | }
45 |
46 | public Backoff setJitter(double jitter) {
47 | this.jitter = jitter;
48 | return this;
49 | }
50 |
51 | public int getAttempts() {
52 | return this.attempts;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/main/java/com/github/nkzawa/hasbinary/HasBinary.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.hasbinary;
2 |
3 | import org.json.JSONArray;
4 | import org.json.JSONException;
5 | import org.json.JSONObject;
6 |
7 | import java.util.Iterator;
8 |
9 | public class HasBinary {
10 |
11 | private HasBinary() {}
12 |
13 | public static boolean hasBinary(Object data) {
14 | return _hasBinary(data);
15 | }
16 |
17 | private static boolean _hasBinary(Object obj) {
18 | if (obj == null) return false;
19 |
20 | if (obj instanceof byte[]) {
21 | return true;
22 | }
23 |
24 | if (obj instanceof JSONArray) {
25 | JSONArray _obj = (JSONArray)obj;
26 | int length = _obj.length();
27 | for (int i = 0; i < length; i++) {
28 | Object v;
29 | try {
30 | v = _obj.isNull(i) ? null : _obj.get(i);
31 | } catch (JSONException e) {
32 | return false;
33 | }
34 | if (_hasBinary(v)) {
35 | return true;
36 | }
37 | }
38 | } else if (obj instanceof JSONObject) {
39 | JSONObject _obj = (JSONObject)obj;
40 | Iterator keys = _obj.keys();
41 | while (keys.hasNext()) {
42 | String key = (String)keys.next();
43 | Object v;
44 | try {
45 | v = _obj.get(key);
46 | } catch (JSONException e) {
47 | return false;
48 | }
49 | if (_hasBinary(v)) {
50 | return true;
51 | }
52 | }
53 | }
54 |
55 | return false;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/socketio/client/ExecutionTest.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.client;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.junit.runners.JUnit4;
6 |
7 | import java.io.BufferedReader;
8 | import java.io.IOException;
9 | import java.io.InputStreamReader;
10 | import java.util.logging.Logger;
11 |
12 | import static org.hamcrest.CoreMatchers.is;
13 | import static org.junit.Assert.assertThat;
14 |
15 | @RunWith(JUnit4.class)
16 | public class ExecutionTest extends Connection {
17 |
18 | private static final Logger logger = Logger.getLogger(ExecutionTest.class.getName());
19 |
20 | final static int TIMEOUT = 30 * 1000;
21 |
22 | @Test(timeout = TIMEOUT)
23 | public void execConnection() throws InterruptedException, IOException {
24 | exec("com.github.nkzawa.socketio.client.executions.Connection");
25 | }
26 |
27 | @Test(timeout = TIMEOUT)
28 | public void execConnectionFailure() throws InterruptedException, IOException {
29 | exec("com.github.nkzawa.socketio.client.executions.ConnectionFailure");
30 | }
31 |
32 | @Test(timeout = TIMEOUT)
33 | public void execImmediateClose() throws InterruptedException, IOException {
34 | exec("com.github.nkzawa.socketio.client.executions.ImmediateClose");
35 | }
36 |
37 | private void exec(String mainClass) throws InterruptedException, IOException {
38 | Process process = Runtime.getRuntime().exec(String.format("mvn --quiet exec:java" +
39 | " -Dexec.mainClass=%s -Dexec.classpathScope=test", mainClass), createEnv());
40 | BufferedReader input = new BufferedReader(
41 | new InputStreamReader(process.getInputStream()));
42 | String line;
43 | while ((line = input.readLine()) != null) {
44 | logger.fine("EXEC OUT: " + line);
45 | }
46 | process.waitFor();
47 | assertThat(process.exitValue(), is(0));
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_chat.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
18 |
25 |
26 |
38 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright (c) 2013 Naoyuki Kanezawa
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 |
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 |
10 |
11 | (The MIT License)
12 |
13 | Copyright (c) 2011 Guillermo Rauch
14 |
15 | Permission is hereby granted, free of charge, to any person obtaining
16 | a copy of this software and associated documentation files (the
17 | 'Software'), to deal in the Software without restriction, including
18 | without limitation the rights to use, copy, modify, merge, publish,
19 | distribute, sublicense, and/or sell copies of the Software, and to
20 | permit persons to whom the Software is furnished to do so, subject to
21 | the following conditions:
22 |
23 | The above copyright notice and this permission notice shall be
24 | included in all copies or substantial portions of the Software.
25 |
26 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
27 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
29 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
30 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
31 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
32 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/socketio/parser/ParserTest.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.parser;
2 |
3 | import org.json.JSONArray;
4 | import org.json.JSONException;
5 | import org.junit.Test;
6 | import org.junit.runner.RunWith;
7 | import org.junit.runners.JUnit4;
8 |
9 | @RunWith(JUnit4.class)
10 | public class ParserTest {
11 |
12 | private static Parser.Encoder encoder = new Parser.Encoder();
13 |
14 | @Test
15 | public void encodeConnection() {
16 | Packet packet = new Packet(Parser.CONNECT);
17 | packet.nsp = "/woot";
18 | Helpers.test(packet);
19 | }
20 |
21 | @Test
22 | public void encodeDisconnection() {
23 | Packet packet = new Packet(Parser.DISCONNECT);
24 | packet.nsp = "/woot";
25 | Helpers.test(packet);
26 | }
27 |
28 | @Test
29 | public void encodeEvent() throws JSONException {
30 | Packet packet1 = new Packet(Parser.EVENT);
31 | packet1.data = new JSONArray("[\"a\", 1, {}]");
32 | packet1.nsp = "/";
33 | Helpers.test(packet1);
34 |
35 | Packet packet2 = new Packet(Parser.EVENT);
36 | packet2.data = new JSONArray("[\"a\", 1, {}]");
37 | packet2.nsp = "/test";
38 | Helpers.test(packet2);
39 | }
40 |
41 | @Test
42 | public void encodeAck() throws JSONException {
43 | Packet packet = new Packet(Parser.ACK);
44 | packet.data = new JSONArray("[\"a\", 1, {}]");
45 | packet.id = 123;
46 | packet.nsp = "/";
47 | Helpers.test(packet);
48 | }
49 |
50 | @Test
51 | public void decodeInError() throws JSONException {
52 | // Random string
53 | Helpers.testDecodeError("asdf");
54 | // Unknown type
55 | Helpers.testDecodeError(Parser.types.length + "asdf");
56 | // Binary event with no `-`
57 | Helpers.testDecodeError(Parser.BINARY_EVENT + "asdf");
58 | // Binary ack with no `-`
59 | Helpers.testDecodeError(Parser.BINARY_ACK + "asdf");
60 | // Binary event with no attachment
61 | Helpers.testDecodeError(String.valueOf(Parser.BINARY_EVENT));
62 | // event non numeric id
63 | Helpers.testDecodeError(Parser.EVENT + "2sd");
64 | // event with invalid json data
65 | Helpers.testDecodeError(Parser.EVENT + "2[\"a\",1,{asdf}]");
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/main/java/com/github/nkzawa/socketio/client/Url.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.client;
2 |
3 | import java.net.MalformedURLException;
4 | import java.net.URI;
5 | import java.net.URISyntaxException;
6 | import java.net.URL;
7 | import java.util.regex.Pattern;
8 |
9 | public class Url {
10 |
11 | private static Pattern PATTERN_HTTP = Pattern.compile("^http|ws$");
12 | private static Pattern PATTERN_HTTPS = Pattern.compile("^(http|ws)s$");
13 |
14 | private Url() {}
15 |
16 | public static URL parse(String uri) throws URISyntaxException, MalformedURLException {
17 | return parse(new URI(uri));
18 | }
19 |
20 | public static URL parse(URI uri) throws MalformedURLException {
21 | String protocol = uri.getScheme();
22 | if (protocol == null || !protocol.matches("^https?|wss?$")) {
23 | protocol = "https";
24 | }
25 |
26 | int port = uri.getPort();
27 | if (port == -1) {
28 | if (PATTERN_HTTP.matcher(protocol).matches()) {
29 | port = 80;
30 | } else if (PATTERN_HTTPS.matcher(protocol).matches()) {
31 | port = 443;
32 | }
33 | }
34 |
35 | String path = uri.getRawPath();
36 | if (path == null || path.length() == 0) {
37 | path = "/";
38 | }
39 |
40 | String userInfo = uri.getRawUserInfo();
41 | String query = uri.getRawQuery();
42 | String fragment = uri.getRawFragment();
43 | return new URL(protocol + "://"
44 | + (userInfo != null ? userInfo + "@" : "")
45 | + uri.getHost()
46 | + (port != -1 ? ":" + port : "")
47 | + path
48 | + (query != null ? "?" + query : "")
49 | + (fragment != null ? "#" + fragment : ""));
50 | }
51 |
52 | public static String extractId(String url) throws MalformedURLException {
53 | return extractId(new URL(url));
54 | }
55 |
56 | public static String extractId(URL url) {
57 | String protocol = url.getProtocol();
58 | int port = url.getPort();
59 | if (port == -1) {
60 | if (PATTERN_HTTP.matcher(protocol).matches()) {
61 | port = 80;
62 | } else if (PATTERN_HTTPS.matcher(protocol).matches()) {
63 | port = 443;
64 | }
65 | }
66 | return protocol + "://" + url.getHost() + ":" + port;
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/socketio/client/UrlTest.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.client;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.junit.runners.JUnit4;
6 |
7 | import java.net.MalformedURLException;
8 | import java.net.URISyntaxException;
9 | import java.net.URL;
10 |
11 | import static org.hamcrest.CoreMatchers.is;
12 | import static org.hamcrest.CoreMatchers.not;
13 | import static org.junit.Assert.assertThat;
14 |
15 | @RunWith(JUnit4.class)
16 | public class UrlTest {
17 |
18 | @Test
19 | public void parse() throws MalformedURLException, URISyntaxException {
20 | assertThat(Url.parse("http://username:password@host:8080/directory/file?query#ref").toString(),
21 | is("http://username:password@host:8080/directory/file?query#ref"));
22 | }
23 |
24 | @Test
25 | public void parseRelativePath() throws MalformedURLException, URISyntaxException {
26 | URL url = Url.parse("https://woot.com/test");
27 | assertThat(url.getProtocol(), is("https"));
28 | assertThat(url.getHost(), is("woot.com"));
29 | assertThat(url.getPath(), is("/test"));
30 | }
31 |
32 | @Test
33 | public void parseNoProtocol() throws MalformedURLException, URISyntaxException {
34 | URL url = Url.parse("//localhost:3000");
35 | assertThat(url.getProtocol(), is("https"));
36 | assertThat(url.getHost(), is("localhost"));
37 | assertThat(url.getPort(), is(3000));
38 | }
39 |
40 | @Test
41 | public void parseNamespace() throws MalformedURLException, URISyntaxException {
42 | assertThat(Url.parse("http://woot.com/woot").getPath(), is("/woot"));
43 | assertThat(Url.parse("http://google.com").getPath(), is("/"));
44 | assertThat(Url.parse("http://google.com/").getPath(), is("/"));
45 | }
46 |
47 | @Test
48 | public void parseDefaultPort() throws MalformedURLException, URISyntaxException {
49 | assertThat(Url.parse("http://google.com/").toString(), is("http://google.com:80/"));
50 | assertThat(Url.parse("https://google.com/").toString(), is("https://google.com:443/"));
51 | }
52 |
53 | @Test
54 | public void extractId() throws MalformedURLException {
55 | String id1 = Url.extractId("http://google.com:80/");
56 | String id2 = Url.extractId("http://google.com/");
57 | String id3 = Url.extractId("https://google.com/");
58 | assertThat(id1, is(id2));
59 | assertThat(id1, is(not(id3)));
60 | assertThat(id2, is(not(id3)));
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/hasbinary/HasBinaryTest.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.hasbinary;
2 |
3 | import org.json.JSONArray;
4 | import org.json.JSONException;
5 | import org.json.JSONObject;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 | import org.junit.runners.JUnit4;
9 |
10 | import java.nio.charset.Charset;
11 |
12 | import static org.junit.Assert.assertTrue;
13 |
14 | @RunWith(JUnit4.class)
15 | public class HasBinaryTest {
16 |
17 | @Test
18 | public void byteArray() {
19 | assertTrue(HasBinary.hasBinary(new byte[0]));
20 | }
21 |
22 | @Test
23 | public void anArrayThatDoesNotContainByteArray() throws JSONException {
24 | JSONArray arr = new JSONArray("[1, \"cool\", 2]");
25 | assertTrue(!HasBinary.hasBinary(arr));
26 | }
27 |
28 | @Test
29 | public void anArrayContainsByteArray() throws JSONException {
30 | JSONArray arr = new JSONArray("[1, null, 2]");
31 | arr.put(1, "asdfasdf".getBytes(Charset.forName("UTF-8")));
32 | assertTrue(HasBinary.hasBinary(arr));
33 | }
34 |
35 | @Test
36 | public void anObjectThatDoesNotContainByteArray() throws JSONException {
37 | JSONObject ob = new JSONObject("{\"a\": \"a\", \"b\": [], \"c\": 1234}");
38 | assertTrue(!HasBinary.hasBinary(ob));
39 | }
40 |
41 | @Test
42 | public void anObjectThatContainsByteArray() throws JSONException {
43 | JSONObject ob = new JSONObject("{\"a\": \"a\", \"b\": null, \"c\": 1234}");
44 | ob.put("b", "abc".getBytes(Charset.forName("UTF-8")));
45 | assertTrue(HasBinary.hasBinary(ob));
46 | }
47 |
48 | @Test
49 | public void testNull() {
50 | assertTrue(!HasBinary.hasBinary(null));
51 | }
52 |
53 | @Test
54 | public void aComplexObjectThatContainsNoBinary() throws JSONException {
55 | JSONObject ob = new JSONObject();
56 | ob.put("x", new JSONArray("[\"a\", \"b\", 123]"));
57 | ob.put("y", JSONObject.NULL);
58 | ob.put("z", new JSONObject("{\"a\": \"x\", \"b\": \"y\", \"c\": 3, \"d\": null}"));
59 | ob.put("w", new JSONArray());
60 | assertTrue(!HasBinary.hasBinary(ob));
61 | }
62 |
63 | @Test
64 | public void aComplexObjectThatContainsBinary() throws JSONException {
65 | JSONObject ob = new JSONObject();
66 | ob.put("x", new JSONArray("[\"a\", \"b\", 123]"));
67 | ob.put("y", JSONObject.NULL);
68 | ob.put("z", new JSONObject("{\"a\": \"x\", \"b\": \"y\", \"c\": 3, \"d\": null}"));
69 | ob.put("w", new JSONArray());
70 | ob.put("bin", "xxx".getBytes(Charset.forName("UTF-8")));
71 | assertTrue(HasBinary.hasBinary(ob));
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/main/java/com/github/nkzawa/socketio/client/IO.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.client;
2 |
3 |
4 | import com.github.nkzawa.socketio.parser.Parser;
5 |
6 | import javax.net.ssl.HostnameVerifier;
7 | import javax.net.ssl.SSLContext;
8 | import java.net.MalformedURLException;
9 | import java.net.URI;
10 | import java.net.URISyntaxException;
11 | import java.net.URL;
12 | import java.util.concurrent.ConcurrentHashMap;
13 | import java.util.logging.Logger;
14 |
15 |
16 | public class IO {
17 |
18 | private static final Logger logger = Logger.getLogger(IO.class.getName());
19 |
20 | private static final ConcurrentHashMap managers = new ConcurrentHashMap();
21 |
22 | /**
23 | * Protocol version.
24 | */
25 | public static int protocol = Parser.protocol;
26 |
27 | public static void setDefaultSSLContext(SSLContext sslContext) {
28 | Manager.defaultSSLContext = sslContext;
29 | }
30 |
31 | public static void setDefaultHostnameVerifier(HostnameVerifier hostnameVerifier) {
32 | Manager.defaultHostnameVerifier = hostnameVerifier;
33 | }
34 |
35 | private IO() {}
36 |
37 | public static Socket socket(String uri) throws URISyntaxException {
38 | return socket(uri, null);
39 | }
40 |
41 | public static Socket socket(String uri, Options opts) throws URISyntaxException {
42 | return socket(new URI(uri), opts);
43 | }
44 |
45 | public static Socket socket(URI uri) throws URISyntaxException {
46 | return socket(uri, null);
47 | }
48 |
49 | /**
50 | * Initializes a {@link Socket} from an existing {@link Manager} for multiplexing.
51 | *
52 | * @param uri uri to connect.
53 | * @param opts options for socket.
54 | * @return {@link Socket} instance.
55 | * @throws URISyntaxException
56 | */
57 | public static Socket socket(URI uri, Options opts) throws URISyntaxException {
58 | if (opts == null) {
59 | opts = new Options();
60 | }
61 |
62 | URL parsed;
63 | try {
64 | parsed = Url.parse(uri);
65 | } catch (MalformedURLException e) {
66 | throw new URISyntaxException(uri.toString(), e.getMessage());
67 | }
68 | URI source = parsed.toURI();
69 | Manager io;
70 |
71 | if (opts.forceNew || !opts.multiplex) {
72 | logger.fine(String.format("ignoring socket cache for %s", source));
73 | io = new Manager(source, opts);
74 | } else {
75 | String id = Url.extractId(parsed);
76 | if (!managers.containsKey(id)) {
77 | logger.fine(String.format("new io instance for %s", source));
78 | managers.putIfAbsent(id, new Manager(source, opts));
79 | }
80 | io = managers.get(id);
81 | }
82 |
83 | return io.socket(parsed.getPath());
84 | }
85 |
86 |
87 | public static class Options extends Manager.Options {
88 |
89 | public boolean forceNew;
90 |
91 | /**
92 | * Whether to enable multiplexing. Default is true.
93 | */
94 | public boolean multiplex = true;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kriyatma/nodesocket/MessageAdapter.java:
--------------------------------------------------------------------------------
1 | package com.kriyatma.nodesocket;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import java.util.List;
13 |
14 |
15 | public class MessageAdapter extends RecyclerView.Adapter {
16 |
17 | private List mMessages;
18 | private int[] mUsernameColors;
19 |
20 | public MessageAdapter(List messages) {
21 | mMessages = messages;
22 | // mUsernameColors = context.getResources().getIntArray(R.array.username_colors);
23 | }
24 |
25 | @Override
26 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
27 | int layout = -1;
28 | /*switch (viewType) {
29 | case Message.TYPE_MESSAGE:
30 | layout = R.layout.item_message;
31 | break;
32 | case Message.TYPE_LOG:
33 | layout = R.layout.item_log;
34 | break;
35 | case Message.TYPE_ACTION:
36 | layout = R.layout.item_action;
37 | break;
38 | }*/
39 | View v = LayoutInflater
40 | .from(parent.getContext())
41 | .inflate(R.layout.layout_message, parent, false);
42 | return new ViewHolder(v);
43 | }
44 |
45 | @Override
46 | public void onBindViewHolder(ViewHolder viewHolder, int position) {
47 | Message message = mMessages.get(position);
48 | viewHolder.setMessage(message.getMessage());
49 | viewHolder.setImage(message.getImage());
50 | }
51 |
52 | @Override
53 | public int getItemCount() {
54 | return mMessages.size();
55 | }
56 |
57 | @Override
58 | public int getItemViewType(int position) {
59 | return mMessages.get(position).getType();
60 | }
61 |
62 | public class ViewHolder extends RecyclerView.ViewHolder {
63 | private ImageView mImageView;
64 | private TextView mMessageView;
65 | public ViewHolder(View itemView) {
66 | super(itemView);
67 | mImageView = (ImageView) itemView.findViewById(R.id.image);
68 | mMessageView = (TextView) itemView.findViewById(R.id.message);
69 | }
70 |
71 | public void setMessage(String message) {
72 | if (null == mMessageView) return;
73 | if(null == message) return;
74 | mMessageView.setText(message);
75 | }
76 |
77 | public void setImage(Bitmap bmp){
78 | if(null == mImageView) return;
79 | if(null == bmp) return;
80 | mImageView.setImageBitmap(bmp);
81 | }
82 | private int getUsernameColor(String username) {
83 | int hash = 7;
84 | for (int i = 0, len = username.length(); i < len; i++) {
85 | hash = username.codePointAt(i) + (hash << 5) - hash;
86 | }
87 | int index = Math.abs(hash % mUsernameColors.length);
88 | return mUsernameColors[index];
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/resources/server.js:
--------------------------------------------------------------------------------
1 | var fs = require('fs');
2 |
3 | var server;
4 | if (process.env.SSL) {
5 | server = require('https').createServer({
6 | key: fs.readFileSync(__dirname + '/key.pem'),
7 | cert: fs.readFileSync(__dirname + '/cert.pem')
8 | });
9 | } else {
10 | server = require('http').createServer();
11 | }
12 |
13 | var io = require('socket.io')(server);
14 | var port = process.env.PORT || 3000;
15 | var nsp = process.argv[2] || '/';
16 | var slice = Array.prototype.slice;
17 |
18 | io.of('/foo').on('connection', function() {
19 | // register namespace
20 | });
21 |
22 | io.of('/timeout_socket').on('connection', function() {
23 | // register namespace
24 | });
25 |
26 | io.of('/valid').on('connection', function() {
27 | // register namespace
28 | });
29 |
30 | io.of('/asd').on('connection', function() {
31 | // register namespace
32 | });
33 |
34 | io.of(nsp).on('connection', function(socket) {
35 | socket.send('hello client');
36 |
37 | socket.on('message', function() {
38 | var args = slice.call(arguments);
39 | socket.send.apply(socket, args);
40 | });
41 |
42 | socket.on('echo', function() {
43 | var args = slice.call(arguments);
44 | socket.emit.apply(socket, ['echoBack'].concat(args));
45 | });
46 |
47 | socket.on('ack', function() {
48 | var args = slice.call(arguments);
49 | var callback = args.pop();
50 | callback.apply(null, args);
51 | });
52 |
53 | socket.on('callAck', function() {
54 | socket.emit('ack', function() {
55 | var args = slice.call(arguments);
56 | socket.emit.apply(socket, ['ackBack'].concat(args));
57 | });
58 | });
59 |
60 | socket.on('getAckDate', function(data, callback) {
61 | callback(new Date());
62 | });
63 |
64 | socket.on('broadcast', function(data) {
65 | var args = slice.call(arguments);
66 | socket.broadcast.emit.apply(socket, ['broadcastBack'].concat(args));
67 | });
68 |
69 | socket.on('room', function() {
70 | var args = slice.call(arguments);
71 | io.to(socket.id).emit.apply(socket, ['roomBack'].concat(args));
72 | });
73 |
74 | socket.on('requestDisconnect', function() {
75 | socket.disconnect();
76 | });
77 |
78 | socket.on('disconnect', function() {
79 | console.log('disconnect');
80 | });
81 |
82 | socket.on('error', function() {
83 | console.log('error: ', arguments);
84 | });
85 | });
86 |
87 |
88 | function before(context, name, fn) {
89 | var method = context[name];
90 | context[name] = function() {
91 | fn.apply(this, arguments);
92 | return method.apply(this, arguments);
93 | };
94 | }
95 |
96 | before(io.engine, 'handleRequest', function(req, res) {
97 | // echo a header value
98 | var value = req.headers['x-socketio'];
99 | if (!value) return;
100 | res.setHeader('X-SocketIO', value);
101 | });
102 |
103 | before(io.engine, 'handleUpgrade', function(req, socket, head) {
104 | // echo a header value for websocket handshake
105 | var value = req.headers['x-socketio'];
106 | if (!value) return;
107 | this.ws.once('headers', function(headers) {
108 | headers.push('X-SocketIO: ' + value);
109 | });
110 | });
111 |
112 |
113 | server.listen(port, function() {
114 | console.log('Socket.IO server listening on port', port);
115 | });
116 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kriyatma/nodesocket/SocketActivity.java:
--------------------------------------------------------------------------------
1 | package com.kriyatma.nodesocket;
2 |
3 | import android.content.Intent;
4 | import android.database.Cursor;
5 | import android.graphics.Bitmap;
6 | import android.graphics.BitmapFactory;
7 | import android.net.Uri;
8 | import android.provider.MediaStore;
9 | import android.support.v7.app.ActionBarActivity;
10 | import android.os.Bundle;
11 | import android.util.Base64;
12 | import android.util.Log;
13 | import android.view.Menu;
14 | import android.view.MenuInflater;
15 | import android.view.MenuItem;
16 |
17 | import java.io.ByteArrayInputStream;
18 | import java.io.ByteArrayOutputStream;
19 | import java.io.File;
20 | import java.io.FileInputStream;
21 | import java.io.FileNotFoundException;
22 | import java.net.URI;
23 |
24 |
25 | public class SocketActivity extends ActionBarActivity {
26 |
27 | String imgDecodableString;
28 | @Override
29 | protected void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 |
32 | setContentView(R.layout.activity_socket);
33 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
34 | getSupportActionBar().setHomeButtonEnabled(true);
35 |
36 | }
37 |
38 | @Override
39 | public boolean onCreateOptionsMenu(Menu menu) {
40 | // Inflate the menu; this adds items to the action bar if it is present.
41 | Log.d("onCreateOptionsMenu", "create menu");
42 | MenuInflater inflater = getMenuInflater();
43 | inflater.inflate(R.menu.socket_activity_actions, menu);
44 | return super.onCreateOptionsMenu(menu);
45 | }
46 |
47 | @Override
48 | public boolean onOptionsItemSelected(MenuItem item) {
49 | // Handle action bar item clicks here. The action bar will
50 | // automatically handle clicks on the Home/Up button, so long
51 | // as you specify a parent activity in AndroidManifest.xml.
52 | switch (item.getItemId()) {
53 | case R.id.action_attach:
54 | Log.d("onOptionsItemSelected","action_attach");
55 | openGallery();
56 | return true;
57 | case R.id.action_capture:
58 | Log.d("onOptionsItemSelected","action_capture");
59 | // openSettings();
60 | return true;
61 | default:
62 | return super.onOptionsItemSelected(item);
63 | }
64 | }
65 |
66 | private void openGallery()
67 | {
68 | Intent galleryintent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
69 | startActivityForResult(galleryintent, 1);
70 | }
71 |
72 | @Override
73 | protected void onActivityResult(int requestCode,int resultCode,Intent data)
74 | {
75 | super.onActivityResult(requestCode, resultCode, data);
76 | if (requestCode == 1 && resultCode == RESULT_OK
77 | && null != data) {
78 | Uri selectedImage = data.getData();
79 | String[] filePathColumn = {MediaStore.Images.Media.DATA};
80 |
81 | Cursor cursor = getContentResolver().query(selectedImage,
82 | filePathColumn, null, null, null);
83 | // Move to first row
84 | cursor.moveToFirst();
85 | int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
86 | imgDecodableString = cursor.getString(columnIndex);
87 | cursor.close();
88 | //Log.d("onActivityResult",imgDecodableString);
89 | ChatFragment fragment = (ChatFragment) getFragmentManager().findFragmentById(R.id.chat);
90 | fragment.sendImage(imgDecodableString);
91 | }
92 | }
93 |
94 |
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/socketio/parser/ByteArrayTest.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.parser;
2 |
3 | import com.github.nkzawa.emitter.Emitter;
4 | import org.json.JSONArray;
5 | import org.json.JSONException;
6 | import org.json.JSONObject;
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 | import org.junit.runners.JUnit4;
10 |
11 | import java.nio.charset.Charset;
12 |
13 | import static org.hamcrest.CoreMatchers.is;
14 | import static org.junit.Assert.assertThat;
15 |
16 | @RunWith(JUnit4.class)
17 | public class ByteArrayTest {
18 |
19 | private static Parser.Encoder encoder = new Parser.Encoder();
20 |
21 | @Test
22 | public void encodeByteArray() {
23 | Packet packet = new Packet(Parser.BINARY_EVENT);
24 | packet.data = "abc".getBytes(Charset.forName("UTF-8"));
25 | packet.id = 23;
26 | packet.nsp = "/cool";
27 | Helpers.testBin(packet);
28 | }
29 |
30 | @Test
31 | public void encodeByteArray2() {
32 | Packet packet = new Packet(Parser.BINARY_EVENT);
33 | packet.data = new byte[2];
34 | packet.id = 0;
35 | packet.nsp = "/";
36 | Helpers.testBin(packet);
37 | }
38 |
39 | @Test
40 | public void encodeByteArrayDeepInJson() throws JSONException {
41 | JSONObject data = new JSONObject("{a: \"hi\", b: {}, c: {a: \"bye\", b: {}}}");
42 | data.getJSONObject("b").put("why", new byte[3]);
43 | data.getJSONObject("c").getJSONObject("b").put("a", new byte[6]);
44 |
45 | Packet packet = new Packet(Parser.BINARY_EVENT);
46 | packet.data = data;
47 | packet.id = 999;
48 | packet.nsp = "/deep";
49 | Helpers.testBin(packet);
50 | }
51 |
52 | @Test
53 | public void encodeDeepBinaryJSONWithNullValue() throws JSONException {
54 | JSONObject data = new JSONObject("{a: \"b\", c: 4, e: {g: null}, h: null}");
55 | data.put("h", new byte[9]);
56 |
57 | Packet packet = new Packet(Parser.BINARY_EVENT);
58 | packet.data = data;
59 | packet.nsp = "/";
60 | packet.id = 600;
61 | Helpers.testBin(packet);
62 | }
63 |
64 | @Test
65 | public void encodeBinaryAckWithByteArray() throws JSONException {
66 | JSONArray data = new JSONArray("[a, null, {}]");
67 | data.put(1, "xxx".getBytes(Charset.forName("UTF-8")));
68 |
69 | Packet packet = new Packet(Parser.BINARY_ACK);
70 | packet.data = data;
71 | packet.id = 127;
72 | packet.nsp = "/back";
73 | Helpers.testBin(packet);
74 | }
75 |
76 | @Test
77 | public void cleanItselfUpOnClose() {
78 | JSONArray data = new JSONArray();
79 | data.put(new byte[2]);
80 | data.put(new byte[3]);
81 |
82 | Packet packet = new Packet(Parser.BINARY_EVENT);
83 | packet.data = data;
84 | packet.id = 0;
85 | packet.nsp = "/";
86 |
87 | encoder.encode(packet, new Parser.Encoder.Callback() {
88 | @Override
89 | public void call(final Object[] encodedPackets) {
90 | final Parser.Decoder decoder = new Parser.Decoder();
91 | decoder.on(Parser.Decoder.EVENT_DECODED, new Emitter.Listener() {
92 | @Override
93 | public void call(Object... args) {
94 | throw new RuntimeException("received a packet when not all binary data was sent.");
95 | }
96 | });
97 |
98 | decoder.add((String)encodedPackets[0]);
99 | decoder.add((byte[]) encodedPackets[1]);
100 | decoder.destroy();
101 | assertThat(decoder.reconstructor.buffers.size(), is(0));
102 | }
103 | });
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/socketio/parser/Helpers.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.parser;
2 |
3 | import com.github.nkzawa.emitter.Emitter;
4 | import org.json.JSONArray;
5 | import org.json.JSONException;
6 | import org.json.JSONObject;
7 | import org.junit.runner.RunWith;
8 | import org.junit.runners.JUnit4;
9 | import org.skyscreamer.jsonassert.JSONAssert;
10 |
11 | import static org.hamcrest.CoreMatchers.is;
12 | import static org.junit.Assert.assertThat;
13 |
14 | @RunWith(JUnit4.class)
15 | public class Helpers {
16 |
17 | private static Parser.Encoder encoder = new Parser.Encoder();
18 | private static Packet errorPacket = new Packet(Parser.ERROR, "parser error");
19 |
20 | public static void test(final Packet obj) {
21 | encoder.encode(obj, new Parser.Encoder.Callback() {
22 | @Override
23 | public void call(Object[] encodedPackets) {
24 | Parser.Decoder decoder = new Parser.Decoder();
25 | decoder.on(Parser.Decoder.EVENT_DECODED, new Emitter.Listener() {
26 | @Override
27 | public void call(Object... args) {
28 | Packet packet = (Packet)args[0];
29 | assertPacket(packet, obj);
30 | }
31 | });
32 | decoder.add((String)encodedPackets[0]);
33 | }
34 | });
35 | }
36 |
37 | public static void testDecodeError(final String errorMessage) {
38 | Parser.Decoder decoder = new Parser.Decoder();
39 | decoder.on(Parser.Decoder.EVENT_DECODED, new Emitter.Listener() {
40 | @Override
41 | public void call(Object... args) {
42 | Packet packet = (Packet)args[0];
43 | assertPacket(errorPacket, packet);
44 | }
45 | });
46 | decoder.add(errorMessage);
47 | }
48 |
49 | public static void testBin(final Packet obj) {
50 | final Object originalData = obj.data;
51 | encoder.encode(obj, new Parser.Encoder.Callback() {
52 | @Override
53 | public void call(Object[] encodedPackets) {
54 | Parser.Decoder decoder = new Parser.Decoder();
55 | decoder.on(Parser.Decoder.EVENT_DECODED, new Emitter.Listener() {
56 | @Override
57 | public void call(Object... args) {
58 | Packet packet = (Packet)args[0];
59 | obj.data = originalData;
60 | obj.attachments = -1;
61 | assertPacket(packet, obj);
62 | }
63 | });
64 |
65 | for (Object packet : encodedPackets) {
66 | if (packet instanceof String) {
67 | decoder.add((String)packet);
68 | } else if (packet instanceof byte[]) {
69 | decoder.add((byte[])packet);
70 | }
71 | }
72 | }
73 | });
74 | }
75 |
76 | public static void assertPacket(Packet expected, Packet actual) {
77 | assertThat(actual.type, is(expected.type));
78 | assertThat(actual.id, is(expected.id));
79 | assertThat(actual.nsp, is(expected.nsp));
80 | assertThat(actual.attachments, is(expected.attachments));
81 |
82 | if (expected.data instanceof JSONArray) {
83 | try {
84 | JSONAssert.assertEquals((JSONArray)expected.data, (JSONArray)actual.data, true);
85 | } catch (JSONException e) {
86 | throw new AssertionError(e);
87 | }
88 | } else if (expected.data instanceof JSONObject) {
89 | try {
90 | JSONAssert.assertEquals((JSONObject)expected.data, (JSONObject)actual.data, true);
91 | } catch (JSONException e) {
92 | throw new AssertionError(e);
93 | }
94 | } else {
95 | assertThat(actual.data, is(expected.data));
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/socketio/client/SocketTest.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.client;
2 |
3 | import com.github.nkzawa.emitter.Emitter;
4 | import com.github.nkzawa.util.Optional;
5 | import org.junit.Test;
6 | import org.junit.runner.RunWith;
7 | import org.junit.runners.JUnit4;
8 |
9 | import java.net.URISyntaxException;
10 | import java.util.concurrent.BlockingQueue;
11 | import java.util.concurrent.LinkedBlockingQueue;
12 |
13 | import static org.hamcrest.CoreMatchers.*;
14 | import static org.junit.Assert.assertThat;
15 |
16 | @RunWith(JUnit4.class)
17 | public class SocketTest extends Connection {
18 |
19 | private Socket socket;
20 |
21 | @Test(timeout = TIMEOUT)
22 | public void shouldHaveAnAccessibleSocketIdEqualToTheEngineIOSocketId() throws URISyntaxException, InterruptedException {
23 | final BlockingQueue values = new LinkedBlockingQueue();
24 | socket = client();
25 | socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
26 | @Override
27 | public void call(Object... objects) {
28 | values.offer(Optional.ofNullable(socket.id()));
29 | }
30 | });
31 | socket.connect();
32 |
33 | @SuppressWarnings("unchecked")
34 | Optional id = values.take();
35 | assertThat(id.isPresent(), is(true));
36 | assertThat(id.get(), is(socket.io().engine.id()));
37 | socket.disconnect();
38 | }
39 |
40 | @Test(timeout = TIMEOUT)
41 | public void clearsSocketIdUponDisconnection() throws URISyntaxException, InterruptedException {
42 | final BlockingQueue values = new LinkedBlockingQueue();
43 | socket = client();
44 | socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
45 | @Override
46 | public void call(Object... objects) {
47 | socket.on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
48 | @Override
49 | public void call(Object... args) {
50 | values.offer(Optional.ofNullable(socket.id()));
51 | }
52 | });
53 |
54 | socket.disconnect();
55 | }
56 | });
57 | socket.connect();
58 | @SuppressWarnings("unchecked")
59 | Optional id = values.take();
60 | assertThat(id.isPresent(), is(false));
61 | }
62 |
63 | @Test(timeout = TIMEOUT)
64 | public void shouldChangeSocketIdUponReconnection() throws URISyntaxException, InterruptedException {
65 | final BlockingQueue values = new LinkedBlockingQueue();
66 | socket = client();
67 | socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
68 | @Override
69 | public void call(Object... objects) {
70 | values.offer(Optional.ofNullable(socket.id()));
71 |
72 | socket.on(Socket.EVENT_RECONNECT_ATTEMPT, new Emitter.Listener() {
73 | @Override
74 | public void call(Object... objects) {
75 | values.offer(Optional.ofNullable(socket.id()));
76 | }
77 | });
78 |
79 | socket.on(Socket.EVENT_RECONNECT, new Emitter.Listener() {
80 | @Override
81 | public void call(Object... objects) {
82 | values.offer(Optional.ofNullable(socket.id()));
83 | }
84 | });
85 |
86 | socket.io().engine.close();
87 | }
88 | });
89 | socket.connect();
90 | @SuppressWarnings("unchecked")
91 | Optional id1 = values.take();
92 |
93 | @SuppressWarnings("unchecked")
94 | Optional id2 = values.take();
95 | assertThat(id2.isPresent(), is(false));
96 |
97 | @SuppressWarnings("unchecked")
98 | Optional id3 = values.take();
99 | assertThat(id3.get(), is(not(id1.get())));
100 |
101 | socket.disconnect();
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/socketio/client/Connection.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.client;
2 |
3 | import org.junit.After;
4 | import org.junit.Before;
5 |
6 | import java.io.BufferedReader;
7 | import java.io.IOException;
8 | import java.io.InputStreamReader;
9 | import java.net.URISyntaxException;
10 | import java.util.HashMap;
11 | import java.util.Map;
12 | import java.util.concurrent.*;
13 | import java.util.logging.Logger;
14 |
15 | public abstract class Connection {
16 |
17 | private static final Logger logger = Logger.getLogger(Connection.class.getName());
18 |
19 | final static int TIMEOUT = 7000;
20 | final static int PORT = 3000;
21 |
22 | private Process serverProcess;
23 | private ExecutorService serverService;
24 | private Future serverOutput;
25 | private Future serverError;
26 |
27 | @Before
28 | public void startServer() throws IOException, InterruptedException {
29 | logger.fine("Starting server ...");
30 |
31 | final CountDownLatch latch = new CountDownLatch(1);
32 | serverProcess = Runtime.getRuntime().exec(
33 | String.format("node src/test/resources/server.js %s", nsp()), createEnv());
34 | serverService = Executors.newCachedThreadPool();
35 | serverOutput = serverService.submit(new Runnable() {
36 | @Override
37 | public void run() {
38 | BufferedReader reader = new BufferedReader(
39 | new InputStreamReader(serverProcess.getInputStream()));
40 | String line;
41 | try {
42 | line = reader.readLine();
43 | latch.countDown();
44 | do {
45 | logger.fine("SERVER OUT: " + line);
46 | } while ((line = reader.readLine()) != null);
47 | } catch (IOException e) {
48 | logger.warning(e.getMessage());
49 | }
50 | }
51 | });
52 | serverError = serverService.submit(new Runnable() {
53 | @Override
54 | public void run() {
55 | BufferedReader reader = new BufferedReader(
56 | new InputStreamReader(serverProcess.getErrorStream()));
57 | String line;
58 | try {
59 | while ((line = reader.readLine()) != null) {
60 | logger.fine("SERVER ERR: " + line);
61 | }
62 | } catch (IOException e) {
63 | logger.warning(e.getMessage());
64 | }
65 | }
66 | });
67 | latch.await(3000, TimeUnit.MILLISECONDS);
68 | }
69 |
70 | @After
71 | public void stopServer() throws InterruptedException {
72 | logger.fine("Stopping server ...");
73 | serverProcess.destroy();
74 | serverOutput.cancel(false);
75 | serverError.cancel(false);
76 | serverService.shutdown();
77 | serverService.awaitTermination(3000, TimeUnit.MILLISECONDS);
78 | }
79 |
80 | Socket client() throws URISyntaxException {
81 | return client(createOptions());
82 | }
83 |
84 | Socket client(IO.Options opts) throws URISyntaxException {
85 | return IO.socket(uri() + nsp(), opts);
86 | }
87 |
88 | String uri() {
89 | return "http://localhost:" + PORT;
90 | }
91 |
92 | String nsp() {
93 | return "/";
94 | }
95 |
96 | IO.Options createOptions() {
97 | IO.Options opts = new IO.Options();
98 | opts.forceNew = true;
99 | return opts;
100 | }
101 |
102 | String[] createEnv() {
103 | Map env = new HashMap(System.getenv());
104 | env.put("DEBUG", "socket.io:*");
105 | env.put("PORT", String.valueOf(PORT));
106 | String[] _env = new String[env.size()];
107 | int i = 0;
108 | for (String key : env.keySet()) {
109 | _env[i] = key + "=" + env.get(key);
110 | i++;
111 | }
112 | return _env;
113 |
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/README.md:
--------------------------------------------------------------------------------
1 | # Socket.IO-client.java
2 | [](https://travis-ci.org/nkzawa/socket.io-client.java)
3 |
4 | This is the Socket.IO v1.x Client Library for Java, which is simply ported from the [JavaScript client](https://github.com/Automattic/socket.io-client).
5 |
6 | See also:
7 |
8 | - [Android chat demo](https://github.com/nkzawa/socket.io-android-chat)
9 | - [engine.io-client.java](https://github.com/nkzawa/engine.io-client.java)
10 |
11 | ## Installation
12 | The latest artifact is available on Maven Central. To install manually, please refer dependencies to [pom.xml](https://github.com/nkzawa/socket.io-client.java/blob/master/pom.xml).
13 |
14 | ### Maven
15 | Add the following dependency to your `pom.xml`.
16 |
17 | ```xml
18 |
19 |
20 | com.github.nkzawa
21 | socket.io-client
22 | 0.5.0
23 |
24 |
25 | ```
26 |
27 | ### Gradle
28 | Add it as a gradle dependency for Android Studio, in `build.gradle`:
29 |
30 | ```groovy
31 | compile 'com.github.nkzawa:socket.io-client:0.5.0'
32 | ```
33 |
34 | ## Usage
35 | Socket.IO-client.java has almost the same api and features with the original JS client. You use `IO#socket` to initialize `Socket`:
36 |
37 | ```java
38 | socket = IO.socket("http://localhost");
39 | socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
40 |
41 | @Override
42 | public void call(Object... args) {
43 | socket.emit("foo", "hi");
44 | socket.disconnect();
45 | }
46 |
47 | }).on("event", new Emitter.Listener() {
48 |
49 | @Override
50 | public void call(Object... args) {}
51 |
52 | }).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
53 |
54 | @Override
55 | public void call(Object... args) {}
56 |
57 | });
58 | socket.connect();
59 | ```
60 |
61 | This Library uses [org.json](http://www.json.org/java/) to parse and compose JSON strings:
62 |
63 | ```java
64 | // Sending an object
65 | JSONObject obj = new JSONObject();
66 | obj.put("hello", "server");
67 | obj.put("binary", new byte[42]);
68 | socket.emit("foo", obj);
69 |
70 | // Receiving an object
71 | socket.on("foo", new Emitter.Listener() {
72 | @Override
73 | public void call(Object... args) {
74 | JSONObject obj = (JSONObject)args[0];
75 | }
76 | });
77 | ```
78 |
79 | Options are supplied as follows:
80 |
81 | ```java
82 | IO.Options opts = new IO.Options();
83 | opts.forceNew = true;
84 | opts.reconnection = false;
85 |
86 | socket = IO.socket("http://localhost", opts);
87 | ```
88 |
89 | You can supply query parameters with the `query` option. NB: if you don't want to reuse a cached socket instance when the query parameter changes, you should use the `forceNew` option, the use case might be if your app allows for a user to logout, and a new user to login again:
90 |
91 | ```java
92 | IO.Options opts = new IO.Options();
93 | opts.forceNew = true;
94 | opts.query = "auth_token=" + authToken;
95 | Socket socket = IO.socket("http://localhost", opts);
96 | ```
97 |
98 | You can get a callback with `Ack` when the server received a message:
99 |
100 | ```java
101 | socket.emit("foo", "woot", new Ack() {
102 | @Override
103 | public void call(Object... args) {}
104 | });
105 | ```
106 |
107 | And vice versa:
108 |
109 | ```java
110 | // ack from client to server
111 | socket.on("foo", new Emitter.Listener() {
112 | @Override
113 | public void call(Object... args) {
114 | Ack ack = (Ack) args[args.length - 1];
115 | ack.call();
116 | }
117 | });
118 | ```
119 |
120 | Use custom SSL settings:
121 |
122 | ```java
123 | // default SSLContext for all sockets
124 | IO.setDefaultSSLContext(mySSLContext);
125 |
126 | // set as an option
127 | opts = new IO.Options();
128 | opts.sslContext = mySSLContext;
129 | socket = IO.socket("https://localhost", opts);
130 | ```
131 |
132 | See the Javadoc for more details.
133 |
134 | http://nkzawa.github.io/socket.io-client.java/apidocs/
135 |
136 | ## Features
137 | This library supports all of the features the JS client does, including events, options and upgrading transport. Android is fully supported.
138 |
139 | ## License
140 |
141 | MIT
142 |
143 |
--------------------------------------------------------------------------------
/app/libs/socket.io-client.java-master/src/test/java/com/github/nkzawa/socketio/client/SSLConnectionTest.java:
--------------------------------------------------------------------------------
1 | package com.github.nkzawa.socketio.client;
2 |
3 | import com.github.nkzawa.emitter.Emitter;
4 | import org.junit.After;
5 | import org.junit.Test;
6 | import org.junit.runner.RunWith;
7 | import org.junit.runners.JUnit4;
8 |
9 | import javax.net.ssl.HostnameVerifier;
10 | import javax.net.ssl.KeyManagerFactory;
11 | import javax.net.ssl.SSLContext;
12 | import javax.net.ssl.TrustManagerFactory;
13 | import java.io.File;
14 | import java.io.FileInputStream;
15 | import java.io.IOException;
16 | import java.security.GeneralSecurityException;
17 | import java.security.KeyStore;
18 | import java.util.concurrent.BlockingQueue;
19 | import java.util.concurrent.LinkedBlockingQueue;
20 |
21 | @RunWith(JUnit4.class)
22 | public class SSLConnectionTest extends Connection {
23 |
24 | // for test on localhost
25 | static HostnameVerifier hostnameVerifier = new HostnameVerifier(){
26 | public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {
27 | return hostname.equals("localhost");
28 | }
29 | };
30 |
31 | private Socket socket;
32 |
33 | @Override
34 | String uri() {
35 | return "https://localhost:" + PORT;
36 | }
37 |
38 | @Override
39 | IO.Options createOptions() {
40 | IO.Options opts = super.createOptions();
41 | opts.secure = true;
42 | return opts;
43 | }
44 |
45 | @Override
46 | String[] createEnv() {
47 | return new String[] {"DEBUG=socket.io:*", "PORT=" + PORT, "SSL=1"};
48 | }
49 |
50 | SSLContext createSSLContext() throws GeneralSecurityException, IOException {
51 | KeyStore ks = KeyStore.getInstance("JKS");
52 | File file = new File("src/test/resources/keystore.jks");
53 | ks.load(new FileInputStream(file), "password".toCharArray());
54 |
55 | KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
56 | kmf.init(ks, "password".toCharArray());
57 |
58 | TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
59 | tmf.init(ks);
60 |
61 | SSLContext sslContext = SSLContext.getInstance("TLS");
62 | sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
63 | return sslContext;
64 | }
65 |
66 | @After
67 | public void tearDown() {
68 | IO.setDefaultSSLContext(null);
69 | IO.setDefaultHostnameVerifier(null);
70 | }
71 |
72 | @Test(timeout = TIMEOUT)
73 | public void connect() throws Exception {
74 | final BlockingQueue