This project is a demo of using the Jegarn Android SDK.
First, copy the sdk library into you project.
copy "/android-chat-system/jegarn" into your project
Then, update your build.gradle file.
dependencies {
compile project(':jegarn')
}
For more details, please see the demo project. And these are some base usages.
String host = "jegarn.com";
int port = 9501;
int reconnectInterval = 5000;
String account = "test";
String password = "test";
// is connect to ssl server ?
boolean enableSsl = true;
DefaultListener listener = new DefaultListener();
JegarnManager.getInstance().init(host,port, reconnectInterval, account, password, enableSsl,listener);
JegarnManager.getInstance().run();
JegarnManager.client.getChatManager().addListener(new ChatManagerListener() {
@Override
public boolean processPacket(Chat packet) {
if (toUserUid.equals(packet.getFrom())) {
if (packet instanceof TextChat) {
TextChat pkt = (TextChat) packet;
}
}
return true;
}
});
TextChat packet = new TextChat("my_uid", "friend_uid", TextChat.TYPE, new TextChatContent("hello"));
JegarnManager.client.sendPacket(packet);
Three steps:
git clone git@github.com:Yaoguais/android-on-the-way.git
cd android-chat-system
gradle build
Open your Android Studio for adding the project of root directory "android-chat-system", then just run it.
Apache License Version 2.0