changeset 181:3a2c6c2f9761

*** empty log message ***
author kent
date Fri, 29 Aug 2008 13:30:46 +0900
parents f34608ae1ed2
children e5a7aad3fbc0
files rep/EditorList.java rep/Session.java rep/SessionList.java
diffstat 3 files changed, 11 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/rep/EditorList.java	Fri Aug 29 12:37:02 2008 +0900
+++ b/rep/EditorList.java	Fri Aug 29 13:30:46 2008 +0900
@@ -20,17 +20,15 @@
 			}
 		}
 		error(editor);
-		REPPacketSend send = new REPPacketSend(editor.getChannel());
-		send.send(repCmd);
+		editor.getChannel().write(repCmd);
 	}
 
 
-	public void sendJoinAck(REPSocketChannel channel, REPCommand repCmd) {
+	public void sendJoinAck(REPSocketChannel<REPCommand> channel, REPCommand repCmd) {
 		REPCommand command = repCmd;
 		command.setCMD(REP.SMCMD_JOIN_ACK);
-		
-		REPPacketSend send = new REPPacketSend(channel);
-		send.send(command);
+
+		channel.write(command);
 	}
 
 	public int addEditor(REPSocketChannel<REPCommand> channel, REPCommand repCmd) {
@@ -67,13 +65,11 @@
 
 
 	public void sendPutAck(REPSocketChannel<REPCommand> channel, REPCommand repCmd) {
-		REPPacketSend send = new REPPacketSend(channel);
-		send.send(repCmd);
+		channel.write(repCmd);
 	}
 	
 	public void send(REPSocketChannel<REPCommand> channel, REPCommand command){
-		REPPacketSend send = new REPPacketSend(channel);
-		send.send(command);
+		channel.write(command);
 	}
 
 
@@ -110,7 +106,7 @@
 	}
 
 
-	public Editor getEditor(REPSocketChannel channel) {
+	public Editor getEditor(REPSocketChannel<REPCommand> channel) {
 		// TODO Auto-generated method stub
 		Editor editor1 = null;
 		for(Editor editor: editorList){
--- a/rep/Session.java	Fri Aug 29 12:37:02 2008 +0900
+++ b/rep/Session.java	Fri Aug 29 13:30:46 2008 +0900
@@ -65,8 +65,7 @@
 	}
 	public void sendToEditor(REPCommand repCmd) {
 		for(Editor editor : editorList){
-			REPPacketSend send = new REPPacketSend(editor.getChannel());
-			send.send(repCmd);
+			editor.getChannel().write(repCmd);
 		}
 	}
 	public Editor getEditor(REPSocketChannel<REPCommand> channel) {
--- a/rep/SessionList.java	Fri Aug 29 12:37:02 2008 +0900
+++ b/rep/SessionList.java	Fri Aug 29 13:30:46 2008 +0900
@@ -17,8 +17,6 @@
 	private boolean channelequals = false;
 	private LinkedList<Session> tmpSessionList = new LinkedList<Session>();
 	private String maxHost;
-	private LinkedList<Integer> temp = new LinkedList<Integer>();
-	
 	//private TranslaterImp1 translater;
 	
 	public SessionList(){
@@ -76,23 +74,20 @@
 				System.out.println("equals");
 				continue;
 			}
-			REPPacketSend repSend = new REPPacketSend(channel);
-			repSend.send(repCmd);
+			channel.write(repCmd);
 		}
 	}
 	
 	public void sendCmd(REPSocketChannel<REPCommand> channel, REPCommand repCmd, boolean ring){
 //		LinkedList <Editor> editorList = session3.get(repCmd.sid).getEditorList();
 		LinkedList <Editor> editorList = sessionLinkedList.get(repCmd.sid).getEditorList();	//ここもforループで検索しないといけないよ。
-		REPPacketSend repsend = null;
 		for(Editor editor : editorList){
 			REPSocketChannel<REPCommand> channel2 = editor.getChannel();
 			if(channel.equals(channel2)){
 				System.out.println("equals");
 				channelequals = true;
 			}else if(channelequals){
-				repsend = new REPPacketSend(channel2);
-				repsend.send(repCmd);
+				channel2.write(repCmd);
 			}
 		}
 	}
@@ -118,22 +113,6 @@
 		return "{}";
 	}
 
-	private int reverseCmd(int cmd) {
-		// TODO Auto-generated method stub
-		int kindOfCmd = 0;
-		switch(cmd){
-		case REP.REPCMD_INSERT:
-			kindOfCmd = REP.REPCMD_DELETE;
-			break;
-		case REP.REPCMD_DELETE:
-			kindOfCmd = REP.REPCMD_INSERT;
-			break;
-		case REP.REPCMD_REPLACE:
-			kindOfCmd = REP.REPCMD_REPLACE;
-			break;
-		}
-		return kindOfCmd;
-	}
 
 	public void addEditor(REPSocketChannel<REPCommand> editorChannel, int sid, int eid) {
 //		session3.get(sid).addEditor(eid, editorChannel);
@@ -143,8 +122,7 @@
 	public void sendSelect(int sid) {
 //		SocketChannel channel = session3.get(sid).getMaster().getChannel();
 		REPSocketChannel<REPCommand> channel = sessionLinkedList.get(sid-1).getOwner().getChannel();
-		REPPacketSend send = new REPPacketSend(channel);
-		send.send(new REPCommand(REP.SMCMD_SELECT, sid, 0, 0, 0, 0, ""));
+		channel.write(new REPCommand(REP.SMCMD_SELECT, sid, 0, 0, 0, 0, ""));
 	}
 
 	public void addSession(REPSocketChannel<REPCommand> channel, String string, int i) {