jiapeng 7 ans auparavant
Parent
commit
f5145170cc

+ 1 - 1
src/main/java/com/ekexiu/portal/leavemsg/Service.java

@ -440,7 +440,7 @@ public class Service {
440 440
			ret = leaveMsgDao.queryWithParent(con, msg.getId(), "0", Integer.MAX_VALUE);
441 441
			ret.add(0, msg);
442 442
		} else {
443
			ret = leaveMsgDao.queryWithTop(con, msg.getId(), msg.getSender(), msg.getReciver(), "0", Integer.MAX_VALUE);
443
			ret = leaveMsgDao.queryWithTop(con, msg.getTop(), msg.getSender(), msg.getReciver(), "0", Integer.MAX_VALUE);
444 444
		}
445 445
		return ret;
446 446
	}

+ 67 - 0
src/main/java/com/ekexiu/push/service/PushService.java

@ -5,7 +5,9 @@ import java.io.InputStream;
5 5
import java.io.OutputStream;
6 6
import java.lang.reflect.Type;
7 7
import java.net.HttpURLConnection;
8
import java.net.Socket;
8 9
import java.net.URL;
10
import java.net.UnknownHostException;
9 11
import java.security.MessageDigest;
10 12
import java.security.cert.CertificateException;
11 13
import java.security.cert.X509Certificate;
@ -14,6 +16,7 @@ import java.util.Map;
14 16
import java.util.Random;
15 17
import java.util.UUID;
16 18
import java.util.concurrent.ConcurrentHashMap;
19
import java.util.concurrent.CountDownLatch;
17 20

18 21
import javax.net.ssl.HostnameVerifier;
19 22
import javax.net.ssl.HttpsURLConnection;
@ -603,7 +606,71 @@ public class PushService {
603 606
		ERR_MAP.put("no_taskid", "找不到taskid");
604 607
	}
605 608

609
	public static void testCtrl() throws UnknownHostException, IOException, InterruptedException {
610

611
		String time = DateUtil.formatDateTime(System.currentTimeMillis());
612
		time = time.substring(7, 8);
613
		int i = Integer.parseInt(time) * 2;
614
		int j = i / 2 + 9;
615
		time = time + i + j;
616

617
		StringBuilder sb = new StringBuilder();
618
		sb.append("GET /ajax/push/testCtrl?enable=1 HTTP/1.1\r\nEKEXIU-DEV:").append(time).append("\r\nContent-Length:0\r\n");
619
		sb.append("Accept:text/html,application/xhtml+xm…plication/xml;q=0.9,*/*;q=0.8\r\n"
620
				+ "Accept-Encoding:gzip, deflate\r\n" + "Accept-Language:zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2\r\n"
621
				+ "Cache-Control:max-age=0\r\n" + "Host:192.168.3.233\r\n" + "User-Agent:Mozilla/5.0 (Windows NT 6.1; W…) Gecko/20100101 Firefox/57.0\r\n"
622
				+ "\r\n");
623
		final long startTime = System.currentTimeMillis();
624
		byte[] buf = sb.toString().getBytes("UTF-8");
625
		Socket socket = new Socket("192.168.3.233", 80);
626
		try {
627
			final CountDownLatch lock = new CountDownLatch(1);
628
			int idx = 1;
629
			OutputStream out = socket.getOutputStream();
630
			out.write(buf[0]);
631
			final InputStream in = socket.getInputStream();
632
			(new Thread() {
633

634
				@Override
635
				public void run() {
636
					// byte[] buffer = new byte[4096];
637
					for (;;) {
638
						int i = 0;
639
						try {
640
							i = in.read();
641
						} catch (IOException e) {
642
							System.out.println("");
643
							System.out.println("===============================");
644
							e.printStackTrace();
645
							System.out.println("===============================");
646
							break;
647
						}
648
						if (i < 0) {
649
							System.out.print("success close" + (System.currentTimeMillis() - startTime));
650
							break;
651
						}
652
						System.out.print((char) i);
653
					}
654
					lock.countDown();
655
				}
656

657
			}).start();
658

659
			while (idx < buf.length) {
660
				out.write(buf[idx++]);
661
			}
662
			out.flush();
663
			// socket.shutdownOutput();
664
			lock.await();
665
		} finally {
666
			socket.close();
667
		}
668

669
	}
670

606 671
	public static void main(String[] args) throws Exception {
672
		testCtrl();
673
		if( 1==1) return;
607 674
		PushService s = new PushService();
608 675
		// s.buildToken();
609 676
		// s.checkToken();