send http
parent
be52cac2bb
commit
99d2828a6c
|
@ -89,6 +89,7 @@ public class GameApplication {
|
||||||
MapLogic.getInstance().init(configurableApplicationContext);
|
MapLogic.getInstance().init(configurableApplicationContext);
|
||||||
|
|
||||||
SensitivewordFilter.init();
|
SensitivewordFilter.init();
|
||||||
|
HttpPool.init();
|
||||||
|
|
||||||
// 加载lua文件
|
// 加载lua文件
|
||||||
CheckFight.getInstance().init("luafight/BattleMain.lua");
|
CheckFight.getInstance().init("luafight/BattleMain.lua");
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package com.ljsd.jieling.config.reportData;
|
package com.ljsd.jieling.config.reportData;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.ljsd.common.mogodb.util.BlockingUniqueQueue;
|
import com.ljsd.common.mogodb.util.BlockingUniqueQueue;
|
||||||
|
import com.ljsd.jieling.ktbeans.KTSendBody;
|
||||||
import com.ljsd.jieling.util.http.HttpPool;
|
import com.ljsd.jieling.util.http.HttpPool;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
@ -11,39 +14,25 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
public class DataMessageUtils {
|
public class DataMessageUtils {
|
||||||
|
|
||||||
static final BlockingQueue<Object> logQueue = new BlockingUniqueQueue<>();
|
static final BlockingQueue<Object> logQueue = new BlockingUniqueQueue<>();
|
||||||
static List<String> dataList = new CopyOnWriteArrayList<>();
|
private static Gson gson = new Gson();
|
||||||
|
private static final String sendUrl = "https://gskuld.receiver.extranet.kt007.com:8081/skuld/game/common/";
|
||||||
//入队列
|
//入队列
|
||||||
public static void addLogQueue(Object info){
|
public static void addLogQueue(Object info){
|
||||||
logQueue.offer(info);
|
logQueue.offer(info);
|
||||||
}
|
}
|
||||||
//出队列
|
|
||||||
public static Object take(){
|
|
||||||
try {
|
|
||||||
return logQueue.take();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void manageData(Object take) {
|
public static void manageData() {
|
||||||
List<String> sendDataList;
|
List<Object> sendDataList = new ArrayList<>(10);
|
||||||
if(dataList.size() >= 10){
|
logQueue.drainTo(sendDataList,10);
|
||||||
sendDataList = dataList;
|
if(sendDataList.isEmpty()){
|
||||||
dataList = new CopyOnWriteArrayList<>();
|
try {
|
||||||
}else{
|
Thread.sleep(10);
|
||||||
dataList.add(JSON.toJSONString(take));
|
return;
|
||||||
return;
|
} catch (InterruptedException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
StringBuilder info = new StringBuilder("[");
|
|
||||||
for (int i =0 ; i < sendDataList.size() ; i++){
|
|
||||||
if (i >= (sendDataList.size() -1)){
|
|
||||||
info.append(sendDataList.get(i)).append(",");
|
|
||||||
}else{
|
|
||||||
info.append(sendDataList.get(i));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info.append("]");
|
KTSendBody sendBody = new KTSendBody(gson.toJson(sendDataList));
|
||||||
HttpPool.sendPost("",info.toString());
|
// HttpPool.sendPost(sendUrl,gson.toJson(sendBody));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class KtEventUtils {
|
||||||
|
|
||||||
|
|
||||||
public static void onKtEvent(User user,int eventType,Object ...parm){
|
public static void onKtEvent(User user,int eventType,Object ...parm){
|
||||||
/* ParamEventBean paramEventBean = new ParamEventBean(eventType);
|
ParamEventBean paramEventBean = new ParamEventBean(eventType);
|
||||||
switch (eventType){
|
switch (eventType){
|
||||||
case ParamEventBean.UserActivityEvent:
|
case ParamEventBean.UserActivityEvent:
|
||||||
int activityId = (int)parm[0];
|
int activityId = (int)parm[0];
|
||||||
|
@ -92,10 +92,9 @@ public class KtEventUtils {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KTParam ktParam = ParamBuilder.paramBuild(user, eventType, paramEventBean);
|
/* KTParam ktParam = ParamBuilder.paramBuild(user, eventType, paramEventBean);
|
||||||
DataMessageUtils.addLogQueue(ktParam);
|
DataMessageUtils.addLogQueue(ktParam);
|
||||||
LOGGER.info("ktparm -- > {}",gson.toJson(ktParam));
|
LOGGER.info("ktparm -- > {}",gson.toJson(ktParam));*/
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
public static ParamEnvironmentBean enviromentBuild(int uid){
|
public static ParamEnvironmentBean enviromentBuild(int uid){
|
||||||
return KTEnvironmentUtil.getUserEnviromentInfoById(uid);
|
return KTEnvironmentUtil.getUserEnviromentInfoById(uid);
|
||||||
|
|
|
@ -37,7 +37,8 @@ public class ThreadManager {
|
||||||
public void init(ConfigurableApplicationContext configurableApplicationContext) {
|
public void init(ConfigurableApplicationContext configurableApplicationContext) {
|
||||||
|
|
||||||
platConfigureTask = configurableApplicationContext.getBean(PlatConfigureTask.class);
|
platConfigureTask = configurableApplicationContext.getBean(PlatConfigureTask.class);
|
||||||
dataReportTask = configurableApplicationContext.getBean(DataReportTask.class);
|
DataReportTask dataReportTask = new DataReportTask();
|
||||||
|
dataReportTask.start();
|
||||||
go();
|
go();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,9 +84,6 @@ public class ThreadManager {
|
||||||
int delayForMinute = 60 - (now%60);
|
int delayForMinute = 60 - (now%60);
|
||||||
LOGGER.info("delayForMinute---->>>>{}" ,delayForMinute);
|
LOGGER.info("delayForMinute---->>>>{}" ,delayForMinute);
|
||||||
scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
|
scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
|
||||||
|
|
||||||
scheduledExecutor.scheduleAtFixedRate(dataReportTask, 10, SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
scheduledExecutor.scheduleAtFixedRate(new MinuteTask(), delayForMinute, 60, TimeUnit.SECONDS);
|
scheduledExecutor.scheduleAtFixedRate(new MinuteTask(), delayForMinute, 60, TimeUnit.SECONDS);
|
||||||
scheduledExecutor.scheduleAtFixedRate(new Thread(){
|
scheduledExecutor.scheduleAtFixedRate(new Thread(){
|
||||||
public void run () {
|
public void run () {
|
||||||
|
|
|
@ -5,13 +5,15 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
@Component
|
public class DataReportTask extends Thread {
|
||||||
public class DataReportTask implements Runnable {
|
|
||||||
|
public DataReportTask(){
|
||||||
|
setName("DataReportTaskThread");
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (true) {
|
while (true) {
|
||||||
Object take = DataMessageUtils.take();
|
DataMessageUtils.manageData();
|
||||||
DataMessageUtils.manageData(take);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// public static void startTlogThread(){
|
// public static void startTlogThread(){
|
||||||
|
|
|
@ -21,6 +21,7 @@ public class HttpPool {
|
||||||
private static int maxSendTimes = 2;
|
private static int maxSendTimes = 2;
|
||||||
private static int sendIntervalTime = 1000;
|
private static int sendIntervalTime = 1000;
|
||||||
private static String charset = "UTF-8";
|
private static String charset = "UTF-8";
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
poolConnection.setMaxTotal(100);
|
poolConnection.setMaxTotal(100);
|
||||||
poolConnection.setDefaultMaxPerRoute(100);
|
poolConnection.setDefaultMaxPerRoute(100);
|
||||||
|
@ -33,6 +34,7 @@ public class HttpPool {
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void sendPost(String url, String info) {
|
public static void sendPost(String url, String info) {
|
||||||
|
LOGGER.info("the data={}",info);
|
||||||
HttpPost httpPost = new HttpPost(url);
|
HttpPost httpPost = new HttpPost(url);
|
||||||
HttpResponse httpResponse;
|
HttpResponse httpResponse;
|
||||||
int sendTimes = 0;
|
int sendTimes = 0;
|
||||||
|
@ -41,8 +43,8 @@ public class HttpPool {
|
||||||
StringEntity stringEntity = new StringEntity(info, charset);
|
StringEntity stringEntity = new StringEntity(info, charset);
|
||||||
httpPost.setEntity(stringEntity);
|
httpPost.setEntity(stringEntity);
|
||||||
httpPost.setConfig(getRequestConfig());
|
httpPost.setConfig(getRequestConfig());
|
||||||
|
httpPost.setHeader("Content-Type","application/json;charset=utf-8");
|
||||||
httpResponse = httpclient.execute(httpPost);
|
httpResponse = httpclient.execute(httpPost);
|
||||||
// retStr = EntityUtils.toString(responseEntity, charset);
|
|
||||||
HttpEntity responseEntity = httpResponse.getEntity();
|
HttpEntity responseEntity = httpResponse.getEntity();
|
||||||
EntityUtils.consume(responseEntity);
|
EntityUtils.consume(responseEntity);
|
||||||
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
||||||
|
@ -71,7 +73,8 @@ public class HttpPool {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main (String [] args){
|
public static void main (String [] args){
|
||||||
|
String send ="{\"gid\":\"129213\",\"time\":1562306610,\"sign\":\"10a518836c856344a00a97f0299b7cb0\",\"jsonStrs\":\"[{\\\"param_environment\\\":{},\\\"param_user\\\":{\\\"account_id_s\\\":\\\"10004165\\\"},\\\"param_role\\\":{\\\"role_id_s\\\":\\\"10004165\\\",\\\"role_name_s\\\":\\\"10004165\\\",\\\"level_i\\\":\\\"1\\\",\\\"vip_level_i\\\":0},\\\"param_event\\\":{\\\"event_s\\\":[\\\"currency_3_l\\\",\\\"source\\\",\\\"15\\\",\\\"19\\\",\\\"1\\\"]}},{\\\"param_environment\\\":{},\\\"param_user\\\":{\\\"account_id_s\\\":\\\"10004165\\\"},\\\"param_role\\\":{\\\"role_id_s\\\":\\\"10004165\\\",\\\"role_name_s\\\":\\\"10004165\\\",\\\"level_i\\\":\\\"1\\\",\\\"vip_level_i\\\":0},\\\"param_event\\\":{\\\"event_s\\\":[\\\"currency_3_l\\\",\\\"source\\\",\\\"15\\\",\\\"1001\\\",\\\"6000\\\"]}},{\\\"param_environment\\\":{},\\\"param_user\\\":{\\\"account_id_s\\\":\\\"10004165\\\"},\\\"param_role\\\":{\\\"role_id_s\\\":\\\"10004165\\\",\\\"role_name_s\\\":\\\"10004165\\\",\\\"level_i\\\":\\\"1\\\",\\\"vip_level_i\\\":0},\\\"param_event\\\":{\\\"event_s\\\":[\\\"currency_3_l\\\",\\\"source\\\",\\\"15\\\",\\\"28\\\",\\\"2\\\"]}},{\\\"param_environment\\\":{},\\\"param_user\\\":{\\\"account_id_s\\\":\\\"10004165\\\"},\\\"param_role\\\":{\\\"role_id_s\\\":\\\"10004165\\\",\\\"role_name_s\\\":\\\"10004165\\\",\\\"level_i\\\":\\\"1\\\",\\\"vip_level_i\\\":0},\\\"param_event\\\":{\\\"event_s\\\":[\\\"currency_3_l\\\",\\\"source\\\",\\\"15\\\",\\\"10046\\\",\\\"1\\\"]}},{\\\"param_environment\\\":{},\\\"param_user\\\":{\\\"account_id_s\\\":\\\"10004165\\\"},\\\"param_role\\\":{\\\"role_id_s\\\":\\\"10004165\\\",\\\"role_name_s\\\":\\\"10004165\\\",\\\"level_i\\\":\\\"1\\\",\\\"vip_level_i\\\":0},\\\"param_event\\\":{\\\"event_s\\\":[\\\"currency_3_l\\\",\\\"source\\\",\\\"29\\\",\\\"27\\\",\\\"3\\\"]}},{\\\"param_environment\\\":{},\\\"param_user\\\":{\\\"account_id_s\\\":\\\"10004165\\\"},\\\"param_role\\\":{\\\"role_id_s\\\":\\\"10004165\\\",\\\"role_name_s\\\":\\\"10004165\\\",\\\"level_i\\\":\\\"1\\\",\\\"vip_level_i\\\":0},\\\"param_event\\\":{\\\"event_s\\\":[\\\"currency_3_l\\\",\\\"source\\\",\\\"29\\\",\\\"44\\\",\\\"10\\\"]}},{\\\"param_environment\\\":{},\\\"param_user\\\":{\\\"account_id_s\\\":\\\"10004165\\\"},\\\"param_role\\\":{\\\"role_id_s\\\":\\\"10004165\\\",\\\"role_name_s\\\":\\\"10004165\\\",\\\"level_i\\\":\\\"1\\\",\\\"vip_level_i\\\":0},\\\"param_event\\\":{\\\"event_s\\\":[\\\"register_0\\\"]}},{\\\"param_environment\\\":{\\\"wifi_b\\\":false},\\\"param_user\\\":{\\\"user_id_s\\\":\\\"24324\\\",\\\"account_id_s\\\":\\\"10004165\\\"},\\\"param_role\\\":{\\\"role_id_s\\\":\\\"10004165\\\",\\\"role_name_s\\\":\\\"10004165\\\",\\\"level_i\\\":\\\"1\\\",\\\"vip_level_i\\\":0},\\\"param_event\\\":{\\\"event_s\\\":[\\\"login_1\\\",\\\"LOGOUT\\\"]}}]\"}";
|
||||||
init();
|
init();
|
||||||
sendPost("http://60.1.1.212:8080","111111111");
|
sendPost("https://gskuld.receiver.extranet.kt007.com:8081/skuld/game/common/",send);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue