Mercurial > hg > RemoteEditor > Eclipse
changeset 65:b1710c49c883
*** empty log message ***
author | pin |
---|---|
date | Thu, 08 Nov 2007 04:31:46 +0900 (2007-11-07) |
parents | 403272ec470c |
children | 4ef0f4f47240 |
files | src/remoteeditor/editors/RemoteEditor.java src/remoteeditor/network/REPPacketSend.java |
diffstat | 2 files changed, 22 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/remoteeditor/editors/RemoteEditor.java Fri Nov 02 17:03:17 2007 +0900 +++ b/src/remoteeditor/editors/RemoteEditor.java Thu Nov 08 04:31:46 2007 +0900 @@ -57,6 +57,9 @@ private int mysid = 0; private String filename = "afro"; protected boolean lock; + private String myHostAndPort; + + //private Translate translate; public RemoteEditor() { @@ -84,6 +87,7 @@ }catch (IOException e) { e.printStackTrace(); } + getSocketString(sc); repreceive = new REPPacketReceive(sc); repsend = new REPPacketSend(sc); @@ -102,6 +106,17 @@ joinPart(); } + private void getSocketString(SocketChannel sc2) { + String socketString = sc2.socket().getLocalSocketAddress().toString(); + System.out.println(socketString); + String[] str = socketString.split("/"); + //String String str2; + for(String str2: str){ + this.myHostAndPort = str2; + } + //this.myHostAndPort = socketString; + } + public void dispose() { //rep.dispose(); super.dispose(); @@ -175,7 +190,7 @@ } }); } - +/* // public void packetReceived(final RSocketEvent evt) { // final int lineNo = evt.getLineNo(); // final int Linelength = evt.getLength(); @@ -185,11 +200,11 @@ // } catch (Exception e) { // e.printStackTrace(); // } -// } +// }*/ public void joinPart(){ //String string = "test.txt"; - repsend.send(new REPCommand(REP.SMCMD_JOIN, 0, 0, 0, 0, 0, "")); + repsend.send(new REPCommand(REP.SMCMD_JOIN, 0, 0, 0, 0, 0, myHostAndPort)); } public void putPart(){ @@ -250,7 +265,7 @@ break; case REP.REPCMD_READ: try { - receiveReadCMD(); + receiveReadCMD(command.eid); } catch (BadLocationException e) { e.printStackTrace(); } @@ -300,12 +315,12 @@ }); } - private void receiveReadCMD() throws BadLocationException { + private void receiveReadCMD(int desteid) throws BadLocationException { for(int i = 0; i < document.getNumberOfLines(); i++){ int offset = document.getLineOffset(i); int length = document.getLineLength(i); String text = document.get(offset, length); - repsend.send(new REPCommand(REP.REPCMD_INSERT, mysid, myeid, myseq, i, text.length(), text)); + repsend.send(new REPCommand(REP.REPCMD_READ_ACK, mysid, desteid, myseq, i, text.length(), text)); } } }
--- a/src/remoteeditor/network/REPPacketSend.java Fri Nov 02 17:03:17 2007 +0900 +++ b/src/remoteeditor/network/REPPacketSend.java Thu Nov 08 04:31:46 2007 +0900 @@ -14,7 +14,7 @@ } public ByteBuffer pack(REPCommand command){ - command.setString(command.string + ":temp:123456"); //���Ƃŏ������� + //command.setString(command.string + ":temp:123456"); //���Ƃŏ������� System.out.println("send command: " + command.toString()); ByteBuffer buffer = ByteBuffer.allocateDirect(24+(command.string).length()*2); buffer.clear(); // position = 0