Mercurial > hg > RemoteEditor > REPSessionManager
changeset 15:78c211017d3d
*** empty log message ***
author | pin |
---|---|
date | Fri, 02 Nov 2007 14:49:42 +0900 |
parents | 47633cfb92d3 |
children | cb482350a1aa |
files | rep/REPPacketReceive.java rep/SessionManager.java |
diffstat | 2 files changed, 20 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/REPPacketReceive.java Fri Nov 02 14:15:26 2007 +0900 +++ b/rep/REPPacketReceive.java Fri Nov 02 14:49:42 2007 +0900 @@ -67,19 +67,19 @@ //System.out.println(string); //getSocket(string); REPCommand repcommand = new REPCommand(cmd, sid, eid, seqid, lineno, textsiz, string); + getSocket(repcommand); System.out.println("received command: " + repcommand.toString()); return repcommand; } - private void getSocket(String string) { - StringTokenizer st = new StringTokenizer(string, "/"); - String hostport = null; - while(st.hasMoreTokens()){ - hostport = st.nextToken(); - } - StringTokenizer st2 = new StringTokenizer(hostport, ":"); + private void getSocket(REPCommand command) { + String string = command.string; + StringTokenizer st2 = new StringTokenizer(string, ":"); host = st2.nextToken(); - port = Integer.parseInt(st2.nextToken()); + String portstring = st2.nextToken(); + port = Integer.parseInt(portstring); + int socketInfoLength = host.length() + portstring.length() + 1; + command.setString(string.substring(0, string.length() - socketInfoLength)); } }
--- a/rep/SessionManager.java Fri Nov 02 14:15:26 2007 +0900 +++ b/rep/SessionManager.java Fri Nov 02 14:49:42 2007 +0900 @@ -9,6 +9,7 @@ import java.nio.channels.Selector; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; +import java.util.StringTokenizer; //+-------+--------+--------+-------+--------+---------+------+ //| cmd | session| editor | seqid | lineno | textsiz | text | @@ -233,7 +234,8 @@ System.out.println(""); registerChannel(selector, sessionchannel, SelectionKey.OP_READ); REPCommand sm_join_com = REPCommand.SMCMD_SESSION_JOIN; - sm_join_com.setString(sm_join_com.string + getSocket(sessionchannel)); + String socketString = getSocketString(sessionchannel); + sm_join_com.setString(sm_join_com.string + ":" + socketString); send.send(REPCommand.SMCMD_SESSION_JOIN); smList.add(sessionchannel); }catch (IOException e) { @@ -241,9 +243,16 @@ } } - private String getSocket(SocketChannel sessionchannel) { + private String getSocketString(SocketChannel sessionchannel) { SocketAddress socket = sessionchannel.socket().getRemoteSocketAddress(); - return socket.toString(); + //String inetAddressString = sessionchannel.socket().getInetAddress().toString(); + StringTokenizer stn = new StringTokenizer(socket.toString(), "/"); + String socketString = null; + while(stn.hasMoreTokens()){ + socketString = stn.nextToken(); + System.out.println(socketString); + } + return socketString; } public void connectionOccured(ConnectionEvent event) {