Commit e135a20734d9c68795d46ba7ae1f772ed60804ac

Authored by 刘基城
2 parents b1c8cd5c cfb6cdff

Merge branch 'master' of http://bj.gitlab.cnlive.com/liujicheng/cnlive_live_web

# Conflicts:
#	src/main/java/com/cnlive/mz/live/action/UgcLiveAction.java
#	src/main/java/com/cnlive/socket/TE.java
#	target/m2e-wtp/web-resources/META-INF/maven/com.cnlive.mz.live.web/cnlive_live_web/pom.properties
.classpath
... ... @@ -24,7 +24,7 @@
24 24 <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
25 25 </attributes>
26 26 </classpathentry>
27   - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
  27 + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
28 28 <attributes>
29 29 <attribute name="maven.pomderived" value="true"/>
30 30 </attributes>
... ...
.settings/org.eclipse.core.resources.prefs
1   -eclipse.preferences.version=1
2   -encoding//src/main/java=UTF-8
3   -encoding//src/main/resources=UTF-8
4   -encoding/<project>=UTF-8
  1 +eclipse.preferences.version=1
  2 +encoding//src/main/java=UTF-8
  3 +encoding//src/main/resources=UTF-8
  4 +encoding//src/test/java=UTF-8
  5 +encoding/<project>=UTF-8
... ...
.settings/org.eclipse.jdt.core.prefs
1   -eclipse.preferences.version=1
2   -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3   -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
4   -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
5   -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6   -org.eclipse.jdt.core.compiler.compliance=1.6
7   -org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8   -org.eclipse.jdt.core.compiler.debug.localVariable=generate
9   -org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10   -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11   -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12   -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
13   -org.eclipse.jdt.core.compiler.source=1.6
  1 +eclipse.preferences.version=1
  2 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
  3 +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
  4 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
  5 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
  6 +org.eclipse.jdt.core.compiler.compliance=1.7
  7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate
  8 +org.eclipse.jdt.core.compiler.debug.localVariable=generate
  9 +org.eclipse.jdt.core.compiler.debug.sourceFile=generate
  10 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
  11 +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
  12 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
  13 +org.eclipse.jdt.core.compiler.source=1.7
... ...
.settings/org.eclipse.wst.common.project.facet.core.xml
... ... @@ -3,5 +3,5 @@
3 3 <installed facet="jst.web" version="3.0"/>
4 4 <installed facet="wst.jsdt.web" version="1.0"/>
5 5 <installed facet="jst.jaxrs" version="1.1"/>
6   - <installed facet="java" version="1.6"/>
  6 + <installed facet="java" version="1.7"/>
7 7 </faceted-project>
... ...
... ... @@ -24,8 +24,8 @@
24 24 <artifactId>maven-compiler-plugin</artifactId>
25 25 <version>2.5.1</version>
26 26 <configuration>
27   - <source>1.6</source>
28   - <target>1.6</target>
  27 + <source>1.7</source>
  28 + <target>1.7</target>
29 29 </configuration>
30 30 </plugin>
31 31 </plugins>
... ...
src/main/java/com/cnlive/mz/live/action/LiveAction.java
1   -/**
2   - * Project Name:cnlive_live_web
3   - * File Name:RoomAction.java
4   - * Package Name:com.cnlive.mz.live.action
5   - * Date:2016年4月25日下午1:12:48
6   - * Copyright (c) 2016, cnlive.com All Rights Reserved.
7   - *
8   - */
9   -
10   -package com.cnlive.mz.live.action;
11   -
12   -import java.io.IOException;
13   -import java.io.UnsupportedEncodingException;
14   -import java.util.HashMap;
15   -import java.util.List;
16   -import java.util.Map;
17   -
18   -import javax.servlet.http.HttpServletResponse;
19   -
20   -import org.apache.commons.lang.StringUtils;
21   -import org.apache.log4j.Logger;
22   -import org.smart4j.framework.dao.bean.Pager;
23   -import org.smart4j.framework.ioc.annotation.Inject;
24   -import org.smart4j.framework.mvc.DataContext;
25   -import org.smart4j.framework.mvc.annotation.Action;
26   -import org.smart4j.framework.mvc.annotation.Request;
27   -import org.smart4j.framework.mvc.bean.Multipart;
28   -import org.smart4j.framework.mvc.bean.Multiparts;
29   -import org.smart4j.framework.mvc.bean.Params;
30   -import org.smart4j.framework.mvc.bean.Redirect;
31   -import org.smart4j.framework.mvc.bean.Result;
32   -import org.smart4j.framework.mvc.bean.ResultBean;
33   -import org.smart4j.framework.mvc.bean.View;
34   -import org.smart4j.framework.util.CastUtil;
35   -
36   -import com.cnlive.mz.commons.Constants;
37   -import com.cnlive.mz.commons.net.HttpReq;
38   -import com.cnlive.mz.live.common.LiveUtils;
39   -import com.cnlive.mz.live.entity.TChannel;
40   -import com.cnlive.mz.live.entity.TLive;
41   -import com.cnlive.mz.live.entity.TRoom;
42   -import com.cnlive.mz.live.service.TCheckService;
43   -import com.cnlive.mz.live.service.TLiveService;
44   -import com.cnlive.mz.live.service.TRoomService;
45   -
46   -/**
47   - * TODO: 机构主播和个人主播发起直播活动 <br/>
48   - * Date: 2016年4月25日 下午1:12:48 <br/>
49   - *
50   - * @author liujicheng
51   - * @version V1.0
52   - * @since JDK 1.6
53   - */
54   -@Action
55   -public class LiveAction {
56   -
57   - private Logger log = Logger.getLogger("LiveAction");
58   - @Inject
59   - private TLiveService tLiveService;
60   - @Inject
61   - private TRoomService tRoomService;
62   - @Inject
63   - private TCheckService tCheckService;
64   -
65   - @Request.Get("/live/preload")
66   - public View preload() {
67   - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
68   - View view = new View("live/live_add.jsp");
69   - List<TRoom> tRooms = tRoomService.getTRooms(user_id);
70   - view.data("tRooms", tRooms);
71   - return view;
72   - }
73   -
74   - @Request.Get("/live/list/{page_number}")
75   - public View list(int page_number) {
76   - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
77   - System.out.println(user_id);
78   - Pager<TLive> tLive = tLiveService.getTLivePager(page_number, Constants.PAGE_SIZE, user_id);
79   - return new View("live/live_management.jsp").data("tLive", tLive);
80   - }
81   -
82   - @Request.Post("/live/save")
83   - public Result saveLive(Params params, Multiparts multiparts) {
84   - System.out.println(params + "....and....." + multiparts);
85   - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
86   - Multipart multipart = multiparts.getOne();
87   - tLiveService.add(user_id, params, multipart);
88   - return new Result(false);
89   - }
90   -
91   - @Request.Get("/live/edit/{id}")
92   - public View edit(int id) {
93   - TLive tLive = tLiveService.getTLiveById(id);
94   - TRoom tRoom = tRoomService.getTRoomById(Integer.parseInt(tLive.getLive_room_id()));
95   - List<TRoom> list = tRoomService.getTRooms(tLive.getT_user_id());
96   - View view = new View("live/live_edit.jsp");
97   - view.data("tActivity", tLive);
98   - view.data("tRoom", tRoom);
99   - view.data("tRooms", list);
100   - return view;
101   - }
102   -
103   - //
104   - @Request.Get("/live/preview/{id}")
105   - public View preview(int id) {
106   - TLive tLive = tLiveService.getTLiveById(id);
107   - TRoom tRoom = tRoomService.getTRoomById(Integer.parseInt(tLive.getLive_room_id()));
108   - View view = new View("live/live_preview.jsp");
109   - view.data("tLive", tLive);
110   - view.data("tRoom", tRoom);
111   - return view;
112   - }
113   -
114   - @Request.Get("/live/alllive/{page_number}")
115   - public View liveList(int page_number) {
116   - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
117   - Pager<TLive> tLive = tLiveService.getAllTLivePager(page_number, Constants.PAGE_SIZE);
118   - return new View("live/all_live_management.jsp").data("tLive", tLive);
119   - }
120   -
121   - @Request.Get("/live/search/{page_number}")
122   - public View search(int page_number, Params params) {
123   - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
124   - System.out.println(user_id);
125   - System.out.println("...parmas..." + params);
126   - String t_user_id = params.getString("search_user_id");
127   - String title = params.getString("search_title");
128   -
129   - try {
130   - title = new String(title.trim().getBytes("ISO-8859-1"), "utf-8");
131   - System.out.println("...title.." + title);
132   - } catch (UnsupportedEncodingException e) {
133   - e.printStackTrace();
134   - }
135   -
136   - Pager<TLive> tLive = tLiveService.getTLiveAllPager(page_number, Constants.PAGE_SIZE, t_user_id, title);
137   - System.out.println("tLive=====" + tLive);
138   - return new View("live/all_live_management.jsp").data("tLive", tLive);
139   - }
140   -
141   - public static void main(String[] args) {
142   -
143   - /*
144   - * NameValuePair[] nvp = new NameValuePair[6]; NameValuePair nv1 = new
145   - * NameValuePair(); nv1.setName("appId"); nv1.setValue("123"); nvp[0] =
146   - * nv1; NameValuePair nv2 = new NameValuePair();
147   - * nv2.setName("activityId"); nv2.setValue("234e"); nvp[1] = nv2;
148   - * NameValuePair nv3 = new NameValuePair(); nv3.setName("activityName");
149   - * nv3.setValue("ee"); nvp[2] = nv3; NameValuePair nv4 = new
150   - * NameValuePair(); nv4.setName("activityStatus"); nv4.setValue("11");
151   - * nvp[3] = nv4; NameValuePair nv5 = new NameValuePair();
152   - * nv5.setName("isHorizontalScreen"); nv5.setValue("321"); nvp[4] = nv5;
153   - * NameValuePair nv6 = new NameValuePair(); nv6.setName("channelId");
154   - * nv6.setValue("ww"); nvp[5] = nv6; String ss =
155   - * HttpReq.postRequestWidthResult(
156   - * "http://bc.cnlive.com/live/epg/createActivity", nvp);
157   - * System.out.println(ss); <<<<<<< HEAD String aa = HttpReq
158   - * .getRequestWidthResult(
159   - * "http://bc.cnlive.com/live/epg/startActivity?appId=123&activityId=234"
160   - * ); System.out.println(aa);
161   - */
162   - String aa = HttpReq.getRequestWidthResult("http://bc.cnlive.com/live/epg/startActivity?appId=123&activityId=234");
163   - System.out.println(aa);
164   - }
  1 +package com.cnlive.mz.live.action;
  2 +
  3 +import java.io.IOException;
  4 +import java.io.UnsupportedEncodingException;
  5 +import java.util.HashMap;
  6 +import java.util.List;
  7 +import java.util.Map;
  8 +
  9 +import javax.servlet.http.HttpServletResponse;
  10 +
  11 +import org.apache.commons.lang.StringUtils;
  12 +import org.apache.log4j.Logger;
  13 +import org.smart4j.framework.dao.bean.Pager;
  14 +import org.smart4j.framework.ioc.annotation.Inject;
  15 +import org.smart4j.framework.mvc.DataContext;
  16 +import org.smart4j.framework.mvc.annotation.Action;
  17 +import org.smart4j.framework.mvc.annotation.Request;
  18 +import org.smart4j.framework.mvc.bean.Multipart;
  19 +import org.smart4j.framework.mvc.bean.Multiparts;
  20 +import org.smart4j.framework.mvc.bean.Params;
  21 +import org.smart4j.framework.mvc.bean.Redirect;
  22 +import org.smart4j.framework.mvc.bean.Result;
  23 +import org.smart4j.framework.mvc.bean.ResultBean;
  24 +import org.smart4j.framework.mvc.bean.View;
  25 +import org.smart4j.framework.util.CastUtil;
  26 +
  27 +import com.cnlive.mz.commons.Constants;
  28 +import com.cnlive.mz.commons.net.HttpReq;
  29 +import com.cnlive.mz.live.common.LiveUtils;
  30 +import com.cnlive.mz.live.entity.TChannel;
  31 +import com.cnlive.mz.live.entity.TLive;
  32 +import com.cnlive.mz.live.entity.TRoom;
  33 +import com.cnlive.mz.live.service.TCheckService;
  34 +import com.cnlive.mz.live.service.TLiveService;
  35 +import com.cnlive.mz.live.service.TRoomService;
  36 +
  37 +/**
  38 + * TODO: 机构主播和个人主播发起直播活动 <br/>
  39 + * Date: 2016年4月25日 下午1:12:48 <br/>
  40 + *
  41 + * @author liujicheng
  42 + * @version V1.0
  43 + * @since JDK 1.6
  44 + */
  45 +@Action
  46 +public class LiveAction {
  47 +
  48 + private Logger log = Logger.getLogger("LiveAction");
  49 + @Inject
  50 + private TLiveService tLiveService;
  51 + @Inject
  52 + private TRoomService tRoomService;
  53 + @Inject
  54 + private TCheckService tCheckService;
  55 +
  56 + @Request.Get("/live/preload")
  57 + public View preload() {
  58 + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  59 + View view = new View("live/live_add.jsp");
  60 + List<TRoom> tRooms = tRoomService.getTRooms(user_id);
  61 + view.data("tRooms", tRooms);
  62 + return view;
  63 + }
  64 +
  65 + @Request.Get("/live/list/{page_number}")
  66 + public View list(int page_number) {
  67 + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  68 + System.out.println(user_id);
  69 + Pager<TLive> tLive = tLiveService.getTLivePager(page_number, Constants.PAGE_SIZE, user_id);
  70 + return new View("live/live_management.jsp").data("tLive", tLive);
  71 + }
  72 +
  73 + @Request.Post("/live/save")
  74 + public Result saveLive(Params params, Multiparts multiparts) {
  75 + System.out.println(params + "....and....." + multiparts);
  76 + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  77 + Multipart multipart = multiparts.getOne();
  78 + tLiveService.add(user_id, params, multipart);
  79 + return new Result(false);
  80 + }
  81 +
  82 + @Request.Get("/live/edit/{id}")
  83 + public View edit(int id) {
  84 + TLive tLive = tLiveService.getTLiveById(id);
  85 + TRoom tRoom = tRoomService.getTRoomById(Integer.parseInt(tLive.getLive_room_id()));
  86 + List<TRoom> list = tRoomService.getTRooms(tLive.getT_user_id());
  87 + View view = new View("live/live_edit.jsp");
  88 + view.data("tActivity", tLive);
  89 + view.data("tRoom", tRoom);
  90 + view.data("tRooms", list);
  91 + return view;
  92 + }
  93 +
  94 + //
  95 + @Request.Get("/live/preview/{id}")
  96 + public View preview(int id) {
  97 + TLive tLive = tLiveService.getTLiveById(id);
  98 + TRoom tRoom = tRoomService.getTRoomById(Integer.parseInt(tLive.getLive_room_id()));
  99 + View view = new View("live/live_preview.jsp");
  100 + view.data("tLive", tLive);
  101 + view.data("tRoom", tRoom);
  102 + return view;
  103 + }
  104 +
  105 + @Request.Get("/live/alllive/{page_number}")
  106 + public View liveList(int page_number) {
  107 + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  108 + Pager<TLive> tLive = tLiveService.getAllTLivePager(page_number, Constants.PAGE_SIZE);
  109 + return new View("live/all_live_management.jsp").data("tLive", tLive);
  110 + }
  111 +
  112 + @Request.Get("/live/search/{page_number}")
  113 + public View search(int page_number, Params params) {
  114 + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  115 + System.out.println(user_id);
  116 + System.out.println("...parmas..." + params);
  117 + String t_user_id = params.getString("search_user_id");
  118 + String title = params.getString("search_title");
  119 +
  120 + try {
  121 + title = new String(title.trim().getBytes("ISO-8859-1"), "utf-8");
  122 + System.out.println("...title.." + title);
  123 + } catch (UnsupportedEncodingException e) {
  124 + e.printStackTrace();
  125 + }
  126 +
  127 + Pager<TLive> tLive = tLiveService.getTLiveAllPager(page_number, Constants.PAGE_SIZE, t_user_id, title);
  128 + System.out.println("tLive=====" + tLive);
  129 + return new View("live/all_live_management.jsp").data("tLive", tLive);
  130 + }
  131 +
165 132 }
166 133 \ No newline at end of file
... ...
src/main/java/com/cnlive/mz/live/action/UgcLiveAction.java
... ... @@ -363,5 +363,5 @@ public class UgcLiveAction {
363 363 rb.setErrorCode("404");
364 364 rb.setErrorMessage("失败");
365 365 return rb;
366   - }
  366 + }
367 367 }
368 368 \ No newline at end of file
... ...
src/main/java/com/cnlive/socket/Client.java
1   -package com.cnlive.socket;
2   -
3   -import java.io.BufferedReader;
4   -import java.io.IOException;
5   -import java.io.InputStreamReader;
6   -import java.io.PrintWriter;
7   -import java.net.Socket;
8   -import java.net.UnknownHostException;
9   -
10   -public class Client {
11   - Socket client;
12   - PrintWriter pw;
13   - public Client() throws UnknownHostException, IOException {
14   - client=new Socket("bc.cnlive.com",65432);
15   - pw=new PrintWriter(client.getOutputStream());
16   - BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
17   - pw.write(br.readLine());
18   - pw.close();
19   - br.close();
20   - }
21   - public static void main(String[] args) {
22   - try {
23   - new Client();
24   - } catch (UnknownHostException e) {
25   - e.printStackTrace();
26   - } catch (IOException e) {
27   - e.printStackTrace();
28   - }
29   - }
  1 +package com.cnlive.socket;
  2 +
  3 +import java.io.BufferedReader;
  4 +import java.io.IOException;
  5 +import java.io.InputStreamReader;
  6 +import java.io.PrintWriter;
  7 +import java.net.Socket;
  8 +import java.net.UnknownHostException;
  9 +
  10 +public class Client {
  11 + Socket client;
  12 + PrintWriter pw;
  13 + public Client() throws UnknownHostException, IOException {
  14 + client=new Socket("bc.cnlive.com",65432);
  15 + pw=new PrintWriter(client.getOutputStream());
  16 + BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  17 + pw.write(br.readLine());
  18 + pw.close();
  19 + br.close();
  20 + }
  21 + public static void main(String[] args) {
  22 + try {
  23 + new Client();
  24 + } catch (UnknownHostException e) {
  25 + e.printStackTrace();
  26 + } catch (IOException e) {
  27 + e.printStackTrace();
  28 + }
  29 + }
30 30 }
31 31 \ No newline at end of file
... ...
src/main/java/com/cnlive/socket/SocketServer.java
... ... @@ -31,7 +31,6 @@ public class SocketServer {
31 31 private int port;
32 32 private volatile boolean running = false;
33 33 private long receiveTimeDelay = 7000;
34   - private ConcurrentHashMap<Class, ObjectAction> actionMapping = new ConcurrentHashMap<Class, ObjectAction>();
35 34 private Thread connWatchDog;
36 35  
37 36 public SocketServer(int port) {
... ... @@ -54,16 +53,12 @@ public class SocketServer {
54 53 connWatchDog.stop();
55 54 }
56 55  
57   - public void addActionMap(Class<Object> cls, ObjectAction action) {
58   - actionMapping.put(cls, action);
59   - }
60   -
61 56 class ConnWatchDog implements Runnable {
62 57 public void run() {
63 58 try {
64 59 ServerSocket ss = new ServerSocket(port, 5);
65 60 while (running) {
66   - System.out.println("等待客户端。。。");
  61 + System.out.println("等待客服端 请求。。。");
67 62 Socket s = ss.accept();
68 63 new Thread(new SocketAction(s)).start();
69 64 }
... ... @@ -85,55 +80,45 @@ public class SocketServer {
85 80 }
86 81  
87 82 public void run() {
  83 + String appId = null;
  84 + String activityId = null;
88 85 while (running && run) {
89 86 try {
90 87 Thread.sleep(3000);
91 88 } catch (InterruptedException e1) {
92 89 e1.printStackTrace();
93 90 }
94   - try {
95   - InputStream in = s.getInputStream();
96   - OutputStream out = s.getOutputStream();
97   - byte[] recData = null;
98   - while (true) {
99   - recData = new byte[1024];
100   - int r = in.read(recData);
101   - if (r > -1) {
102   - String data = new String(recData);
103   - /*
104   - * if(data.trim().equals("over")) { s.close();
105   - * break; }
106   - */
107   - System.out.println("读取到客户端发送的来数据:" + data);
  91 +
  92 + if (System.currentTimeMillis() - lastReceiveTime > receiveTimeDelay) {
  93 + System.out.println("socket连接超过30s.....");
  94 + } else {
  95 + try {
  96 + InputStream in = s.getInputStream();
  97 + OutputStream out = s.getOutputStream();
  98 + if (in.available() > 0) {
  99 + byte[] recData = null;
  100 + while (true) {
  101 + recData = new byte[1024];
  102 + int r = in.read(recData);
  103 + if (r > -1) {
  104 + lastReceiveTime = System.currentTimeMillis();
  105 + String data = new String(recData);
  106 + System.out.println("读取到客户端发送的来数据:" + data);
  107 + String[] str = data.split("#");
  108 + appId = str[0];
  109 + activityId = str[1];
  110 + System.out.println(appId+" : "+activityId);
  111 + }
  112 + }
108 113 }
  114 + } catch (Exception e) {
  115 + System.out.println(System.currentTimeMillis() - lastReceiveTime);
  116 + e.printStackTrace();
  117 + overThis();
109 118 }
110   - /*
111   - * if(in.available()>0){ BufferedReader br = new
112   - * BufferedReader(new InputStreamReader(in)); //out = new
113   - * PrintWriter(socket.getOutputStream(), true); String line
114   - * = br.readLine(); System.out.println("you input is : " +
115   - * line); //out.println("you input is :" + line);
116   - * //out.close(); // in.close(); }
117   - */
118   - /*
119   - * ObjectInputStream ois = new ObjectInputStream(in); Object
120   - * obj = ois.readObject(); lastReceiveTime =
121   - * System.currentTimeMillis();
122   - * System.out.println("接收:\t"+obj); ObjectAction oa =
123   - * actionMapping.get(obj.getClass()); oa = oa==null?new
124   - * DefaultObjectAction():oa; Object out = oa.doAction(obj);
125   - * if(out!=null){ ObjectOutputStream oos = new
126   - * ObjectOutputStream(s.getOutputStream());
127   - * oos.writeObject(out); oos.flush(); }
128   - */
129   - } catch (Exception e) {
130   - System.out.println(System.currentTimeMillis() - lastReceiveTime);
131   - e.printStackTrace();
132   - overThis();
133 119 }
134 120 }
135 121 }
136   -
137 122 private void overThis() {
138 123 if (run)
139 124 run = false;
... ...
src/main/java/com/cnlive/socket/TE.java
... ... @@ -14,7 +14,7 @@ import org.apache.commons.httpclient.methods.GetMethod;
14 14  
15 15 public class TE {
16 16 public static void main(String[] args) {
17   - new TE().doGet("http://bc.cnlive.com/live/epg/play/app?appId=inbevnr031&channelID=1472020387351&isHLS=0&platform_id=com.cnlive.libs&timestamp=1471942267&uid=7C1B686C33E0456B883295A57CBBDA87_1471941483046&sp_id=inbevnr031&activityId=1472020387351");
  17 + new TE().doGet("http://bc.cnlive.com/live/epg/play/app?app_id=60_irg1rhs308&channelID=1471754157393");
18 18 }
19 19  
20 20 private HttpClient getHttpClient() {
... ... @@ -31,7 +31,6 @@ public void doGet(String url) {
31 31 InputStream stream = null;
32 32 try {
33 33 int exeCode = client.executeMethod(method);
34   - System.out.println(exeCode);
35 34 StatusLine status = method.getStatusLine();
36 35 int statusCode = status.getStatusCode();
37 36 StringBuffer buf = new StringBuffer();
... ...
src/test/java/com/cnlive/test/Test.java 0 → 100644
  1 +package com.cnlive.test;
  2 +
  3 +import java.io.BufferedReader;
  4 +import java.io.File;
  5 +import java.io.FileInputStream;
  6 +import java.io.InputStreamReader;
  7 +import java.net.URL;
  8 +import java.net.URLConnection;
  9 +import java.text.SimpleDateFormat;
  10 +import java.util.Date;
  11 +import java.util.Locale;
  12 +
  13 +import com.cnlive.mz.commons.net.HttpReq;
  14 +
  15 +public class Test {
  16 +
  17 + public static void main(String[] args) throws Exception {
  18 +// String mediaId="123";
  19 +// String title="hha";
  20 +// String sid="234";
  21 +// //String url = "https://mobile.cnlive.com/CnliveMobile/hd/applyChatRoomId.action?mediaId="+mediaId+"&title="+title+"&sid=?"+sid;
  22 +// String url = "https://mobile.cnlive.com/CnliveMobile/hd/applyChatRoomId.action";
  23 +// //String chat_room_id = HttpReq.getRequestWidthResult(url);
  24 +// System.out.println(sendGet(url));
  25 +// String live = "rtmp://cnlive01.rtmplive.ks-cdn.com/live/498122_a9fdb367c6054edc9d2035dc237d28aa";
  26 +// int index = live.lastIndexOf("/");
  27 +// System.out.println(index);
  28 +// String live_url = live.substring(index+1);
  29 +// System.out.println(live_url);
  30 + //bcb0bf1603664092b4724b4fa90fde7a_14520164246087.mpg
  31 + //7416e88e23f6c6e959142_14658980239250.mpg
  32 + File file = new File("D:/video/b.mpg");
  33 + getFileSizes(file);
  34 + System.out.println(file.length());
  35 + }
  36 + public static long getFileSizes(File f) throws Exception{//取得文件大小
  37 + long s=0;
  38 + if (f.exists()) {
  39 + FileInputStream fis = null;
  40 + fis = new FileInputStream(f);
  41 + s= fis.available();
  42 + System.out.println(s);
  43 + } else {
  44 + f.createNewFile();
  45 + System.out.println("文件不存在");
  46 + }
  47 + return s;
  48 + }
  49 + public static String toGMTString(Date date) {
  50 + SimpleDateFormat df = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss z", Locale.UK);
  51 + df.setTimeZone(new java.util.SimpleTimeZone(0, "GMT"));
  52 + return df.format(date);
  53 + }
  54 + public static String sendGet(String url) {
  55 + String result = "";
  56 + BufferedReader in = null;
  57 + try {
  58 + URL realUrl = new URL(url);
  59 + /*
  60 + * http header 参数
  61 + */
  62 + String content_type = "application/json";
  63 + String path = realUrl.getFile();
  64 + String date = toGMTString(new Date());
  65 + // 2.计算 HMAC-SHA1
  66 + // 打开和URL之间的连接
  67 + URLConnection connection = realUrl.openConnection();
  68 + System.out.println(connection);
  69 + // 设置通用的请求属性
  70 + // 建立实际的连接
  71 + // 定义 BufferedReader输入流来读取URL的响应
  72 + in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
  73 + String line;
  74 + while ((line = in.readLine()) != null) {
  75 + result += line;
  76 + }
  77 + } catch (Exception e) {
  78 + System.out.println("发送GET请求出现异常!" + e);
  79 + e.printStackTrace();
  80 + }
  81 + // 使用finally块来关闭输入流
  82 + finally {
  83 + try {
  84 + if (in != null) {
  85 + in.close();
  86 + }
  87 + } catch (Exception e) {
  88 + e.printStackTrace();
  89 + }
  90 + }
  91 + return result;
  92 + }
  93 +}
... ...
target/m2e-wtp/web-resources/META-INF/MANIFEST.MF
1   -Manifest-Version: 1.0
2   -Build-Jdk: 1.7.0_79
3   -Built-By: adm
4   -Created-By: Maven Integration for Eclipse
5   -
  1 +Manifest-Version: 1.0
  2 +Build-Jdk: 1.7.0_79
  3 +Built-By: adm
  4 +Created-By: Maven Integration for Eclipse
  5 +
... ...
target/m2e-wtp/web-resources/META-INF/maven/com.cnlive.mz.live.web/cnlive_live_web/pom.properties
1 1 #Generated by Maven Integration for Eclipse
2   -#Thu Aug 25 09:33:18 CST 2016
  2 +#Thu Aug 25 14:43:25 CST 2016
3 3 version=0.0.1-SNAPSHOT
4 4 groupId=com.cnlive.mz.live.web
5 5 m2e.projectName=cnlive_live_web
6 6 m2e.projectLocation=D\:\\1_CNLIVE_JAVA_CODE\\cnlive_live_web
7   -artifactId=cnlive_live_web
8 7 \ No newline at end of file
  8 +artifactId=cnlive_live_web
... ...
target/m2e-wtp/web-resources/META-INF/maven/com.cnlive.mz.live.web/cnlive_live_web/pom.xml
... ... @@ -24,8 +24,8 @@
24 24 <artifactId>maven-compiler-plugin</artifactId>
25 25 <version>2.5.1</version>
26 26 <configuration>
27   - <source>1.6</source>
28   - <target>1.6</target>
  27 + <source>1.7</source>
  28 + <target>1.7</target>
29 29 </configuration>
30 30 </plugin>
31 31 </plugins>
... ...