Mercurial > hg > Members > nobuyasu > tightVNCProxy
view src/MyRfbProto.java @ 13:a5d73cafc8fe
add ProxyVncCanvas and VncProxyService
author | e085711 |
---|---|
date | Sun, 17 Apr 2011 01:50:24 +0900 |
parents | 2840c7a259f1 |
children | 89e1c5f84407 |
line wrap: on
line source
import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import java.nio.ByteBuffer; import java.util.LinkedList; class MyRfbProto extends RfbProto { private ServerSocket servSock; private byte initData[]; private LinkedList <Socket> cliList; boolean MYVNC = true; MyRfbProto(String h, int p, VncViewer v ) throws IOException { super(h, p, v); cliList = new LinkedList <Socket>(); } MyRfbProto(String h, int p) throws IOException { super(h, p); cliList = new LinkedList <Socket>(); } void initServSock(int port) throws IOException{ servSock = new ServerSocket(port); } void setSoTimeout(int num) throws IOException { servSock.setSoTimeout(num); } Socket accept() throws IOException { return servSock.accept(); } void addSock(Socket sock){ cliList.add(sock); } void mark(int len) throws IOException { is.mark(len); } void reset() throws IOException { is.reset(); } boolean markSupported() { return is.markSupported(); } void readServerInit() throws IOException { mark(255); skipBytes(20); int nlen = readU32(); int blen = 20+4+nlen; initData = new byte[blen]; reset(); mark(blen); readFully(initData); reset(); framebufferWidth = readU16(); framebufferHeight = readU16(); bitsPerPixel = readU8(); depth = readU8(); bigEndian = (readU8() != 0); trueColour = (readU8() != 0); redMax = readU16(); greenMax = readU16(); blueMax = readU16(); redShift = readU8(); greenShift = readU8(); blueShift = readU8(); byte[] pad = new byte[3]; readFully(pad); int nameLength = readU32(); byte[] name = new byte[nameLength]; readFully(name); desktopName = new String(name); // Read interaction capabilities (TightVNC protocol extensions) if (protocolTightVNC) { int nServerMessageTypes = readU16(); int nClientMessageTypes = readU16(); int nEncodingTypes = readU16(); readU16(); readCapabilityList(serverMsgCaps, nServerMessageTypes); readCapabilityList(clientMsgCaps, nClientMessageTypes); readCapabilityList(encodingCaps, nEncodingTypes); } inNormalProtocol = true; } void sendInitData(Socket sock) throws IOException{ sock.getOutputStream().write(initData); } void sendData(byte b[]) throws IOException{ for(Socket cli : cliList) cli.getOutputStream().write(b, 0, b.length); } int cliSize(){ return cliList.size(); } }