Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sridatta committed Jun 25, 2012
1 parent 4729bb0 commit a5a3e85
Show file tree
Hide file tree
Showing 151 changed files with 3,284 additions and 12 deletions.
16 changes: 16 additions & 0 deletions chat/AndroidChat/AndroidManifest.xml
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.flotype.bridge" android:versionCode="1"
android:versionName="1.0">


<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MainActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
Binary file added chat/AndroidChat/bin/BridgeAndroidTest.apk
Binary file not shown.
Binary file added chat/AndroidChat/bin/classes.dex
Binary file not shown.
3 changes: 3 additions & 0 deletions chat/AndroidChat/bin/jarlist.cache
@@ -0,0 +1,3 @@
# cache for current jar dependecy. DO NOT EDIT.
# format is <lastModified> <length> <SHA-1> <path>
# Encoding is UTF-8
Binary file added chat/AndroidChat/bin/res/drawable-hdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chat/AndroidChat/bin/res/drawable-ldpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chat/AndroidChat/bin/res/drawable-mdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chat/AndroidChat/bin/resources.ap_
Binary file not shown.
6 changes: 6 additions & 0 deletions chat/AndroidChat/gen/com/flotype/bridge/BuildConfig.java
@@ -0,0 +1,6 @@
/** Automatically generated file. DO NOT MODIFY */
package com.flotype.bridge;

public final class BuildConfig {
public final static boolean DEBUG = true;
}
28 changes: 28 additions & 0 deletions chat/AndroidChat/gen/com/flotype/bridge/R.java
@@ -0,0 +1,28 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/

package com.flotype.bridge;

public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int button1=0x7f050002;
public static final int editText1=0x7f050001;
public static final int text=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
3 changes: 3 additions & 0 deletions chat/AndroidChat/lint.xml
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
</lint>
31 changes: 31 additions & 0 deletions chat/AndroidChat/pom.xml
@@ -0,0 +1,31 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>BridgeAndroidTest</artifactId>
<name>asdf</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.flotype.bridge</groupId>
<artifactId>bridge-java-core</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies>

<url>http://flotype.com</url>
<organization>
<name>Flotype Inc.</name>
<url>http://flotype.com</url>
</organization>
<scm>
<url>http://git.flotype.com/bridge-java</url>
</scm>
<version>0.0.1-snapshot</version>
<groupId>com.sridattalabs</groupId>
</project>
36 changes: 36 additions & 0 deletions chat/AndroidChat/proguard.cfg
@@ -0,0 +1,36 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
14 changes: 14 additions & 0 deletions chat/AndroidChat/project.properties
@@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-10
Binary file added chat/AndroidChat/res/drawable-hdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chat/AndroidChat/res/drawable-ldpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chat/AndroidChat/res/drawable-mdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions chat/AndroidChat/res/layout/main.xml
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:editable="false"
android:text="Welcome to Bridge Chat"
android:textAppearance="?android:attr/textAppearanceLarge" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" >

<requestFocus />
</EditText>

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Send" />
</LinearLayout>

</LinearLayout>
5 changes: 5 additions & 0 deletions chat/AndroidChat/res/values/strings.xml
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, MainActivity!</string>
<string name="app_name">BridgeAndroidTest</string>
</resources>
80 changes: 80 additions & 0 deletions chat/AndroidChat/src/com/flotype/bridge/MainActivity.java
@@ -0,0 +1,80 @@
package com.flotype.bridge;

import java.io.IOException;


import org.apache.log4j.Level;


import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.widget.TextView;
import de.mindpipe.android.logging.log4j.LogConfigurator;

public class MainActivity extends Activity {

interface RemoteChat extends BridgeRemoteObject {
public void message(String sender, String message);
}



interface RemoteAuth extends BridgeRemoteObject {
public void join(String room, String pass, ChatObj obj, BridgeObject cb);
}

static {
final LogConfigurator logConfigurator = new LogConfigurator();

logConfigurator.setUseFileAppender(false);
logConfigurator.setRootLevel(Level.DEBUG);
// Set log level of a specific logger
logConfigurator.setLevel("org.apache", Level.ERROR);
logConfigurator.configure();
}

interface RemoteGreeter extends BridgeRemoteObject {
public void greet(String name, BridgeObject callback);
}

Bridge bridge;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

bridge = new Bridge("abcdefgh");
try {
RemoteAuth auth = bridge.getService("auth", RemoteAuth.class);
auth.join("bridge-lovers", "secret123", new ChatObj(), new BridgeObject() {
public void callback(RemoteChat channel, String channelName) {

}
});
bridge.connect();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public void updateText(final String text) {
runOnUiThread(new Runnable() {
public void run() {
TextView textView = (TextView) findViewById(R.id.text);
textView.append("\n" + text);
}
});

}

class ChatObj implements BridgeObject {
public void message(String sender, String message) {
MainActivity.this.updateText(sender + ": " + message);
}
}

}
2 changes: 1 addition & 1 deletion readline.js → chat/chat.js
Expand Up @@ -13,7 +13,7 @@ var chatHandler = {
var joinCallback = function (channel, name) {
console.log('Joined channel : ', name);
rl.on('line', function (line) {
channel.message('steve', line);
channel.message('Jasper', line);
});
};

Expand Down
2 changes: 1 addition & 1 deletion readline.rb → chat/chat.rb
Expand Up @@ -8,7 +8,7 @@ def initialize(channel)
end

def receive_line(data)
@ch.message("steve", data)
@ch.message("Ruby", data)
end
end

Expand Down
16 changes: 16 additions & 0 deletions chat/chatserver.py
@@ -0,0 +1,16 @@
from BridgePython import Bridge


class AuthHandler(object):
def join(self, room, password, obj, callback):
if password == "secret123":
print ('Welcome!')
# new: join channel using the client's objects
bridge.join_channel(room, obj, callback)
else:
print ('Sorry!')

bridge = Bridge(api_key='abcdefgh')
bridge.publish_service('auth', AuthHandler())

bridge.connect()

0 comments on commit a5a3e85

Please sign in to comment.