changeset 107:d32096538dc3

*** empty log message ***
author pin
date Sat, 22 Dec 2007 21:32:00 +0900
parents eded5012be89
children 4e8ebfa2d529
files export/sessionmanager.jar rep/SessionManager.java
diffstat 2 files changed, 42 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
Binary file export/sessionmanager.jar has changed
--- a/rep/SessionManager.java	Sat Dec 22 21:22:36 2007 +0900
+++ b/rep/SessionManager.java	Sat Dec 22 21:32:00 2007 +0900
@@ -499,50 +499,51 @@
 	}
 
 	public void ActionOccured(REPActionEvent event) {
-
-		SocketChannel editorChannel = event.getEditorChannel();
-		int sid = event.getSID();
-		Editor editor = new Editor(editorChannel);
-		editor.setHost(this.myHost);
-		Session session = sessionlist.getSession(sid);
-		session.addEditor(editor);
 		
-		Editor owner = session.getMaster();
-		
-		REPCommand command = new REPCommand();
-		command.setCMD(REP.SMCMD_SELECT);
-		command.setSID(sid);
-		command.setString(editor.getHost() + ":" + editor.getPort());
-		owner.send(command);
+		/*** 元の ***/
+//		SocketChannel editorChannel = event.getEditorChannel();
+//		int sid = event.getSID();
+//		Editor editor = new Editor(editorChannel);
+//		editor.setHost(this.myHost);
+//		Session session = sessionlist.getSession(sid);
+//		session.addEditor(editor);
+//		
+//		Editor owner = session.getMaster();
+//		
+//		REPCommand command = new REPCommand();
+//		command.setCMD(REP.SMCMD_SELECT);
+//		command.setSID(sid);
+//		command.setString(editor.getHost() + ":" + editor.getPort());
+//		owner.send(command);
 		
 		/*** 書き直し ***/
-//		SocketChannel channel = event.getEditorChannel();
-//		int sid = event.getSID();
-//		Session session = sessionlist.getSession(sid);
-//		if(session.isOwner()){
-//			int eid = session.addEditor(new Editor(channel));
-//			REPCommand sendCommand = new REPCommand();
-//			sendCommand.setCMD(REP.SMCMD_JOIN_ACK);
-//			sendCommand.setEID(eid);
-//			sendCommand.setSID(sid);
-//			REPPacketSend sender = new REPPacketSend(channel);
-//			sender.send(sendCommand);
-//		}else {
-//			SocketChannel editorChannel = event.getEditorChannel();
-//			sid = event.getSID();
-//			Editor editor = new Editor(editorChannel);
-//			editor.setHost(myHost);
-//			session = sessionlist.getSession(sid);
-//			session.addEditor(editor);
-//			
-//			Editor owner = session.getMaster();
-//			
-//			REPCommand command = new REPCommand();
-//			command.setCMD(REP.SMCMD_SELECT);
-//			command.setSID(sid);
-//			command.setString(editor.getHost() + ":" + editor.getPort());
-//			owner.send(command);
-//		}
+		SocketChannel channel = event.getEditorChannel();
+		int sid = event.getSID();
+		Session session = sessionlist.getSession(sid);
+		if(session.isOwner()){
+			int eid = session.addEditor(new Editor(channel));
+			REPCommand sendCommand = new REPCommand();
+			sendCommand.setCMD(REP.SMCMD_JOIN_ACK);
+			sendCommand.setEID(eid);
+			sendCommand.setSID(sid);
+			REPPacketSend sender = new REPPacketSend(channel);
+			sender.send(sendCommand);
+		}else {
+			SocketChannel editorChannel = event.getEditorChannel();
+			sid = event.getSID();
+			Editor editor = new Editor(editorChannel);
+			editor.setHost(myHost);
+			session = sessionlist.getSession(sid);
+			session.addEditor(editor);
+			
+			Editor owner = session.getMaster();
+			
+			REPCommand command = new REPCommand();
+			command.setCMD(REP.SMCMD_SELECT);
+			command.setSID(sid);
+			command.setString(editor.getHost() + ":" + editor.getPort());
+			owner.send(command);
+		}
 		
 		
 		//REPPacketSend send = new REPPacketSend(editorChannel);