Skip to content

Commit

Permalink
修复配置
Browse files Browse the repository at this point in the history
  • Loading branch information
朱培杰 committed Dec 21, 2018
1 parent bdb97f3 commit 981b43f
Show file tree
Hide file tree
Showing 8 changed files with 1,088 additions and 716 deletions.
741 changes: 30 additions & 711 deletions firestorm.log

Large diffs are not rendered by default.

1,007 changes: 1,007 additions & 0 deletions firestorm.log.1

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/main/java/com/github/unclecatmyself/Application.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.github.unclecatmyself;

import com.github.unclecatmyself.auto.ConfigFactory;
import com.github.unclecatmyself.auto.InitServer;
import com.github.unclecatmyself.common.bean.InitNetty;
import com.github.unclecatmyself.user.DataBaseServiceImpl;
import com.github.unclecatmyself.user.InChatVerifyServiceImpl;

/**
* Created by MySelf on 2018/12/18.
Expand All @@ -10,6 +13,9 @@ public class Application {

public static void main(String[] args) {
//注册InChat相关配置
ConfigFactory.inChatToDataBaseService = new DataBaseServiceImpl();
ConfigFactory.inChatVerifyService = new InChatVerifyServiceImpl();

InitServer initServer = new InitServer(new InitNetty());
initServer.open();
//预制InChat的用户接口
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/com/github/unclecatmyself/auto/ConfigFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.github.unclecatmyself.auto;

import com.github.unclecatmyself.bootstrap.data.InChatToDataBaseService;
import com.github.unclecatmyself.bootstrap.verify.InChatVerifyService;

/**
* 默认配置工厂
* Created by MySelf on 2018/12/21.
*/
public class ConfigFactory {

public static InChatVerifyService inChatVerifyService;

public static InChatToDataBaseService inChatToDataBaseService;

public InChatVerifyService getInChatVerifyService() {
return inChatVerifyService;
}

public void setInChatVerifyService(InChatVerifyService inChatVerifyService) {
this.inChatVerifyService = inChatVerifyService;
}

public InChatToDataBaseService getInChatToDataBaseService() {
return inChatToDataBaseService;
}

public void setInChatToDataBaseService(InChatToDataBaseService inChatToDataBaseService) {
this.inChatToDataBaseService = inChatToDataBaseService;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.github.unclecatmyself.bootstrap;


import com.github.unclecatmyself.auto.ConfigFactory;
import com.github.unclecatmyself.bootstrap.channel.WebSocketHandlerService;
import com.github.unclecatmyself.bootstrap.handler.DefaultWebSocketHandler;
import com.github.unclecatmyself.common.bean.InitNetty;
import com.github.unclecatmyself.task.DataAsynchronousTask;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
Expand All @@ -23,7 +25,7 @@ public abstract class AbstractBootstrapServer implements BootstrapServer {
protected void initHandler(ChannelPipeline channelPipeline, InitNetty serverBean){
intProtocolHandler(channelPipeline,serverBean);
channelPipeline.addLast(new IdleStateHandler(serverBean.getHeart(),0,0));
channelPipeline.addLast(new DefaultWebSocketHandler(new WebSocketHandlerService()));
channelPipeline.addLast(new DefaultWebSocketHandler(new WebSocketHandlerService(new DataAsynchronousTask(ConfigFactory.inChatToDataBaseService),ConfigFactory.inChatVerifyService)));
}

private void intProtocolHandler(ChannelPipeline channelPipeline,InitNetty serverBean){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@
*/
public class WebSocketHandlerService extends ServerWebSocketHandlerService {

private final InChatVerifyService inChatVerifyService = new InChatVerifyServiceImpl();
private final InChatVerifyService inChatVerifyService;

private final InChatBackMapService inChatBackMapService = new InChatBackMapServiceImpl();

private final WsChannelService websocketChannelService = new WebSocketChannelService();

private final DataAsynchronousTask dataAsynchronousTask = new DataAsynchronousTask();
private final DataAsynchronousTask dataAsynchronousTask;

public WebSocketHandlerService() {
public WebSocketHandlerService(DataAsynchronousTask dataAsynchronousTask,InChatVerifyService inChatVerifyService) {
this.dataAsynchronousTask = dataAsynchronousTask;
this.inChatVerifyService = inChatVerifyService;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
public interface WebSocketHandlerApi {


void close(Channel channel);

void sendMeText(Channel channel, Map<String,Object> maps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ public class DataAsynchronousTask {

private final Logger log = LoggerFactory.getLogger(DataAsynchronousTask.class);

private final InChatToDataBaseService inChatToDataBaseService = new DataBaseServiceImpl();
private final InChatToDataBaseService inChatToDataBaseService;

public DataAsynchronousTask(InChatToDataBaseService inChatToDataBaseService){
this.inChatToDataBaseService = inChatToDataBaseService;
}

public void writeData(Map<String,Object> maps) throws Exception {
log.info("【异步写入数据】");
Expand Down

0 comments on commit 981b43f

Please sign in to comment.