Mercurial > hg > Members > nobuyasu > tightVNCClient
comparison src/MyRfbProto.java @ 10:9c7eab50c708
update MyRfbProto. add acceptThread
author | e085711 |
---|---|
date | Sat, 16 Apr 2011 20:40:24 +0900 |
parents | 2237c4a06427 |
children | 1b2bca9583cb |
comparison
equal
deleted
inserted
replaced
9:2237c4a06427 | 10:9c7eab50c708 |
---|---|
1 import java.io.IOException; | 1 import java.io.IOException; |
2 import java.net.ServerSocket; | |
2 import java.net.Socket; | 3 import java.net.Socket; |
3 import java.nio.ByteBuffer; | 4 import java.nio.ByteBuffer; |
5 import java.util.LinkedList; | |
4 | 6 |
5 | 7 |
6 class MyRfbProto extends RfbProto { | 8 class MyRfbProto extends RfbProto { |
7 | 9 |
10 private ServerSocket servSock; | |
8 private byte initData[]; | 11 private byte initData[]; |
12 private LinkedList <Socket> cliList; | |
13 boolean MYVNC = true; | |
14 | |
9 | 15 |
10 MyRfbProto(String h, int p, VncViewer v) throws IOException { | 16 MyRfbProto(String h, int p, VncViewer v) throws IOException { |
11 super(h, p, v); | 17 super(h, p, v); |
18 cliList = new LinkedList <Socket>(); | |
12 } | 19 } |
13 | 20 |
21 void initServSock(int port) throws IOException{ | |
22 servSock = new ServerSocket(port); | |
23 } | |
24 | |
25 void setSoTimeout(int num) throws IOException { | |
26 servSock.setSoTimeout(num); | |
27 } | |
28 | |
29 Socket accept() throws IOException { | |
30 return servSock.accept(); | |
31 } | |
32 | |
33 void addSock(Socket sock){ | |
34 cliList.add(sock); | |
35 } | |
36 | |
14 void mark(int len) throws IOException { | 37 void mark(int len) throws IOException { |
15 is.mark(len); | 38 is.mark(len); |
16 } | 39 } |
17 | 40 |
18 void reset() throws IOException { | 41 void reset() throws IOException { |
26 void readServerInit() throws IOException { | 49 void readServerInit() throws IOException { |
27 | 50 |
28 mark(255); | 51 mark(255); |
29 skipBytes(20); | 52 skipBytes(20); |
30 int nlen = readU32(); | 53 int nlen = readU32(); |
31 initData = new byte[20+4+nlen]; | 54 int blen = 20+4+nlen; |
55 initData = new byte[blen]; | |
56 reset(); | |
57 | |
58 mark(blen); | |
32 readFully(initData); | 59 readFully(initData); |
33 reset(); | 60 reset(); |
34 | 61 |
35 framebufferWidth = readU16(); | 62 framebufferWidth = readU16(); |
36 framebufferHeight = readU16(); | 63 framebufferHeight = readU16(); |
64 | 91 |
65 inNormalProtocol = true; | 92 inNormalProtocol = true; |
66 } | 93 } |
67 | 94 |
68 void sendInitData(Socket sock) throws IOException{ | 95 void sendInitData(Socket sock) throws IOException{ |
69 sock.getOutputStream().write(initData); | 96 sock.getOutputStream().write(initData); |
70 } | 97 } |
71 | 98 |
99 void sendData(byte b[]) throws IOException{ | |
100 for(Socket cli : cliList) | |
101 cli.getOutputStream().write(b, 0, b.length); | |
102 } | |
103 | |
104 int cliSize(){ | |
105 return cliList.size(); | |
106 } | |
72 | 107 |
73 } | 108 } |