Skip to content

Commit

Permalink
Version 0.6.0
Browse files Browse the repository at this point in the history
Group Chat!!!
  • Loading branch information
realJustinLee committed Feb 21, 2019
1 parent 3191e2b commit 468936b
Show file tree
Hide file tree
Showing 42 changed files with 141 additions and 63 deletions.
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ LiMe is a communication app which allows you to send messages whenever and where
The Li Xin Messenger

## Version
- C_v 0.5
- S_v 0.5
- C_v 0.6.0
- S_v 0.6.0

```
_______________________
/ Finally, v_0.5! \
/ Finally, v_0.6! \
| _ _ __ __ |
| | | (_) \/ | ___ |
| | | | | |\/| |/ _ \ |
Expand Down Expand Up @@ -43,28 +43,38 @@ The Register GUI

![](./ScreenShots/LiMeRegister.png)

The Chat GUI of user @Lixin, the friend list is on the left side of the panel
The User Agreement (HTML parsing)

![](./ScreenShots/LiMeAgreement.png)

The Chat GUI of user @lixin, the friend list is on the left side of the panel
![](./ScreenShots/LiMeChatLixin.png)

The Chat GUI of user @Test

![](./ScreenShots/LiMeChatTest.png)

## The File Transmission
### The Group Chat

![](./ScreenShots/LiMeChatTest.png)

### The File Transmission

![](./ScreenShots/LiMeGroupChat.png)

![](./ScreenShots/LiMeChatFile.png)
## Data persistence

## Data persistence and user management
MySQL table structure

MySQL
![](./ScreenShots/TableStructure.png)

## TODO
- [ ] Gradle the project
- [ ] Use HTML to render the email content
- [ ] Use hibernate or Mybatis as a persistence framework
- [ ] The process bar for the file transmission
- [ ] Open group chat for all users
- [ ] A fancy website for LiMe
- [X] Open group chat for all users
- [x] Enable user to reset password via a server-sent Email
- [x] Redirect LiMe to the new domain name
- [x] Email is should be a unique key (LiMeSeedRecoverPassword)
Expand Down
Binary file added ScreenShots/LiMeAgreement.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ScreenShots/LiMeChatFile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ScreenShots/LiMeChatLixin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ScreenShots/LiMeChatTest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ScreenShots/LiMeGroupChat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ScreenShots/LiMeLogin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ScreenShots/LiMeRegister.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ScreenShots/LiMeServer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ScreenShots/TableStructure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified out/.DS_Store
Binary file not shown.
Binary file modified out/artifacts/.DS_Store
Binary file not shown.
Binary file modified out/artifacts/LiMeServer_jar/LiMeServer.jar
Binary file not shown.
Binary file modified out/artifacts/LiMe_jar/LiMe.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manifest-Version: 0.5.2
Manifest-Version: 0.6.0
Main-Class: com.lixin.lime.LiMe

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified out/production/LiMe/com/lixin/lime/client/model/LiMeModel.class
Binary file not shown.
Binary file not shown.
Binary file modified out/production/LiMe/com/lixin/lime/protocol/seed/LiMeSeed.class
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manifest-Version: 0.5.2
Manifest-Version: 0.6.0
Main-Class: com.lixin.lime.LiMeServer

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion src/com/lixin/lime/client/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manifest-Version: 0.5.2
Manifest-Version: 0.6.0
Main-Class: com.lixin.lime.LiMe

25 changes: 22 additions & 3 deletions src/com/lixin/lime/client/controller/LiMeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.HashMap;
import java.util.HashSet;

import static com.lixin.lime.protocol.seed.LiMeSeed.LIME_GROUP_CHAT;
import static com.lixin.lime.protocol.util.factory.MyStaticFactory.*;

/**
Expand Down Expand Up @@ -65,7 +66,7 @@ public LiMeController() {
private void initialize() {
// 测试版本
try {
model = new LiMeModel(HOST, PORT, this);
model = new LiMeModel(HOST, PORT, this, this);
initLoginFrame();
model.connectToServer();
} catch (LiMeException e) {
Expand Down Expand Up @@ -93,6 +94,11 @@ private void initChatFrame() {
chatFrame.getButtonLogout().addActionListener(this);
chatFrame.getButtonSendFile().addActionListener(this);
chatFrame.getButtonSendMessage().addActionListener(this);

HashMap<String, String> history = chatFrame.getHistory();
history.put(LIME_GROUP_CHAT, "");
// Update UI from history
chatFrame.updateTextAreaHistory();
}

private void encryptAndWriteToFile(File file, String username, String password) {
Expand Down Expand Up @@ -324,6 +330,9 @@ public void newFriendList(LiMeSeed seed) {
}
// Remove ex-friends from oldList
for (String friend : friendList) {
if (friend.equals(LIME_GROUP_CHAT)) {
continue;
}
if (!newFriendList.contains(friend)) {
history.remove(friend);
}
Expand Down Expand Up @@ -382,7 +391,17 @@ public void handleLiMeException(LiMeException e) {
}

@Override
public void newGroupChat(String sender, String time, String message) {

public void newGroupChat(LiMeSeed seed) {
if (seed.getSender().equals(username)) {
return;
}
LiMeSeedMessage seedMessage = (LiMeSeedMessage) seed;
String message = seedMessage.getMessage();
String time = seedMessage.getTime();
HashMap<String, String> history = chatFrame.getHistory();
String msgLog = history.get(LIME_GROUP_CHAT) + "< " + seed.getSender() + " > | < " + time + " >\n" + message + "\n\n";
history.put(LIME_GROUP_CHAT, msgLog);
// Update UI from history
chatFrame.updateTextAreaHistory();
}
}
8 changes: 4 additions & 4 deletions src/com/lixin/lime/client/controller/LiMeKnight.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.lixin.lime.client.controller;

import com.lixin.lime.protocol.seed.LiMeSeed;

/**
* @author lixin
*/
public interface LiMeKnight {
/**
* 接收到新的信息,显示在屏幕上
*
* @param sender 发信方
* @param time 时间戳
* @param message 信息
* @param seed 承载信息的 LiMeSeed
*/
void newGroupChat(String sender, String time, String message);
void newGroupChat(LiMeSeed seed);
}
11 changes: 9 additions & 2 deletions src/com/lixin/lime/client/model/LiMeModel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.lixin.lime.client.model;

import com.lixin.lime.client.controller.LiMeFarmer;
import com.lixin.lime.client.controller.LiMeKnight;
import com.lixin.lime.protocol.exception.LiMeException;
import com.lixin.lime.protocol.seed.*;
import com.lixin.lime.protocol.util.factory.LiMeExceptionFactory;
Expand All @@ -23,6 +24,7 @@ public class LiMeModel {
private String host;
private int port;
private LiMeFarmer farmer;
private LiMeKnight knight;

private Socket socket;
private ObjectOutputStream oos;
Expand All @@ -38,10 +40,11 @@ public class LiMeModel {
private ExecutorService cachedThreadPool;
private LiMeExceptionFactory exceptionFactory;

public LiMeModel(String host, int port, LiMeFarmer farmer) {
public LiMeModel(String host, int port, LiMeFarmer farmer, LiMeKnight knight) {
this.host = host;
this.port = port;
this.farmer = farmer;
this.knight = knight;
cachedThreadPool = Executors.newCachedThreadPool();
exceptionFactory = new LiMeExceptionFactory();
}
Expand Down Expand Up @@ -147,7 +150,11 @@ public void run() {
// 被踢
throw exceptionFactory.newLiMeException(ERROR_ADMIN_KICKED);
case MESSAGE:
farmer.newLiMeMessage(seed);
if (seed.getReceiver().equals(LIME_GROUP_CHAT)) {
knight.newGroupChat(seed);
} else {
farmer.newLiMeMessage(seed);
}
break;
case FRIENDS_UPDATE:
farmer.newFriendList(seed);
Expand Down
1 change: 1 addition & 0 deletions src/com/lixin/lime/protocol/seed/LiMeSeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class LiMeSeed implements Serializable {
public static final int STATUS_LOGIN_SUCCESS = 9;
public static final int STATUS_REGISTER_SUCCESS = 10;

public static final String LIME_GROUP_CHAT = "[ LiMe Group Chat ]";

private int action;
private String sender;
Expand Down
6 changes: 3 additions & 3 deletions src/com/lixin/lime/protocol/util/factory/MyStaticFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public class MyStaticFactory {
public static final String THE_TITLE = "Lixin Messenger";
public static final String THE_BRAND = "LiMe";
public static final String THE_AUTHOR = "Lixin";
public static final String THE_COPYRIGHT = "™ and © 2015-" + getLiMeYear() + " " + THE_AUTHOR + ". All Rights Reserved.";
public static final String THE_LIME_VERSION = "C_v 0.5.2";
public static final String THE_COPYRIGHT = "™ and © 1997-" + getLiMeYear() + " " + THE_AUTHOR + ". All Rights Reserved.";
public static final String THE_LIME_VERSION = "C_v 0.6.0";

public static final String THE_SERVER_TITLE = THE_TITLE + " Server";
public static final String THE_SERVER_BRAND = THE_BRAND + " Server";
public static final String THE_SERVER_VERSION = "S_v 0.5.2";
public static final String THE_SERVER_VERSION = "S_v 0.6.0";

/**
* The Actions
Expand Down
2 changes: 1 addition & 1 deletion src/com/lixin/lime/server/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manifest-Version: 0.5.2
Manifest-Version: 0.6.0
Main-Class: com.lixin.lime.LiMeServer

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lixin.lime.server.controller;

import com.lixin.lime.protocol.seed.LiMeSeed;
import com.lixin.lime.server.view.LiMeServerFrame;
import com.lixin.lime.server.model.LiMeServerModel;

Expand Down Expand Up @@ -35,7 +36,7 @@ public LiMeServerController() {
*/
private void initialize() {
initServerFrame();
serverModel = new LiMeServerModel(this);
serverModel = new LiMeServerModel(this, this);
cachedThreadPool = Executors.newCachedThreadPool();
}

Expand Down Expand Up @@ -112,8 +113,8 @@ public void enablePrivileges(boolean bool) {
}

@Override
public void newChatHistory(String sender, String time, String message) {
serverFrame.appendHistory("< " + sender + " > | < " + time + " >\n" + message + "\n");
public void newChatHistory(LiMeSeed seed) {
serverFrame.appendHistory("< " + seed.getSender() + " > | < " + seed.getTime() + " >\n" + seed.getMessage() + "\n\n");
}
}

9 changes: 8 additions & 1 deletion src/com/lixin/lime/server/controller/LiMeServerKnight.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package com.lixin.lime.server.controller;

import com.lixin.lime.protocol.seed.LiMeSeed;

/**
* @author lixin
*/
public interface LiMeServerKnight {
void newChatHistory(String sender, String time, String message);
/**
* 接收到新的信息,显示在屏幕上
*
* @param seed 承载信息的 LiMeSeed
*/
void newChatHistory(LiMeSeed seed);
}
6 changes: 1 addition & 5 deletions src/com/lixin/lime/server/dao/MyDatabaseConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MyDatabaseConnector {
private Statement statement;
private ResultSet resultSet;

public MyDatabaseConnector(String host, int port, String database, String username, String password) {
public MyDatabaseConnector(String host, int port, String database, String username, String password) throws SQLException {
String url = "jdbc:mysql://" + host + ":" + port + "/" + database + "?" + "User=" + username +
"&password=" + password + "&useUnicode=true&characterEncoding=UTF8&useSSL=true" +
"&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
Expand All @@ -27,10 +27,6 @@ public MyDatabaseConnector(String host, int port, String database, String userna
System.err.println("Database driver loading failure.");
e.printStackTrace();
System.exit(0);
} catch (SQLException e) {
System.err.println("Database connection failure.");
e.printStackTrace();
System.exit(0);
}
}

Expand Down
Loading

0 comments on commit 468936b

Please sign in to comment.