简体   繁体   English

AWS Android聊天应用程序

[英]AWS Android Chat App

I am trying to make an android chat application. 我正在尝试制作一个Android聊天应用程序。 I am thinking about making it with aws. 我正在考虑用aws做。 But the problem is that I am unable to find any good tutorial for doing this and I have no idea how to do it. 但是问题是我找不到任何好的教程来做到这一点,而且我也不知道该怎么做。

So could anyone please suggest some tutorial for sending push notification or on how to make a chat application? 因此,有人可以建议一些有关发送推送通知或如何制作聊天应用程序的教程吗?

Check Socket.IO for android. 检查Socket.IO for android。 ( https://github.com/socketio/socket.io-client-java ) https://github.com/socketio/socket.io-client-java

Its really easy to write a chat application. 编写聊天应用程序真的很容易。 But you need a server side. 但是您需要服务器端。 Easy to write a simple server for this chat app. 易于为该聊天应用编写简单的服务器。 Server reveice the all message from clients and broadcast the message, to all. 服务器显示来自客户端的所有消息,并将消息广播给所有人。

Gradle: 摇篮:

compile 'com.github.nkzawa:socket.io-client:0.5.1'

Android manifest: Android清单:

<uses-permission android:name="android.permission.INTERNET" />

Java 爪哇

public static Socket mSocket;
try {
            mSocket = IO.socket("http://192.168.1.104:4444");
            mSocket.connect();
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }

Send messsage to server: 发送消息到服务器:

MainActivity.mSocket.emit("message","Text here...");

Create a listener for another message: 创建另一个消息的侦听器:

MainActivity.mSocket.on("newMessage", onMessageArrive); // Oncreate


private Emitter.Listener onMessageArrive = new Emitter.Listener() {
        @Override
        public void call(final Object... args) {
            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {

                    String data = (String)args[0];
                    // Here is all message. add it to list :) Or Push notif
                }
            });
        }
    };

// Server side: // 服务器端:

var http = require('http');
var express = require('express'),
    app = module.exports.app = express();
var io = require('socket.io').listen(app.listen(4444));

io.on('connection', function (socket) {
  socket.on("message",function(msg){
      io.sockets.emit('newMessage', msg);
  });
});

Run: 跑:

npm install express
npm install socket.io
node filename.js

Just dont forget to check you IP! 只是不要忘记检查您的IP! :) Done! :)完成! You have a Real Time Chat!! 您有实时聊天!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android Studio 中的 Firebase 聊天应用 - Firebase chat app in android studio 我想使用 PHP 开发一个 Android 聊天应用程序。 我该怎么做? 不使用 Google Firebase Cloud Messeging 和 AWS - I want to develop an Android chat app using PHP. How can I do it? without using Google Firebase Cloud Messeging and AWS 聊天应用程序 - 哪种技术更适合在Android中实现聊天应用程序 - Chat application - which tech is better to implement chat app in Android 带有 Recyclerview 的基本 Android 聊天应用启动器 - Basic Android chat app starter with Recyclerview 在Android中使用Socket.io进行聊天应用 - Using Socket.io in android for Chat app 通过android应用限制whatsapp的群聊中的用户 - limit users in group chat of whatsapp by an android app Google App Engine和Android中用于聊天应用程序的XMPP - XMPP in Google App Engine and Android for a chat application 如何在Android应用中实现XMPP聊天? - How to implement XMPP chat in an android app? 将Android App连接到AWS dynamoDB - Connect Android App to AWS dynamoDB 使用特定联系人打开 LINE android 应用程序的聊天屏幕 - Open chat screen of LINE android app with a specific contact
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM