Giter VIP home page Giter VIP logo

imclient's Introduction

IMClient

Android 即时通讯系统客户端

本项目是一个类微信的即时通讯系统,用来实现用户之间即时通讯。 本系统分为Android客户端和后台服务器两个部分。此项目为本系统的Android客户端部分。 客户端实现了登录验证,获取好友列表,向好友发送消息,接收好友消息的功能。用户发送的消息通过Socket发送到服务器,服务器作为中转将消息通过Socket转发到目标用户。

Credits

此项目小组成员为以下5名同学:

  • 覃昌雷
  • 康宗
  • 石岩
  • 姜洪超
  • 冯会会

配置说明

  • 此客户端使用Android Studio 3.1开发。
  • 本即时通讯系统分为Android客户端和后台服务器两个部分。本系统的服务器部分请见:https://github.com/NaCl96/IMServer
  • 由于服务器部署环境不固定,此客户端可以在登录界面中手动输入服务器的IP地址。

功能模块

登录

  • 输入用户ID和密码。通过HTTP将用户ID和密码表单发送到服务器的LoginServlet,LoginServlet返回登录验证结果。如果结果为通过则启动好友列表界面。

好友列表

  • 通过HTTP访问服务器中的FriendServlet来获取当前用户的好友数据。返回数据为JSON格式,对其进行解析,并通过ListView显示好友列表。点击每个列表项进入与该好友的聊天界面。

通信服务

  • IMService为用于与服务器进行Socket通信的后台服务。
  • 通过启动login线程,与服务器建立Socket连接,将用户ID发送到服务器作为该Socket的索引。
  • Check线程每5秒对Socket连接进行一次心跳检查,如果连接断开则进行重启login线程进行重连。
  • sendM线程用于向服务器发送消息,在用户向好友发送消息时被启动。每个消息有发起用户ID、目标用户ID、消息正文三段数据,以JSON格式封装,发送到服务器,由服务器转发到目标用户。
  • recieveM线程循环读取Socket输入流,接收服务器的消息。收到消息时将消息存入SQLite数据库,并通知好友聊天界面更新。

好友聊天

  • 在好友聊天界面中用RecyclerView来显示聊天消息气泡。界面启动时通过SQLite数据库获取当前用户与当前好友的聊天记录,将历史消息加入RecyclerView的绑定的数据集中并更新。
  • 输入消息,点击发送,将消息加入RecyclerView的数据集,同时消息存入SQLite,并同过与IMService绑定的Binder将消息交由IMService来发送。

数据持久化

  • SQLite存储用户聊天记录
  • SharedPreference存储用户ID、用户姓名、用户密码,用来自动登录。

imclient's People

Contributors

nacl96 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.