Mercurial > hg > Members > nobuyasu > tightVNCProxy
comparison src/myVncProxy/MyRfbProto.java @ 130:cb00150c223e
implement sendEchoPort
author | e085711 |
---|---|
date | Tue, 30 Aug 2011 05:39:12 +0900 |
parents | 2ff8d5a226c9 |
children | 2a90459a05f0 |
comparison
equal
deleted
inserted
replaced
125:e3dddee7b934 | 130:cb00150c223e |
---|---|
68 // private MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new MostRecentMultiCast<LinkedList<ByteBuffer>>(10); | 68 // private MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new MostRecentMultiCast<LinkedList<ByteBuffer>>(10); |
69 private MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new MulticastQueue<LinkedList<ByteBuffer>>(); | 69 private MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new MulticastQueue<LinkedList<ByteBuffer>>(); |
70 private int clients = 0; | 70 private int clients = 0; |
71 private Inflater inflater = new Inflater(); | 71 private Inflater inflater = new Inflater(); |
72 private Deflater deflater = new Deflater(); | 72 private Deflater deflater = new Deflater(); |
73 | 73 private CreateThread geth; |
74 | |
74 public | 75 public |
75 MyRfbProto() throws IOException { | 76 MyRfbProto() throws IOException { |
76 } | 77 } |
77 | 78 |
78 MyRfbProto(String h, int p, VncViewer v) throws IOException { | 79 MyRfbProto(String h, int p, VncViewer v) throws IOException { |
79 super(h, p, v); | 80 super(h, p, v); |
80 } | 81 } |
81 | 82 |
83 MyRfbProto(String h, int p, CreateThread geth) throws IOException { | |
84 super(h, p); | |
85 this.geth = geth; | |
86 } | |
87 | |
82 MyRfbProto(String h, int p) throws IOException { | 88 MyRfbProto(String h, int p) throws IOException { |
83 super(h, p); | 89 super(h, p); |
84 } | 90 } |
85 | 91 |
86 // over write | 92 // over write |
224 if (serverMajor < 3) { | 230 if (serverMajor < 3) { |
225 throw new IOException( | 231 throw new IOException( |
226 "RFB server does not support protocol version 3"); | 232 "RFB server does not support protocol version 3"); |
227 } | 233 } |
228 | 234 |
235 if (serverMinor == 998) { | |
236 sendPortNumber(); | |
237 } | |
238 | |
239 } | |
240 | |
241 void sendPortNumber() throws IOException { | |
242 byte[] b = new byte[4]; | |
243 b = castIntByte(geth.port); | |
244 os.write(b); | |
229 } | 245 } |
230 | 246 |
231 void sendSecurityType(OutputStream os) throws IOException { | 247 void sendSecurityType(OutputStream os) throws IOException { |
232 // number-of-security-types | 248 // number-of-security-types |
233 os.write(1); | 249 os.write(1); |
311 int checkAndMark() throws IOException { | 327 int checkAndMark() throws IOException { |
312 int dataLen; | 328 int dataLen; |
313 switch (encoding) { | 329 switch (encoding) { |
314 case RfbProto.EncodingRaw: | 330 case RfbProto.EncodingRaw: |
315 dataLen = rectW * rectH * 4 + 16; | 331 dataLen = rectW * rectH * 4 + 16; |
316 is.mark(dataLen); | 332 // is.mark(dataLen); |
317 break; | 333 break; |
318 case RfbProto.EncodingCopyRect: | 334 case RfbProto.EncodingCopyRect: |
319 dataLen = 16 + 4; | 335 dataLen = 16 + 4; |
320 is.mark(dataLen); | 336 // is.mark(dataLen); |
321 break; | 337 break; |
322 case RfbProto.EncodingRRE: | 338 case RfbProto.EncodingRRE: |
323 case RfbProto.EncodingCoRRE: | 339 case RfbProto.EncodingCoRRE: |
324 case RfbProto.EncodingHextile: | 340 case RfbProto.EncodingHextile: |
325 case RfbProto.EncodingTight: | 341 case RfbProto.EncodingTight: |
326 dataLen = zLen + 20; | 342 dataLen = zLen + 20; |
327 is.mark(dataLen); | 343 // is.mark(dataLen); |
328 break; | 344 break; |
329 case RfbProto.EncodingZlib: | 345 case RfbProto.EncodingZlib: |
330 case RfbProto.EncodingZRLE: | 346 case RfbProto.EncodingZRLE: |
331 case RfbProto.EncodingZRLEE: | 347 case RfbProto.EncodingZRLEE: |
332 dataLen = zLen + 20; | 348 dataLen = zLen + 20; |
333 is.mark(dataLen); | 349 // is.mark(dataLen); |
334 break; | 350 break; |
335 case RfbProto.EncodingXCursor: | 351 case RfbProto.EncodingXCursor: |
336 case RfbProto.EncodingRichCursor: | 352 case RfbProto.EncodingRichCursor: |
337 int pixArray = rectW * rectH * 4; | 353 int pixArray = rectW * rectH * 4; |
338 int u8Array = (int)Math.floor((rectW + 7)/8) * rectH; | 354 int u8Array = (int)Math.floor((rectW + 7)/8) * rectH; |
339 dataLen = pixArray + u8Array; | 355 dataLen = pixArray + u8Array; |
340 printFramebufferUpdate(); | 356 printFramebufferUpdate(); |
341 is.mark(dataLen); | 357 // is.mark(dataLen); |
342 break; | 358 break; |
343 default: | 359 default: |
344 dataLen = 1000000; | 360 dataLen = 1000000; |
345 is.mark(dataLen); | 361 // is.mark(dataLen); |
346 } | 362 } |
347 return dataLen; | 363 return dataLen; |
348 } | 364 } |
349 | 365 |
350 | 366 |
351 void sendDataToClient() throws Exception { | 367 void sendDataToClient() throws Exception { |
352 regiFramebufferUpdate(); | 368 regiFramebufferUpdate(); |
369 printFramebufferUpdate(); | |
353 int dataLen = checkAndMark(); | 370 int dataLen = checkAndMark(); |
354 readSendData(dataLen); | 371 readSendData(dataLen); |
355 } | 372 } |
356 | 373 |
357 BufferedImage createBufferedImage(Image img) { | 374 BufferedImage createBufferedImage(Image img) { |
417 + 16); | 434 + 16); |
418 break; | 435 break; |
419 default: | 436 default: |
420 } | 437 } |
421 } | 438 } |
439 int returnMsgtype() { | |
440 return messageType; | |
441 } | |
442 | |
422 | 443 |
423 void readSpeedCheck() throws IOException { | 444 void readSpeedCheck() throws IOException { |
424 byte[] b = new byte[1]; | 445 byte[] b = new byte[1]; |
425 readFully(b); | 446 readFully(b); |
426 } | 447 } |
601 ByteBuffer blen = ByteBuffer.allocate(4); blen.putInt(len2); blen.flip(); | 622 ByteBuffer blen = ByteBuffer.allocate(4); blen.putInt(len2); blen.flip(); |
602 bufs.addFirst(blen); | 623 bufs.addFirst(blen); |
603 | 624 |
604 bufs.addFirst(header); | 625 bufs.addFirst(header); |
605 multicastqueue.put(bufs); | 626 multicastqueue.put(bufs); |
606 is.reset(); | 627 |
628 // is.reset(); | |
607 return ; | 629 return ; |
608 } | 630 } |
609 } | |
610 bufs.add(header); | 631 bufs.add(header); |
611 if (dataLen>16) { | 632 if (dataLen>16) { |
612 ByteBuffer b = ByteBuffer.allocate(dataLen-16); | 633 ByteBuffer b = ByteBuffer.allocate(dataLen-16); |
613 readFully(b.array(),0,dataLen-16); b.limit(dataLen-16); | 634 readFully(b.array(),0,dataLen-16); b.limit(dataLen-16); |
614 bufs.add(b); | 635 bufs.add(b); |
615 } | 636 } |
616 multicastqueue.put(bufs); | 637 multicastqueue.put(bufs); |
617 is.reset(); | 638 is.reset(); |
639 } | |
640 is.reset(); | |
618 | 641 |
619 // It may be compressed. We can inflate here to avoid repeating clients decompressing here, | 642 // It may be compressed. We can inflate here to avoid repeating clients decompressing here, |
620 // but it may generate too many large data. It is better to do it in each client. | 643 // but it may generate too many large data. It is better to do it in each client. |
621 // But we have do inflation for all input data, so we have to do it here. | 644 // But we have do inflation for all input data, so we have to do it here. |
622 } | 645 } |