Mercurial > hg > RemoteEditor > REPSessionManager
view rep/Editor.java @ 82:4bb583553a42
*** empty log message ***
author | pin |
---|---|
date | Tue, 11 Dec 2007 14:26:13 +0900 |
parents | 391d44c94799 |
children | 9381b4734a0b |
line wrap: on
line source
package rep; import java.nio.channels.SocketChannel; import java.util.StringTokenizer; public class Editor { private int eid; private SocketChannel myChannel; private SocketChannel nextChannel; private String host; private String port; //public int getEID; private String file; public Editor(int editorNo, SocketChannel channel){ this.eid = editorNo; this.myChannel = channel; } public Editor(SocketChannel channel) { this.myChannel = channel; setHostAndPort(myChannel); } public Editor() { } private void setHostAndPort(SocketChannel channel) { String socketString = channel.socket().getRemoteSocketAddress().toString(); String[] split = socketString.split("/"); int length = split.length; String hostAndPort = split[length-1]; split = hostAndPort.split(":"); host = split[0]; port = split[1]; } public SocketChannel getChannel() { return myChannel; } public void setHost(String host){ this.host = host; } public void setPort(String port){ this.port = port; } public String getHost(){ return host; } public String getPort(){ return port; } public int getEID() { return eid; } public void setEID(int eid) { this.eid = eid; } public String toString(){ return (host + ":" + port + ":" + file); //return ("eid:" + eid + ":" + myChannel.socket().getLocalSocketAddress().toString()); } public String getName() { return file; } public void setName(String string) { file = string; } public void send(REPCommand repCmd) { REPPacketSend send = new REPPacketSend(myChannel); send.send(repCmd); } }