faces/0040755000076600007660000000000007425146602012375 5ustar kitazawakitazawafaces/CalendarFormat.java0100644000076600007660000000370607425146554016133 0ustar kitazawakitazawapackage jp.faces; import java.util.*; /** * $BF|;~$NJ8;zNs@8@.(B * * @author Jun Kitazawa * @version 0.1.3 */ public class CalendarFormat { private Calendar cal; private String year; private String month; private String day; private String hour; private String minute; private String second; private String weekstr; public CalendarFormat(){ cal = Calendar.getInstance(); year = Integer.toString(cal.get(Calendar.YEAR)); month = Integer.toString(cal.get(Calendar.MONTH)+1); day = Integer.toString(cal.get(Calendar.DAY_OF_MONTH)); hour = Integer.toString(cal.get(Calendar.HOUR_OF_DAY)); minute = Integer.toString(cal.get(Calendar.MINUTE)); second = Integer.toString(cal.get(Calendar.SECOND)); if(month.length() < 2) month = "0" + month; if(day.length() < 2) day = "0" + day; if(hour.length() < 2) hour = "0" + hour; if(minute.length() < 2) minute = "0" + minute; if(second.length() < 2) second = "0" + second; weekstr = ""; switch(cal.get(Calendar.DAY_OF_WEEK)){ case Calendar.SUNDAY: weekstr = "Sun"; break; case Calendar.MONDAY: weekstr = "Mon"; break; case Calendar.TUESDAY: weekstr = "Tue"; break; case Calendar.WEDNESDAY: weekstr = "Wed"; break; case Calendar.THURSDAY: weekstr = "Thu"; break; case Calendar.FRIDAY: weekstr = "Fri"; break; case Calendar.SATURDAY: weekstr = "Sat"; break; } } public String getDateStrFormat(){ String datestr; // $B7n(B/$BF|(B/$BG/(B $B;~(B:$BJ,(B:$BIC(B datestr = "[" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":" + second + "] "; return datestr; } public String getDateTStrFormat(){ String TNodeStr = ""; return TNodeStr; } } faces/ClientInfo.java0100644000076600007660000000255007425146554015277 0ustar kitazawakitazawapackage jp.faces; import java.util.*; import java.io.*; import org.w3c.dom.*; import javax.xml.parsers.*; import org.apache.crimson.tree.*; /** * クライアント情報管理 * * @author Jun Kitazawa * @version 0.1.3 */ public class ClientInfo { private int nnum; // Pノードのn属性にあたる数 private String AppName; // クライアントが所属しているアプリケーションの名前 private int roomNum = -1; // クライアントが所属している部屋番号 /** * 名前(selfname)をセットする * * @param n クライアントID */ public final void setNnum(int n){ nnum = n; } /** * 名前(selfname)をゲットする * * @return クライアントID */ public final int getNnum(){ return nnum; } /** * アプリケーション名をセットする * * @param app アプリケーション名 */ public final void setAppName(String app){ AppName = app; } /** * 部屋番号をセットする * 部屋に入れる人数は無制限 * @param r 部屋番号 */ public final void setRoomNum(int r){ roomNum = r; } /** * アプリケーション名をゲットする * * @return アプリケーション名の文字列 */ public final String getAppName(){ return AppName; } /** * 部屋番号をゲットする * * @return アプリケーション名の文字列 */ public final int getRoomNum(){ return roomNum; } } faces/FacesClient.java0100644000076600007660000001011107425146554015415 0ustar kitazawakitazawapackage jp.faces; import java.net.*; import java.io.*; /** * FacesServer用クライアントクラス * * @author Jun Kitazawa * @version 0.1.3 * @see FacesServer */ public class FacesClient extends Thread { /** * サーバ(FacesServerクラスのインスタンス) */ private FacesServer srv; /** * クライアントソケット */ private Socket sock; /** * クライアントから送られてくるメッセージを受信するReader */ protected BufferedReader in; /** * クライアントへのメッセージを送信するWriter */ protected PrintWriter out; /** * XMLメッセージからDOMツリーを作って、各クライアントの情報を得るためのXML解析クラス */ private FacesXML px; /** * クライアントのIPを保持する文字列 */ private String ipstr; /** * クライアント情報管理オブジェクト */ private ClientInfo ci; /** * FacesClientクラスのコンストラクタ * FacesServerクラスのrunServerメソッドの中で呼ばれる * * @param srv サーバ(FacesServerクラスのインスタンス) * @param sock ソケット */ public FacesClient(FacesServer srv, Socket sock) { this.srv = srv; this.sock = sock; this.ipstr = sock.getInetAddress().getHostAddress(); ci = new ClientInfo(); px = new FacesXML(srv, this); try { // readerとwriterはそれぞれBufferedReader,PrintWriterでストリームをラップして生成 in = new BufferedReader(new InputStreamReader(sock.getInputStream(),"SJIS")); out = new PrintWriter(new OutputStreamWriter(sock.getOutputStream(), "SJIS"), true); } catch(IOException ioe) { // 初期化失敗 srv.printServerMsg("initilization error on Client IP: " + ipstr + ". disconnected."); ioe.printStackTrace(); // このクライアントを停止する stopClient(); } } /** * クライアント情報管理オブジェクトを得る */ public final ClientInfo getClientInfo(){ return ci; } /** * クライアントからのメッセージを文字列に構成し * FacesXmlオブジェクトのreadXMLメソッドに渡す */ public void run() { try { // 1文字分配列確保 char c[] = new char[1]; // クライアントからのストリームがある while(in.read(c,0,1) != -1) { // ストリーム用文字列バッファ StringBuffer sb = new StringBuffer(4096); // null文字がこなければ while(c[0] != '\0') { // バッファに1文字付加 sb.append(c[0]); // さらに1文字ストリームから読み込み in.read(c, 0 ,1); } // XMLメッセージ処理 px.readXML(sb.toString()); } } catch(IOException ioe) { // read errorが起こったので、コネクションを切断 srv.printServerMsg("read error on Client IP: " + ipstr + ". disconnected."); } finally { // 最後にはこのクライアントクラスを停止する stopClient(); } } /** * クライアントのIPの文字列を返すメソッド * * @return クライアントのIPの文字列 */ public final String getIPStr() { return ipstr; } /** * クライアントにメッセージを送る。 * メッセージはnull文字"\0"が終端 * * @param msg クライアントに送るメッセージ文字列 * @see FacesServer#sendToRoom(String msg, String an, int r) */ public void sendToClient(String msg) { out.print(msg + "\0"); if(out.checkError()) { srv.printServerMsg("write error on Client IP: " + ipstr + ". disconnected."); //クライアントを停止する stopClient(); } } /** * クライアントを停止する * */ private void stopClient() { // FacesServerから自分(クライアントクラスのインスタンス)を削除 srv.deleteClient(this); try { in.close(); //BufferdReaderを閉じる out.close(); // PrintWriterを閉じる sock.close(); // ソケットを閉じる } catch (IOException ioe) { // 閉じるのに失敗したらその旨表示 srv.printServerMsg("connection error on Client IP: " + ipstr); ioe.printStackTrace(); } } } faces/FacesServer.java0100644000076600007660000002371007425146554015456 0ustar kitazawakitazawapackage jp.faces; import java.net.*; import java.io.*; import java.util.*; /** * FACEs Server--Flash用マルチユーザサーバ * * @author Jun Kitazawa * @version 0.1.3 */ public class FacesServer { /** * サーバソケット */ private ServerSocket srvsock; /** * 部屋情報のリスト */ private HashMap rooms = new HashMap(); /** * クライアントのリスト */ private HashMap fclist = new HashMap(); private List numlist = new Vector(); /** * データベース接続用 */ private JDBC pg = null; /** * データベースを使用するかどうか */ private boolean jdbcflag = false; /** * XMLエラーメッセージマップ */ private XmlErrMap errMap; /** * サーバプロセスを起動し、DBへのコネクションを確立。クライアントからのapp指定が * 無いときのためのデフォルトアプリケーション"0"の領域を用意しておく。 * * @param port クライアントの接続を受け付けるポートの番号 */ public FacesServer(int port) { if(jdbcflag == true) pg = new JDBC(); // データベース接続オブジェクト // デフォルト(クライアントがapp要素を指定していない場合の)アプリケーション情報 RoomInfo roominfo = new RoomInfo(this); // デフォルトアプリケーション(名前は"0") roominfo.setAppName("0"); roominfo.setRoomNum(0); HashMap approoms = new HashMap(); approoms.put(new Integer(0),roominfo); rooms.put("0",approoms); // アプリケーション"0"をアプリケーション配列に付加 errMap = new XmlErrMap(); // XMLエラーメッセージマップ runServer(port); } /** * XMLエラーメッセージマップを返す * * @return XMLエラーメッセージマップ */ public XmlErrMap getXmlErrMap(){ return errMap; } /** * 空いている最小のクライアント番号を返す * * @return 空いている最小のクライアント番号 */ private int getWaitingCnum(){ int num = 1; while(true){ boolean check = true; Iterator itr = numlist.iterator(); while (itr.hasNext()) { Integer i = (Integer)itr.next(); int cnum = i.intValue(); if(cnum == num){ num++; check = false; break; } } if(check){ numlist.add(new Integer(num)); return num; } } } /** * データベースへの接続情報を得る * * @return JDBCインスタンス */ public final JDBC getPG(){ return pg; } /** * アプリケーション情報の配列を得る * * @return アプリケーション情報(ClientInfoインスタンス)の配列 */ public final HashMap getRooms(){ return rooms; } /** * クライアントのリストを得る * * @return クライアントのリスト */ public final HashMap getClients(){ return fclist; } /** * アプリケーション名と部屋番号から部屋情報を得る * * @param an アプリケーション名 * @param r 部屋番号 * @return 部屋情報 */ public RoomInfo getRoomInfo(String an, int r){ HashMap list = (HashMap)rooms.get(an); if(list != null){ RoomInfo ri = (RoomInfo)list.get(new Integer(r)); if(ri != null){ return ri; } } return null; } /** * クライアントIDからFacesClientオブジェクトを得る * * @param id クライアントID * @return クライアントクラス */ public FacesClient getFacesClientFromID(int id){ Collection valueSet = fclist.values(); Iterator itr = valueSet.iterator(); while(itr.hasNext()){ Vector v = (Vector)itr.next(); Enumeration e = v.elements(); while(e.hasMoreElements()){ FacesClient fc = (FacesClient)(e.nextElement()); if(fc.getClientInfo().getNnum() == id){ return fc; } } } return null; } /** * 接続しているクライアントのなかで同じアプリケーション名かつ同じ部屋番のクライアントすべてにメッセージを配る。 * * @param msg 配るメッセージ文字列 * @param an アプリケーション名 * @param r 部屋番 */ public void sendToRoom(String msg, String an , int r) { // 同じ部屋のクライアントそれぞれにメッセージを送信していく Vector v = (Vector)fclist.get(an); if(v != null){ Enumeration e = v.elements(); while(e.hasMoreElements()){ FacesClient fc = (FacesClient)(e.nextElement()); //部屋番号が同じクライアントに送信 ClientInfo clinfo = fc.getClientInfo(); if(clinfo != null){ int roomnum = clinfo.getRoomNum(); if(roomnum == r){ fc.sendToClient(msg); } } } } } /** * 接続しているクライアントのなかで同じアプリケーション名のクライアントすべてにメッセージを配る。 * * * @param msg 配るメッセージ文字列 * @param an アプリケーション名 */ public void sendToApp(String msg, String an) { // 同じアプリのクライアントそれぞれにメッセージを送信していく Vector v = (Vector)fclist.get(an); if(v != null){ Enumeration e = v.elements(); while(e.hasMoreElements()){ FacesClient fc = (FacesClient)(e.nextElement()); fc.sendToClient(msg); } } } /** * 引数で指定されたアプリケーションの現在の利用者数を返す * * @param an アプリケーション名 * @return 利用者数 */ public synchronized int appUserCount(String an){ Vector v = (Vector)fclist.get(an); if(v != null){ return v.size(); } else { return 0; } } /** * 引数で指定された部屋の現在の利用者数を返す * * @param an アプリケーション名 * @param r 部屋番号 * @return 利用者数 */ public synchronized int roomUserCount(String an, int r){ Vector v = (Vector)fclist.get(an); Enumeration e = v.elements(); int clcnt = 0; while(e.hasMoreElements()){ FacesClient fc = (FacesClient)(e.nextElement()); int roomnum = fc.getClientInfo().getRoomNum(); if(roomnum == r){ clcnt++; } } return clcnt; } /** * クライアントリストからクライアントを削除 * * @param fc 削除するクライアントのインスタンス */ public void deleteClient(FacesClient fc) { int clindex = fc.getClientInfo().getNnum(); String appname = fc.getClientInfo().getAppName(); int roomnum = fc.getClientInfo().getRoomNum(); // 誰か抜けたことを表示 printServerMsg(fc.getIPStr() + " disconnected."); // クライアントリストからクライアントを削除 Vector v = (Vector)fclist.get(appname); if(v != null){ v.remove(fc); } // クライアント番号リストから該当番号を削除 numlist.remove(new Integer(clindex)); // 抜けたクライアントの番号をおなじ部屋のクライアントとロビーに配信する // 部屋番号0番の時には2重に送られないようにする if(roomnum != 0){ sendToRoom("",appname,roomnum); } sendToRoom("",appname,0); // 部屋のカウンタ処理(抜けたことによってカウンタが揃う場合用) RoomInfo ritmp = getRoomInfo(appname, roomnum); SyncCounters syncCount = ritmp.getSyncCounters(); List snlist = syncCount.evalRoomForDelete(appname, roomnum); Iterator itr = snlist.iterator(); while(itr.hasNext()){ String n = (String)itr.next(); sendToRoom("",appname,roomnum); } RoomInfo ritmp0 = getRoomInfo(appname, 0); if(ritmp0 != null){ ritmp0.deleteLogNode(clindex); // ロビーのLOGノード削除 } HashMap list = (HashMap)rooms.get(appname); Collection valueSet = list.values(); itr = valueSet.iterator(); while(itr.hasNext()){ ritmp = (RoomInfo)itr.next(); if(ritmp != null) ritmp.deleteSelfSubNode(clindex); // 要素key=selfnameのノード削除 } if(jdbcflag == true) pg.puserDelete(clindex,appname,appUserCount(appname)); } /** * サーバの状態を表す文字列を標準出力に出す * * @param msg 表示するメッセージの本体 */ public static void printServerMsg(String msg) { // 引数文字列に、日時と改行コードを付加 msg = getDateStrFormat() + msg + "\n"; System.out.print(msg); } /** * 月/日/年 時:分:秒 * というフォーマットで文字列を構成 * * @return 日時を表すの文字列 */ private static String getDateStrFormat(){ CalendarFormat cf = new CalendarFormat(); return cf.getDateStrFormat(); } /** * サーバをスタートさせて、接続を受け付ける * * @param port 接続を受け付けるポートの番号 */ private void runServer(int port) { // 起動中の文字列を表示 printServerMsg("starting server..."); if(jdbcflag == true) pg.clearTables(); // DBのテーブル内容を全て消去 try { // サーバソケットクラスのインスタンスを生成 srvsock = new ServerSocket(port); printServerMsg("server started on port " + port); // サーバが起動している間は。。。 while(true) { // クライアントからの接続要求を受けとり、新しいソケットを生成する Socket sock = srvsock.accept(); // FacesClientクラスのインスタンス生成 FacesClient fc = new FacesClient(this, sock); // 接続成功を伝える printServerMsg(fc.getIPStr() + " connected to the server."); fc.getClientInfo().setNnum(getWaitingCnum()); // クライアント番号設定 // クライアントスレッドを開始する fc.start(); } } catch(IOException ioe) { // 接続が失敗したことを伝える printServerMsg("connection error. closing serversocket..."); ioe.printStackTrace(); // サーバを停止する stopServer(); } } private void stopServer() { try { // サーバソケットを閉じる srvsock.close(); printServerMsg("serversocket closed"); if(jdbcflag == true) pg.close(); } catch (IOException ioe){ ioe.printStackTrace(); } } /** * mainメソッド * * @param args[] 接続待ちポート番号のみ */ public static void main(String args[]) { int portNum = 0; // 引数の数をチェック if(args.length == 1) { try { portNum = Integer.parseInt(args[0]); } catch (NumberFormatException e){ e.printStackTrace(); portNum = 0; } if(portNum > 0){ // 引数を整数型(ポート番号)にしてコンストラクタ起動 FacesServer fsrv = new FacesServer(portNum); } else { printServerMsg("invalid port number. stopped."); } } else { // 引数の数が間違ってたらエラー表示 printServerMsg("invalid number of argument. stopped."); } } } faces/FacesXML.java0100644000076600007660000004072207425146554014652 0ustar kitazawakitazawapackage jp.faces; import org.w3c.dom.*; import javax.xml.parsers.*; import java.io.*; import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.*; import java.util.*; /** * FACEs用XMLメッセージ解析クラス * * @author Jun Kitazawa * @version 0.1.3 */ public class FacesXML { private Document document; private GenDom objDom; private ClientInfo ci; private FacesClient fc; private FacesServer srv; private String DocumentStr; private JDBC pg = null; private HashMap fclist; /** * コンストラクタ(引数はクライアント情報管理オブジェクト) * * @param srv FacesServer(メインクラス) * @param fc このインスタンスを使用しているクライアントのインスタンス */ public FacesXML(FacesServer srv, FacesClient fc){ objDom = new GenDom(srv); this.srv = srv; this.fc = fc; this.ci = fc.getClientInfo(); this.pg = srv.getPG(); this.fclist = srv.getClients(); } /** * 受け取ったXMLドキュメント文字列をDOM化 * * @param str DOM化するXMLドキュメント文字列 */ public void readXML(String str){ DocumentStr = str; document = objDom.makeDom(new InputSource(new StringReader(str))); if(document != null){ document.normalize(); DocumentAnalysis(); } try { String teststr = new String(str.getBytes("EUCJIS")); //System.out.println(teststr); // ノード名表示(デバッグ用文字列 本運用のときは外す) } catch(Exception e){ e.printStackTrace(); } } /** * 部屋もしくはロビーに入って,クライアント固有の番号を得る * * @param nmdMap QNエレメントのAttributeのNodeMap */ private void processQN(NamedNodeMap nmdMap){ String appname = ""; // スタートしたクライアントに固有の番号を与える fc.sendToClient(""); //ユーザ&部屋登録 if(nmdMap != null){ // 属性が存在するなら Node n_node; int max = 0; Node max_node; if((max_node = nmdMap.getNamedItem("max")) != null){ // max属性が存在するなら try { max = Integer.parseInt(max_node.getNodeValue()); } catch(Exception e) { e.printStackTrace(); } } if((n_node = nmdMap.getNamedItem("app")) != null){ // app属性が存在するなら Node r_node; // アプリケーション名をセット appname = n_node.getNodeValue(); ci.setAppName(appname); // 自分のクライアントのアプリケーション名セット ci.setRoomNum(0); // 自分のクライアントの部屋番セット(とりあえず0(ロビールームの番号)に設定) if((r_node = nmdMap.getNamedItem("r")) != null){ // r属性が存在するなら int r = 0; try { r = Integer.parseInt(r_node.getNodeValue()); } catch(Exception e) { e.printStackTrace(); } ci.setRoomNum(r); // 自分のクライアントの部屋番セット addNewRoom(appname,r,max); } else { // r属性が存在しないなら addNewRoom(appname,0,max); } } else { // app属性が存在しないなら // アプリケーション名を"0"にセット appname = "0"; ci.setAppName(appname); } } else { // 属性が存在しないなら // アプリケーション名を"0"にセット appname = "0"; ci.setAppName(appname); } // DBのユーザテーブル(puser)にユーザID(ci.getNnum()),ユーザ名(今のところ空),アプリケーション名(appname)をセット if(!appname.equals("0")){ if(pg != null) pg.puserSet(ci.getNnum(),"",appname, srv.appUserCount(appname)); } // クライアントリストにクライアントを登録 if(fclist.get(appname) == null){ // 新しい名前のアプリケーションだったら(当然部屋番も新しい) Vector v = new Vector(); v.add(fc); fclist.put(appname,v); } else { // 新しい名前のアプリケーションでなければ Vector v = (Vector)fclist.get(appname); int index = v.indexOf(fc); if(index == -1){ // 既に存在するクライアントでなければ v.add(fc); } } } private boolean addNewRoom(String appname,int r, int max){ HashMap list = (HashMap)(srv.getRooms().get(appname)); if(list == null){ // 新しい名前のアプリケーションだったら(当然部屋番も新しい) // 指定された番号の部屋を作る RoomInfo newRoom = new RoomInfo(srv); newRoom.setAppName(appname); newRoom.setRoomNum(r, max); list = new HashMap(); list.put(new Integer(newRoom.getRoomNum()),newRoom); // ロビーが無ければロビーを作る if(r != 0){ RoomInfo newRoom0 = new RoomInfo(srv); newRoom0.setAppName(appname); newRoom0.setRoomNum(0, max); list.put(new Integer(newRoom.getRoomNum()),newRoom); } srv.getRooms().put(appname,list); // DBのアプリケーションテーブル(app)にアプリケーション名をセット if(pg != null) pg.appSet(appname); return true; } else { // 新しい名前のアプリケーションでなければ if(srv.getRoomInfo(appname,r) == null){ // 指定された番号の部屋を作る RoomInfo newRoom = new RoomInfo(srv); newRoom.setAppName(appname); newRoom.setRoomNum(r, max); list.put(new Integer(newRoom.getRoomNum()),newRoom); } else { // 新しい部屋番でなければその既存の部屋に接続する(のでなにもしない) // ただし部屋が最大人数に達していたらエラーメッセージをクライアントに送り、 // デフォルトアプリケーション(アプリケーション名0)に接続する RoomInfo ritmp = srv.getRoomInfo(appname, r); int roomMaxP = 0; if(ritmp != null) roomMaxP = ritmp.getRoomMaxP(); if(roomMaxP != 0){ if(srv.roomUserCount(appname, r) >= roomMaxP){ // エラー送信,デフォルトアプリケーションに接続 fc.sendToClient(""); appname = "0"; ci.setAppName(appname); } } } return false; } } /** * サーバが保持している情報をリクエスト * * @param nmdMap QRエレメントのAttributeのNodeMap */ private void processQR(NamedNodeMap nmdMap){ // 属性が存在するならn属性で指定した名前のノードの内容をリクエスト if(nmdMap != null){ String requestedNodeName; Node n_node; if((n_node = nmdMap.getNamedItem("n")) != null){ RoomInfo ritmp = srv.getRoomInfo(ci.getAppName(), ci.getRoomNum()); if(ritmp != null){ if(n_node.getNodeValue().equals("COUNT")){ // リクエストされたノードの名前がCOUNTだったら fc.sendToClient(ritmp.outputLogCount()); } else { fc.sendToClient(ritmp.outputByNodeName(n_node)); } } } else { // 保持しているノード全部送る RoomInfo ritmp = srv.getRoomInfo(ci.getAppName(), ci.getRoomNum()); if(ritmp != null) fc.sendToClient(ritmp.outputAll()); } } // 属性が存在しないならサーバが保持しているすべての情報をリクエスト(クライアント側から) else { RoomInfo ritmp = srv.getRoomInfo(ci.getAppName(), ci.getRoomNum()); if(ritmp != null){ fc.sendToClient(ritmp.outputAll()); } } } /** * サーバが保持している情報をファイルにセーブ * * @param nmdMap QFエレメントのAttributeのNodeMap */ private void processQF(NamedNodeMap nmdMap){ // 属性が存在するならn属性で指定した名前のノードの内容をファイルにセーブ RoomInfo ritmp = srv.getRoomInfo(ci.getAppName(), ci.getRoomNum()); if(nmdMap != null){ Node n_node; if((n_node = nmdMap.getNamedItem("n")) != null){ if(ritmp != null) fc.sendToClient(ritmp.saveByNodeName(n_node)); } else { // 保持しているノード全部送る if(ritmp != null) fc.sendToClient(ritmp.saveAll()); } } // 属性が存在しないならサーバが保持しているすべての情報をファイルにセーブ else { if(ritmp != null) fc.sendToClient(ritmp.saveAll()); } } /** * サーバが保持している情報を消去 * * @param nmdMap QEエレメントのAttributeのNodeMap */ private void processQE(NamedNodeMap nmdMap){ // 属性が存在するならn属性で指定した名前のノードを消去 RoomInfo ritmp = srv.getRoomInfo(ci.getAppName() ,ci.getRoomNum()); if(nmdMap != null && ritmp != null){ Node n_node; if((n_node = nmdMap.getNamedItem("n")) != null){ Node key_node; if((key_node = nmdMap.getNamedItem("key")) != null){ if(n_node.getNodeValue().equals("all")){ ritmp.clearByKey(key_node); } else { ritmp.clearByNodeNameAndKey(n_node, key_node); } } else { Node self_node = nmdMap.getNamedItem("self"); if(n_node.getNodeValue().equals("all")){ if(self_node != null){ ritmp.clearBySelf(self_node); } else { ritmp.clearAll(); } } else { if(self_node != null){ ritmp.clearByNodeNameAndSelf(n_node, self_node); } else { ritmp.clearByNodeName(n_node); } } } } else { // 保持しているノードすべて消去 if(ritmp != null) ritmp.clearAll(); } } // 属性が存在しないならサーバが保持しているすべての情報を消去 else { if(ritmp != null) ritmp.clearAll(); } } /** * サーバにカウンタ名と待機カウントを送信 * * @param nmdMap QSエレメントのAttributeのNodeMap */ private void processQS(NamedNodeMap nmdMap, int self){ // 属性が存在するなら RoomInfo ritmp = srv.getRoomInfo(ci.getAppName() ,ci.getRoomNum()); if(nmdMap != null && ritmp != null){ String SNodeStr; if((SNodeStr = ritmp.checkQSNode(nmdMap, self)) != null){ srv.sendToRoom(SNodeStr, ci.getAppName(), ci.getRoomNum()); } } } /** * ロビーの情報から空き部屋番号を返す。 * * @param nmdMap QERエレメントのAttributeのNodeMap */ private void processQER(NamedNodeMap nmdMap){ // 属性が存在するなら RoomInfo ritmp = srv.getRoomInfo(ci.getAppName() ,ci.getRoomNum()); if(nmdMap != null && ritmp != null){ String ErNodeStr; if((ErNodeStr = ritmp.checkQERNode(nmdMap)) != null){ srv.sendToRoom(ErNodeStr, ci.getAppName(), ci.getRoomNum()); } } } /** * サーバ上の正確な時刻を送信 * * @param nmdMap QTエレメントのAttributeのNodeMap */ private void processQT(NamedNodeMap nmdMap){ CalendarFormat cf = new CalendarFormat(); fc.sendToClient(cf.getDateTStrFormat()); } /** * n属性で指定されたクライアント番号のクライアントを消去 * * @param nmdMap DエレメントのAttributeのNodeMap */ private void processD(NamedNodeMap nmdMap){ if(nmdMap != null){ String requestedClientID; Node n_node; if((n_node = nmdMap.getNamedItem("n")) != null){ requestedClientID = n_node.getNodeValue(); FacesClient fcc; if((fcc = srv.getFacesClientFromID(Integer.parseInt(requestedClientID))) != null){ //srv.deleteClient(fcc); RoomInfo ritmp = srv.getRoomInfo(ci.getAppName() ,0); if(ritmp != null) ritmp.deleteLogNode(Integer.parseInt(requestedClientID)); ritmp = srv.getRoomInfo(ci.getAppName(), ci.getRoomNum()); if(ritmp != null) ritmp.deleteSelfSubNode(Integer.parseInt(requestedClientID)); // 要素self=selfnameのノード削除 } } } } /** * (クライアントから送られてきたドキュメントの)トップノードがQN,QR,QF,QE,QS,Dのいずれかでないノードの処理 * * @param node 素通し配信(もしくはサーバのメモリ上に残した上で配信)するノード */ private void processUserNode(Node node){ NamedNodeMap nmdMap; Node fixed = node.cloneNode(true); // 送信用にsaveとkeyをあとで消す if((nmdMap = node.getAttributes()) != null){ // 属性が存在するなら Node saveattr = nmdMap.getNamedItem("save"); Node toattr = nmdMap.getNamedItem("to"); boolean allsave = false; if(saveattr != null){ RoomInfo ritmp = null; // save属性とto属性両方ある場合は、toで指定された部屋でsave if(saveattr != null && toattr != null){ // to属性の値がallだったら全ての部屋番でsave if(toattr.getNodeValue().equals("all")){ HashMap list = (HashMap)(srv.getRooms().get(ci.getAppName())); Collection valueSet = list.values(); Iterator itr = valueSet.iterator(); allsave = true; while(itr.hasNext()){ ritmp = (RoomInfo)itr.next(); if(saveattr.getNodeValue().equals("1")){ //情報を配列でない形で保持する場合(部屋単位) // save if(ritmp != null) ritmp.checkNodeName(node); } else { //情報を配列で保持する場合(部屋単位) // ノード名がLOGの時の処理は, // Dノードを受信したときに対処 if(ritmp != null) ritmp.checkNodeListName(node); } } } // to属性の値が番号だったら番号で指定されたクライアントの属する部屋でsave else { int toid = 0; try { toid = Integer.parseInt(toattr.getNodeValue()); } catch(Exception e){ e.printStackTrace(); } if(toid != 0){ FacesClient toClient = srv.getFacesClientFromID(toid); if(toClient != null){ int toRoomNum = toClient.getClientInfo().getRoomNum(); ritmp = srv.getRoomInfo(ci.getAppName() , toRoomNum); } } } } else { ritmp = srv.getRoomInfo(ci.getAppName() ,ci.getRoomNum()); } //情報を配列で無い形で保持する場合(部屋単位) if(saveattr.getNodeValue().equals("1")){ // save if(ritmp != null) ritmp.checkNodeName(node); } else { //情報を配列で保持する場合(部屋単位) // ノード名がLOGの時の処理は, // Dノードを受信したときに対処 if(ritmp != null) ritmp.checkNodeListName(node); Node subattr = nmdMap.getNamedItem("key"); // sendToRoom時にkeyを消す if(subattr != null) ((Element)fixed).removeAttribute("key"); } // sendToRoom時にsaveを消す ((Element)fixed).removeAttribute("save"); // sendToRoom時にselfを消す NamedNodeMap nmdMap2 = fixed.getAttributes(); if(nmdMap2 != null){ if(nmdMap2.getNamedItem("self") != null){ ((Element)fixed).removeAttribute("self"); } } } // to属性が付いていたら,特定のIDをもつクライアントのみに送信 if(toattr != null){ int toid = 0; // to属性の値がallだったら部屋番に関らず同じアプリの全員に送る if(toattr.getNodeValue().equals("all")){ srv.sendToApp(RoomInfo.getNode(fixed), ci.getAppName()); return; } // to属性の値が番号なら else { try { toid = Integer.parseInt(toattr.getNodeValue()); } catch(Exception e){ e.printStackTrace(); } if(toid != 0){ ((Element)fixed).removeAttribute("to"); FacesClient fcto = srv.getFacesClientFromID(toid); if(fcto != null){ fcto.sendToClient(RoomInfo.getNode(fixed)); } return; } } } } // ブロードキャスト srv.sendToRoom(RoomInfo.getNode(fixed), ci.getAppName(), ci.getRoomNum()); } /** * 受け取ったXMLドキュメント文字列をDOM化し、 * 要素、属性の種類に応じて処理する。 * */ private void DocumentAnalysis(){ Node node = document.getFirstChild(); NamedNodeMap nmdMap = node.getAttributes(); if(node.getNodeName().equals("QN")){ // 部屋もしくはロビーに入って,クライアント固有の番号を得る processQN(nmdMap); } else if(node.getNodeName().equals("QR")){ // サーバが保持している情報をリクエスト processQR(nmdMap); } else if(node.getNodeName().equals("QF")){ // サーバが保持している情報をファイルにセーブ processQF(nmdMap); } else if(node.getNodeName().equals("QE")){ // サーバが保持している情報を消去 processQE(nmdMap); } else if(node.getNodeName().equals("QS")){ // サーバにカウンタ名と待機カウントを送信 processQS(nmdMap, ci.getNnum()); } else if(node.getNodeName().equals("QT")){ // サーバ上の正確な時刻を送信 processQT(nmdMap); } else if(node.getNodeName().equals("QER")){ // ロビーの情報から空き部屋番号を返す。 processQER(nmdMap); } else if(node.getNodeName().equals("D")){ // n属性で指定されたクライアント番号のクライアントを消去 processD(nmdMap); } else { // クライアントから送られてきたドキュメントのトップノードがQN,QR,QF,QE,QS,Dのいずれかでなければ processUserNode(node); } } } /** * * DOMオブジェクト生成 * */ class GenDom extends DefaultHandler { private XmlErrMap errMap; private boolean hm; private FacesServer srv; /** * エラーメッセージマップ生成。 * */ public GenDom(FacesServer srv){ errMap = srv.getXmlErrMap(); } /** * DOMオブジェクト生成 * * @param in 入力ソース * @return Documentインスタンス */ public Document makeDom(InputSource in){ Document document = null; try { DocumentBuilder docBld = DocumentBuilderFactory.newInstance().newDocumentBuilder(); if(in != null){ document = docBld.parse(in); document.normalize(); } } catch(IOException ioe){ ioe.printStackTrace(); return null; } catch(SAXParseException saxpe){ System.out.println("\nXML error in line" + saxpe.getLineNumber()); System.out.println(saxpe.getMessage()); if(errMap.getLoaded()){ System.out.println(errMap.getErrMessage(saxpe.getMessage())); } return null; } catch(ParserConfigurationException pce){ pce.printStackTrace(); return null; } catch(SAXException saxe){ System.out.println(saxe.getMessage()); return null; } return document; } } faces/JDBC.java0100644000076600007660000001136207425146554013750 0ustar kitazawakitazawapackage jp.faces; import java.sql.*; /** * JDBCによるSQLデータベースへの接続とテーブル操作を扱う * * @author Jun Kitazawa * @version 0.1.3 */ public class JDBC { private Connection Conn; /** * SQLデータベースサーバへ接続 * 現在接続先とデータベース名がハードコードされているが,ファイルから読み込むよう変更予定 */ public JDBC(){ try { // Load JDBC-ODBC Bridge Driver Class.forName("org.postgresql.Driver"); String strConn = "jdbc:postgresql://192.168.254.10:5432/kitazawa"; // Connect to DBMS Conn = DriverManager.getConnection( strConn, "kitazawa", "" ); } catch ( Exception e ) { System.out.println( "Error: " + e); e.printStackTrace(); } } /** * SQL命令文字列(SELECT文)を実行 * * @param sqlstr SQL命令文字列(SELECT文) * @return ResultSetインスタンス */ public ResultSet sqlexec(String sqlstr) { ResultSet rs; try { // Execute SELECT query. Statement st = Conn.createStatement(); //java.sql.ResultSet rs = st.executeQuery("SELECT * from BookTable"); rs = st.executeQuery(sqlstr); // Show result /* while ( rs.next() ) { int nBookID = rs.getInt("BookID"); String strTitle = rs.getString("Title"); System.out.print("BookID: " + nBookID ); System.out.println(" Title: " + strTitle ); } */ //rs.close(); return rs; } catch ( Exception e ) { System.out.println( "Error: " + e); e.printStackTrace(); return null; } } /** * ResultSet内の項目数を数える * * @param rs ResultSetインスタンス * @return 項目数 */ public int ResultCount(ResultSet rs){ int count = 0; if(rs != null){ try { while ( rs.next() ) { count++; } rs.close(); } catch ( Exception e ) { System.out.println( "Error: " + e); e.printStackTrace(); } } return count; } /** * SQL命令文字列(SELECT文)を実行 * * @param sqlstr 結果を返さないSQL命令文字列(DELETE,INSERT,UPDATE文) * @return 変更した項目数 */ public int sqlupdate(String sqlstr) { int row = -1; try { // Execute query. Statement st = Conn.createStatement(); row = st.executeUpdate(sqlstr); } catch ( Exception e ) { System.out.println( "Error: " + e); e.printStackTrace(); } return row; } /** * アプリケーション名をappテーブルにセット * * @param appname アプリケーション名 */ public synchronized void appSet(String appname){ sqlupdate("DELETE FROM app WHERE appname = '" + appname +"'"); sqlupdate("INSERT INTO app VALUES('" + appname + "',0)"); } /** * ユーザをpuserテーブルにセットし、新しいユーザ数をappテーブルにセット * * @param id ユーザID * @param username ユーザ名(現在未使用) * @param appname アプリケーション名 * @param count 新しいユーザ数 */ public synchronized void puserSet(int id, String username, String appname, int count){ sqlupdate("DELETE FROM puser WHERE userid = " + id); sqlupdate("INSERT INTO puser VALUES(" + id + ",'" + username + "','" + appname + "')"); //int row = ResultCount(sqlexec("SELECT * from puser where appname = '" + appname + "'")); //sqlupdate("UPDATE app SET usercount = " + row + " WHERE appname = '" + appname + "'"); if(count != -1){ sqlupdate("UPDATE app SET usercount = " + count + " WHERE appname = '" + appname + "'"); } } /** * ユーザをpuserテーブルから削除し、新しいユーザ数をappテーブルにセット * * @param id ユーザID * @param appname アプリケーション名 * @param count 新しいユーザ数 */ public void puserDelete(int id, String appname, int count){ sqlupdate("DELETE FROM puser WHERE userid = " + id); //int row = ResultCount(sqlexec("SELECT * from puser where appname = '" + appname + "'")); //sqlupdate("UPDATE app SET usercount = " + row + " WHERE appname = '" + appname + "'"); if(count != -1){ sqlupdate("UPDATE app SET usercount = " + count + " WHERE appname = '" + appname + "'"); } else { } } /** * アプリケーション名をappテーブルから削除 * * @param appname アプリケーション名 */ public void appDelete(String appname){ sqlupdate("DELETE FROM app WHERE appname = '" + appname +"'"); } /** * puserテーブルとappテーブルを全クリア */ public void clearTables(){ sqlupdate("DELETE FROM puser"); //sqlupdate("DELETE FROM app"); sqlupdate("UPDATE app SET usercount = 0"); } /** * データベース接続を閉じる */ public void close() { try { clearTables(); Conn.close(); } catch ( Exception e ) { System.out.println( "Error: " + e); e.printStackTrace(); } } } faces/RoomInfo.java0100644000076600007660000004651207425146554015003 0ustar kitazawakitazawapackage jp.faces; import java.util.*; import java.io.*; import org.w3c.dom.*; import javax.xml.parsers.*; import org.apache.crimson.tree.*; /** * 部屋情報管理 * * @author Jun Kitazawa * @version 0.1.3 */ public class RoomInfo { private HashMap nodeNameshm = new HashMap(); //リストで無い形で保持するノードの名前リスト // saveをキーにしたHashMap(要素はkeyをキーにしたHashMap(要素はNode)) private HashMap nodeSaveMap = new HashMap(); private String AppName; // クライアントが所属しているアプリケーションの名前 private int roomNum = -1; // クライアントが所属している部屋番号 private int roomMaxP = 0; // 部屋に入れる人数の最大値(デフォルト値(0)なら無制限) private SyncCounters syncCount; private FacesServer srv; /* * 部屋クラスのコンストラクタ * @param server サーバオブジェクト(部屋の人数を知るときに参照する) */ public RoomInfo(FacesServer server){ srv = server; syncCount = new SyncCounters(srv); // カウンタセットのインスタンス } public SyncCounters getSyncCounters(){ return syncCount; } /** * XML文字列をファイルにセーブ * * @param xmlstr XML文字列 * @param prefix ファイル名に付けるプレフィクス * @return SERVERMSG要素のみのXMLドキュメント文字列 * */ private String FileSave(String xmlstr, String prefix){ String timestr = (new Long(System.currentTimeMillis())).toString(); String to_name = prefix + timestr + ".xml"; File to_file = new File(to_name); if(to_file.exists()){ if(!to_file.canWrite()){ System.out.println(""); return ""; } } else { String parent = to_file.getParent(); // デスティネーションディレクトリを取得 if(parent == null) parent = System.getProperty("user.dir"); // カレントディレクトリ File dir = new File(parent); // ファイルに変換 if(!dir.exists()){ System.out.println(""); return ""; } if(dir.isFile()){ System.out.println(""); return ""; } if(!dir.canWrite()){ System.out.println(""); return ""; } } // ここまでくればOK。 FileOutputStream to = null; // デスティネーションへの書き込み用のストリーム try { byte[] buffer = xmlstr.getBytes(); to = new FileOutputStream(to_file); // 出力ストリームの作成 to.write(buffer); } catch(Exception e){ e.printStackTrace(); } finally { if(to != null) { try { to.close(); } catch (IOException ioe){ ioe.printStackTrace(); } } } System.out.println(""); return ""; } /** * 保持しているノード配列の中の指定されたノード名のノードをXMLドキュメント文字列にしてファイルにセーブ * * @param nodename セーブしたいノード名 * @return SERVERMSG要素のみのXMLドキュメント文字列 */ public String saveByNodeName(Node node){ // 文字列をファイルにセーブ return FileSave(outputByNodeName(node), AppName + "_" + node.getNodeValue() + "_"); } /** * 保持しているノード配列の中のノード全てをXMLドキュメント文字列にしてファイルにセーブ * * @return SERVERMSG要素のみのXMLドキュメント文字列 */ public String saveAll(){ // 文字列をファイルにセーブ return FileSave(outputAll(), AppName + "_"); } /** * (ロビーに)セーブされているLogノードの数をCOUNTタグで返す * * @return COUNTタグ */ public String outputLogCount(){ return ""; } /** * 保持しているノードの中で、リクエストされたノード名のものを出力用XMLドキュメントに整形 * クライアントからリクエストがあったとき用 * * @param savenode リクエストするノード名 * @return リクエストされたノード名のノードを文字列にしたもの */ public String outputByNodeName(Node savenode){ Document doc = new XmlDocument(); Node node = (Node)nodeNameshm.get(savenode.getNodeValue()); if(node != null){ Node listnode = doc.importNode(node,true); // XML整形 NamedNodeMap nmdMap = listnode.getAttributes(); if(nmdMap != null){ if(nmdMap.getNamedItem("self") != null){ ((Element)listnode).removeAttribute("self"); } if(nmdMap.getNamedItem("to") != null){ ((Element)listnode).removeAttribute("to"); } } doc.appendChild(listnode); return getNode(doc.getDocumentElement()); } HashMap nodeSubMap = (HashMap)nodeSaveMap.get(savenode.getNodeValue()); if(nodeSubMap != null){ // XML整形 //Document doc = new XmlDocument(); Element e = doc.createElement(savenode.getNodeValue()); doc.appendChild(e); Collection valueSet = nodeSubMap.values(); Iterator itro = valueSet.iterator(); while(itro.hasNext()){ Node childnode = doc.importNode((Node)itro.next(),true); ((Element)childnode).removeAttribute("save"); ((Element)childnode).removeAttribute("key"); NamedNodeMap nmdMap = childnode.getAttributes(); if(nmdMap != null){ if(nmdMap.getNamedItem("self") != null){ ((Element)childnode).removeAttribute("self"); } if(nmdMap.getNamedItem("to") != null){ ((Element)childnode).removeAttribute("to"); } } e.appendChild(childnode); } return getNode(doc.getDocumentElement()); } return "<" + savenode.getNodeValue() + "/>"; // 一致するノードがなかった } /** * 保持しているノードをすべて消去 */ public void clearAll(){ nodeNameshm.clear(); nodeSaveMap.clear(); } /** * 指定されたノード名のノードをすべて消去 */ public void clearByNodeName(Node savenode){ if(nodeNameshm.remove(savenode.getNodeValue()) != null){ return; } if(nodeSaveMap.remove(savenode.getNodeValue()) != null){ return; } } /** * 指定されたノード名の指定されたキーをもつノードを消去 */ public void clearByNodeNameAndKey(Node savenode, Node keynode){ HashMap nodeSubMap = (HashMap)nodeSaveMap.get(savenode.getNodeValue()); if(nodeSubMap != null){ nodeSubMap.remove(keynode.getNodeValue()); } } /** * 指定されたノード名の指定されたselfnameをもつノードを消去 */ public void clearByNodeNameAndSelf(Node savenode, Node selfnode){ String savenodestr = savenode.getNodeValue(); String selfnodestr = selfnode.getNodeValue(); clearByNodeNameAndSelfString(savenodestr, selfnodestr); } private void clearByNodeNameAndSelfString(String savenode, String selfnode){ Node node = (Node)nodeNameshm.get(savenode); if(node != null){ NamedNodeMap nmdMap = node.getAttributes(); if(nmdMap != null){ Node tmpselfnode; if((tmpselfnode = nmdMap.getNamedItem("self")) != null){ if(tmpselfnode.getNodeValue().equals(selfnode)){ nodeNameshm.remove(savenode); } } } } HashMap nodeSubMap = (HashMap)nodeSaveMap.get(savenode); if(nodeSubMap != null){ Collection valueSet = nodeSubMap.values(); Iterator itr = valueSet.iterator(); while(itr.hasNext()){ Node tmpnode = (Node)itr.next(); NamedNodeMap nmdMap = tmpnode.getAttributes(); if(nmdMap != null){ Node tmpselfnode; if((tmpselfnode = nmdMap.getNamedItem("self")) != null){ if(tmpselfnode.getNodeValue().equals(selfnode)){ itr.remove(); } } } } } } /** * 指定されたselfnameをもつノードをすべて消去 */ public void clearBySelf(Node selfnode){ Set keySet = nodeSaveMap.keySet(); Iterator itr = keySet.iterator(); while(itr.hasNext()){ String savenodestr = (String)itr.next(); clearByNodeNameAndSelfString(savenodestr, selfnode.getNodeValue()); } } /** * 指定されたkeyをもつノードをすべて消去 */ public void clearByKey(Node keynode){ Collection valueSet = nodeSaveMap.values(); Iterator itr = valueSet.iterator(); while(itr.hasNext()){ ((HashMap)itr.next()).remove(keynode.getNodeValue()); } } /** * 保持しているノードをすべてXMLドキュメント文字列に整形 * クライアントからリクエストがあったとき用に * * @return XMLドキュメント文字列 */ public String outputAll(){ Document doc = new XmlDocument(); Element rootElement = doc.createElement("R"); doc.appendChild(rootElement); Collection valueSet = nodeNameshm.values(); Iterator itr = valueSet.iterator(); while(itr.hasNext()){ Node listnode = doc.importNode((Node)itr.next(), true); // XML整形 rootElement.appendChild(listnode); } Set saveMapSet = nodeSaveMap.keySet(); itr = saveMapSet.iterator(); while(itr.hasNext()){ String savenodestr = (String)itr.next(); HashMap nodeSubMap = (HashMap)nodeSaveMap.get(savenodestr); Element e = null; try { e = doc.createElement(savenodestr); rootElement.appendChild(e); } catch(DOMException dome){ dome.printStackTrace(); } valueSet = nodeSubMap.values(); Iterator itro = valueSet.iterator(); while(itro.hasNext()){ Node childnode = doc.importNode((Node)itro.next(),true); ((Element)childnode).removeAttribute("save"); ((Element)childnode).removeAttribute("key"); NamedNodeMap nmdMap = childnode.getAttributes(); if(nmdMap != null){ if(nmdMap.getNamedItem("self") != null){ ((Element)childnode).removeAttribute("self"); } if(nmdMap.getNamedItem("to") != null){ ((Element)childnode).removeAttribute("to"); } } if(e != null) e.appendChild(childnode); } } return getNode(doc.getDocumentElement()); } /** * QERエレメントをを解析し、空き部屋番号を返す * * @param nmdMap QERエレメントの要素 */ public String checkQERNode(NamedNodeMap nmdMap){ int maxint; Node max_node; if((max_node = nmdMap.getNamedItem("max")) != null){ // n属性(カウンタ名)があれば try { maxint = Integer.parseInt(max_node.getNodeValue()); } catch(Exception e){ maxint = 5; e.printStackTrace(); } return ""; } else { return null; } } /** * QSエレメントを解析し、カウンタを生成もしくはインクリメントする。maxに達した場合カウンタを * 削除しSノードを送信 * @param nmdMap QSエレメントの要素 * @return カウンタがmaxに達している場合Sノード文字列, そうでない場合はnull */ public String checkQSNode(NamedNodeMap nmdMap, int self){ //NamedNodeMap nmdMap = node.getAttributes(); // 属性を得る String n; // カウンタ名 int maxint = 1; // 待機カウント int rn; // max="Rx" flag="Rx"の場合のxの部分のが表す部屋番号 Node n_node; Node max_node; Node flag_node; if((n_node = nmdMap.getNamedItem("n")) != null){ // n属性(カウンタ名)があれば n=n_node.getNodeValue(); if((max_node = nmdMap.getNamedItem("max")) != null){ // max属性(待機カウント)があれば try { maxint = Integer.parseInt(max_node.getNodeValue()); } catch(Exception e){ String maxstr = max_node.getNodeValue(); if(maxstr.startsWith("R")){ try { rn = Integer.parseInt(maxstr.substring(1)); maxint = srv.roomUserCount(AppName, rn); } catch(Exception ee){ maxint = 1; } } else { maxint = 1; } } } else { // max属性(待機カウント)がなければ //maxint = 1; // flag属性(待機カウント(部屋の全員にフラグを立てる))があれば if((flag_node = nmdMap.getNamedItem("flag")) != null){ String flagstr = flag_node.getNodeValue(); if(flagstr.startsWith("R")){ try { rn = Integer.parseInt(flagstr.substring(1)); if(!syncCount.evalRoom(AppName, rn, n, self)){ return ""; } else { return null; } } catch(Exception ee){ maxint = 1; } } else { maxint = 1; } } } } else { // n属性(カウンタ名)がなければ(カウンタはデフォルトカウンタ) if((max_node = nmdMap.getNamedItem("max")) != null){ // max属性(待機カウント)があれば n = "0"; try { maxint = Integer.parseInt(max_node.getNodeValue()); } catch(Exception e){ maxint = 1; } } else { // max属性(待機カウント)がなければ n = "0"; maxint = 1; } } // カウンタをセットする。もしカウンタがmaxに達していたらSノードを送信 if(!syncCount.setCounter(n,maxint)){ return ""; } else if(maxint <= 1){ return ""; } else { return null; } } /** * 情報を配列で無い形で保持する場合 * saveを削除してリスト更新 * * @param node ノードインスタンス */ public void checkNodeName(Node node){ ((Element)node).removeAttribute("save"); nodeNameshm.put(node.getNodeName(),node); } /** * 情報を配列で保持する場合 * すでにリストにあるかどうかチェックし、なければリストに付加、あれば更新 * * @param node ノードインスタンス */ public void checkNodeListName(Node node){ NamedNodeMap nmdMap = node.getAttributes(); Node savenode = null; Node subnode = null; if(nmdMap != null){ savenode = nmdMap.getNamedItem("save"); subnode = nmdMap.getNamedItem("key"); } HashMap nodelist = null; if(savenode != null) nodelist = (HashMap)nodeSaveMap.get(savenode.getNodeValue()); if(nodelist != null && subnode != null){ nodelist.put(subnode.getNodeValue(), node); } else { HashMap nodeSubMap = new HashMap(); // keyをキーにしたHashMap(要素はNode) if(subnode != null) nodeSubMap.put(subnode.getNodeValue(), node); if(savenode != null) nodeSaveMap.put(savenode.getNodeValue(), nodeSubMap); } } /** * ロビーにのこしてある自分が書いたLOGノードを消去する * リストにあるかどうかチェックし、あれば消去 * * @param n クライアントID */ public void deleteLogNode(int n){ Collection valueSet = nodeSaveMap.values(); Iterator itr = valueSet.iterator(); while(itr.hasNext()){ HashMap nodeSubMap = (HashMap)itr.next(); // ノード名が一致した(リストにあった)ら Node listnode = (Node)nodeSubMap.get(Integer.toString(n)); if(listnode != null){ if(listnode.getNodeName().equals("LOG")){ nodeSubMap.remove(Integer.toString(n)); } } } } /** * セーブされているLogノードをカウントする * * @return LOGノードの数 */ private int countLogNode(){ Collection valueSet = nodeSaveMap.values(); Iterator itr = valueSet.iterator(); int cnt = 0; while(itr.hasNext()){ HashMap nodeSubMap = (HashMap)itr.next(); Collection valueSeto = nodeSubMap.values(); Iterator itro = valueSeto.iterator(); while(itro.hasNext()){ Node listnode = (Node)itro.next(); if(listnode != null){ if(listnode.getNodeName().equals("LOG")){ cnt++; } } } } return cnt; } /** * Logノードをしらべて空き部屋を探す * * */ private int getEmptyRoomNum(int max){ Collection valueSet = nodeSaveMap.values(); Iterator itr = valueSet.iterator(); int cnt = 0; Node rnode; int count[] = new int[256]; for(int i = 0; i < 256; i++){ count[i] = 0; } while(itr.hasNext()){ HashMap nodeSubMap = (HashMap)itr.next(); Collection valueSeto = nodeSubMap.values(); Iterator itro = valueSeto.iterator(); while(itro.hasNext()){ Node listnode = (Node)itro.next(); if(listnode != null){ if(listnode.getNodeName().equals("LOG")){ NamedNodeMap nmdMap = listnode.getAttributes(); if((rnode =nmdMap.getNamedItem("r")) != null){ try { int rnum = Integer.parseInt(rnode.getNodeValue()); count[rnum]++; } catch(Exception e){ e.printStackTrace(); } } } } } } for(int i = 1; i < 256; i++){ if(count[i] < max){ return i; } } return -1; } /** * ログアウトした部屋で要素self=selfnameのデータを消去する * リストにあるかどうかチェックし、あれば消去 * * @param n クライアントID */ public void deleteSelfSubNode(int n){ Collection valueSet = nodeSaveMap.values(); Iterator itr = valueSet.iterator(); while(itr.hasNext()){ HashMap nodeSubMap = (HashMap)itr.next(); // ノード名が一致した(リストにあった)ら Collection valueSetSub = nodeSubMap.values(); Iterator itro = valueSetSub.iterator(); while(itro.hasNext()){ NamedNodeMap nmdMap = ((Node)itro.next()).getAttributes(); Node self_node; if((self_node = nmdMap.getNamedItem("self")) != null){ if(self_node.getNodeValue().equals(Integer.toString(n))){ itro.remove(); } } } } valueSet = nodeNameshm.values(); itr = valueSet.iterator(); while(itr.hasNext()){ NamedNodeMap nmdMap = ((Node)itr.next()).getAttributes(); Node self_node; if((self_node = nmdMap.getNamedItem("self")) != null){ if(self_node.getNodeValue().equals(Integer.toString(n))){ itr.remove(); } } } } /** * ノードを文字列にする * * @param node 文字列にしたいノードインスタンス * @return XML文字列 */ public static String getNode(Node node){ String nstr = ""; if (node.getNodeType() == Node.TEXT_NODE) { //System.out.print(node.getNodeValue()); nstr = nstr + node.getNodeValue(); } else if (node.getNodeType() == Node.ELEMENT_NODE){ //System.out.print("<"); //System.out.print(node.getNodeName()); nstr = nstr + "<" + node.getNodeName(); NamedNodeMap nmdMap = node.getAttributes(); // 属性を得る if(nmdMap != null){ // 属性が存在したら for(int nSb = 0; nSb < nmdMap.getLength(); nSb++){ // 属性をすべてスキャン String nn = nmdMap.item(nSb).getNodeName(); String nv = nmdMap.item(nSb).getNodeValue(); //System.out.print(" " + nn + "=\"" + nv + "\""); nstr = nstr + " " + nn + "=\"" + nv + "\""; } } if(!node.hasChildNodes()){ //System.out.print("/>"); nstr = nstr + "/>"; } else { //System.out.print(">"); nstr = nstr + ">"; for (Node childnode = node.getFirstChild(); childnode != null; childnode = childnode.getNextSibling() ){ //getNode(childnode); nstr = nstr + getNode(childnode); } //System.out.print("\n"); nstr = nstr + ""; } } return nstr; } /** * アプリケーション名をセットする * * @param app アプリケーション名 */ public final void setAppName(String app){ AppName = app; } /** * 部屋番号をセットする * 部屋に入れる人数は無制限 * @param r 部屋番号 */ public final void setRoomNum(int r){ roomNum = r; } /** * 部屋に入れる最大人数をセットする * * @param r 部屋番号 * @param max 部屋に入れる人数の最大値 0なら無制限 */ public final void setRoomNum(int r, int max){ roomNum = r; roomMaxP = max; } /** * アプリケーション名をゲットする * * @return アプリケーション名の文字列 */ public final String getAppName(){ return AppName; } /** * 部屋番号をゲットする * * @return アプリケーション名の文字列 */ public final int getRoomNum(){ return roomNum; } /** * 部屋に入れる最大人数をgetする * * @return 部屋に入れる最大人数 */ public final int getRoomMaxP(){ return roomMaxP; } } faces/SyncCounters.java0100644000076600007660000001154307425146554015706 0ustar kitazawakitazawapackage jp.faces; import java.util.*; /** * クライアント同士のタイミング同期のためのカウンタ集合を管理する * * @author Jun Kitazawa * @version 0.1.3 * @see RoomInfo */ public class SyncCounters { private List counters = new Vector(); private FacesServer srv; public SyncCounters(FacesServer s){ srv = s; } /* * 部屋の全員がQSを送ったかどうかチェック * * @param appname アプリケーション名 * @param roomnum 部屋番号 * @param counterName カウンタ名 * @param selfname クライアント固有の番号 * * @return 全員がQSを送り済ならfalse それ以外はtrue * */ public boolean evalRoom(String appname, int roomnum, String counterName, int selfname){ Iterator itr = counters.iterator(); System.out.println("evalRoom selfname " + selfname); while(itr.hasNext()){ Counter cntr = (Counter)itr.next(); // すでにその名前のカウンタが存在するならカウンタ値を更新 if(cntr.getCounterName().equals(counterName)){ cntr.qsListAdd(selfname); if(!cntr.qsAll(appname, roomnum)){ counters.remove(cntr); // 全員からQSを受けているのでのでカウンタ削除 // Sノード送信 return false; } else { return true; } } } // その名前のカウンタが存在しないなら if(srv.roomUserCount(appname, roomnum) > 1){ // 2人以上いるならカウンタ設定 Counter newCnt = new Counter(counterName, 0 , srv); counters.add(newCnt); newCnt.qsListAdd(selfname); return true; } else { // 1人以下なら即座にSノード送信 return false; } } /* * 誰かがログアウトした時点で部屋の全員がQSを送ったかどうかチェック * * @param appname アプリケーション名 * @param roomnum 部屋番号 * * @return Sノード送信するカウンタ名リスト * */ public synchronized List evalRoomForDelete(String appname, int roomnum){ List cntlst = new Vector(); Iterator itr = counters.iterator(); while(itr.hasNext()){ try { Counter cntr = (Counter)itr.next(); if(!cntr.qsAll(appname, roomnum)){ // このカウンタ名はSノード送信 cntlst.add(cntr.getCounterName()); counters.remove(cntr); // 全員からQSを受けているのでのでカウンタ削除 } } catch(Exception e){ break; } } return cntlst; } /** * カウンタをインクリメント,同名のカウンタが存在していなければ新規に作る * * @param counterName カウンタ名 * @param maxCount 待機カウント * @return カウンタが最大値に達したら false それ以外はtrue * */ public boolean setCounter(String counterName, int maxCount){ Iterator itr = counters.iterator(); while(itr.hasNext()){ Counter cntr = (Counter)itr.next(); // すでにその名前のカウンタが存在するならカウンタ値を更新 if(cntr.getCounterName().equals(counterName)){ cntr.resetMaxCount(maxCount); if(!cntr.incrementCount()){ counters.remove(cntr); // カウンタがmaxに達したのでカウンタ削除 // Sノード送信 return false; } else { // 1人以下なら即座にSノード送信 return true; } } } // その名前のカウンタが存在しないなら if(maxCount > 1){ // 2人以上いるならカウンタ設定 counters.add(new Counter(counterName, maxCount, srv)); return true; } else { // Sノード送信 return false; } } } class Counter { private String counterName; private int maxCount; private int currentCount; private FacesServer srv; // Listで qs受けたクライアントのselfnameのリストを持つ private List qsList = new Vector(); public Counter(String counterName, int maxCount, FacesServer srv){ this.counterName = counterName; this.maxCount = maxCount; this.srv = srv; currentCount = 1; } public int getCurrentCount(){ return currentCount; } public String getCounterName(){ return counterName; } public void qsListAdd(int selfname){ // 既にqs受けたクライアントのselfnameのリストにselfnameがなければ付加 Integer selfnameInt = new Integer(selfname); System.out.println("selfname " + selfname); if(!qsList.contains(selfnameInt)){ System.out.println("qsList.add " + selfname); qsList.add(new Integer(selfname)); } } public boolean qsAll(String appname, int roomnum){ boolean check = false; // appname, roomnumの部屋のメンバー全員がqsListの中に含まれているかどうかチェック List appfclist = (List)(srv.getClients().get(appname)); // アプリ名が一致して Iterator itr = appfclist.iterator(); while(itr.hasNext()){ FacesClient fc = (FacesClient)itr.next(); if(roomnum == fc.getClientInfo().getRoomNum()){ // 部屋番号が一致して Integer si = new Integer(fc.getClientInfo().getNnum()); if(!qsList.contains(si)){ return true; // qsListに含まれていない(ので全員のQSが揃ってない) } } } return false; } public boolean incrementCount(){ if(currentCount >= maxCount - 1){ return false; } else { currentCount++; return true; } } public void resetMaxCount(int cnt){ maxCount = cnt; } } faces/XmlErrMap.java0100644000076600007660000000317007425146554015113 0ustar kitazawakitazawapackage jp.faces; import java.util.*; import java.io.*; /** * XML$B%(%i!<%a%C%;!<%8%^%C%W@8@.(B * * @author Jun Kitazawa * @version 0.1.3 */ public class XmlErrMap { private String stFile = "Messages_en.properties"; private Properties prop; private static boolean loaded = false; /** * $B%(%i!<%a%C%;!<%8%^%C%W$r@8@.(B */ public XmlErrMap(){ loaded = makeMsgMap(); } /** * $B%(%i!<%a%C%;!<%8%^%C%W$N@8@.$K@.8y$7$F$$$k$+$I$&$+$rJV$9(B * * @return $B%(%i!<%a%C%;!<%8%^%C%W$N@8@.$K@.8y$7$?$+$I$&$+$N??56CM(B */ public boolean getLoaded(){ return loaded; } /** * $B%(%i!<%a%C%;!<%8$N%W%m%Q%F%#%U%!%$%k$+$i(BProperties$B%*%V%8%'%/%H@8@.(B * * @return Properties$B$,@5>o$K@8@.$G$-$?$+$I$&$+$N??56CM(B */ public boolean makeMsgMap() { try { if(!loaded){ prop = new Properties(); FileInputStream fin = new FileInputStream(stFile); prop.load(fin); fin.close(); loaded = true; } return true; } catch(Exception e){ //System.out.println("no XML error message map file"); return false; } } /** * SAXParseException$B$N%(%i!<%3!<%I$+$iBP1~$9$k%(%i!<%a%C%;!<%8$rJV$9(B * * @param errCode $B%(%i!<%3!<%I(B * @return $B%(%i!<%a%C%;!<%8J8;zNs(B */ public String getErrMessage(String errCode){ String stLine, stCode; int nPos; if((nPos = errCode.indexOf("/")) > 0){ stCode = errCode.substring(nPos + 1).trim(); if((nPos = stCode.indexOf(" ")) > 0) stCode = stCode.substring(0, nPos); return (String)prop.getProperty(stCode); } else return ""; } } faces/jp/0040755000076600007660000000000007406047613013007 5ustar kitazawakitazawafaces/jp/faces/0040755000076600007660000000000007407607405014072 5ustar kitazawakitazawafaces/jp/faces/CalendarFormat.class0100644000076600007660000000345507425146705020010 0ustar kitazawakitazawa朋詐-u )= >? (@ >A BC (D (E (F (G (H (I JKL =M N OP (QRSTUVWXYZ[\]^_`abcdefgcalLjava/util/Calendar;yearLjava/lang/String;monthdayhourminutesecondweekstr()VCodeLineNumberTablegetDateStrFormat()Ljava/lang/String;getDateTStrFormat SourceFileCalendarFormat.java 45h ij *+ klm no ,- .- /- 0- 1- 2-p qrjava/lang/StringBuffer0 st n9 3-SunMonTueWedThuFriSat[/ :] jp/faces/CalendarFormatjava/lang/Objectjava/util/Calendar getInstance()Ljava/util/Calendar;get(I)Ijava/lang/IntegertoString(I)Ljava/lang/String;java/lang/Stringlength()Iappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;!()*+,-.-/-0-1-2-3-456!******`****  **  **  * * Y** * Y** * Y*  * * Y*  * * Y*  **f*3<ENW`*6*-*$*** *7v +:JZj !##)$\&b'e)k*n,t-w/}023568;896vZ Y**** * * L+7 @XH:96f Y *!*"*#*$* %* &* 'L+7 LdT;<faces/jp/faces/ClientInfo.class0100644000076600007660000000132707425146705017154 0ustar kitazawakitazawa朋詐-"     !nnumIAppNameLjava/lang/String;roomNum()VCodeLineNumberTablesetNnum(I)VgetNnum()I setAppName(Ljava/lang/String;)V setRoomNum getAppName()Ljava/lang/String; getRoomNum SourceFileClientInfo.java   jp/faces/ClientInfojava/lang/Object!   * ** "* *&"*+ /0"* 89*A*Jfaces/jp/faces/Counter.class0100644000076600007660000000406707425146705016545 0ustar kitazawakitazawa朋詐- !<= < > ? @ A BC D EFG <H I J K LM NO P QR STU V WXY Z [\ [] W^_` counterNameLjava/lang/String;maxCountI currentCountsrvLjp/faces/FacesServer;qsListLjava/util/List;,(Ljava/lang/String;ILjp/faces/FacesServer;)VCodeLineNumberTablegetCurrentCount()IgetCounterName()Ljava/lang/String; qsListAdd(I)VqsAll(Ljava/lang/String;I)ZincrementCount()Z resetMaxCount SourceFileSyncCounters.java +ajava/util/Vector )* "# $% '( &%java/lang/Integer +4b cdjava/lang/StringBuffer selfname ef eg h2i jk lm qsList.add nmo pqr stjava/util/List uvw xyjp/faces/FacesClient z{| }0 ~0 8jp/faces/Counterjava/lang/Object()Vjava/lang/SystemoutLjava/io/PrintStream;append,(Ljava/lang/String;)Ljava/lang/StringBuffer;(I)Ljava/lang/StringBuffer;toStringjava/io/PrintStreamprintln(Ljava/lang/String;)Vcontains(Ljava/lang/Object;)Zaddjp/faces/FacesServer getClients()Ljava/util/HashMap;java/util/HashMapget&(Ljava/lang/Object;)Ljava/lang/Object;iterator()Ljava/util/Iterator;java/util/Iteratornext()Ljava/lang/Object; getClientInfo()Ljp/faces/ClientInfo;jp/faces/ClientInfo getRoomNumgetNnumhasNext !"#$%&%'()*+,-T$**Y*+**-*.#/0-*.12-*.34-[ Y M Y *,. Y * Y W. "/HZ56-c>*+::<:$ Y :*.. *6GUWa78-?**d*Y`. 94-"*. :;faces/jp/faces/FacesClient.class0100644000076600007660000000535107425146705017303 0ustar kitazawakitazawa朋詐- 3Q 2R 2S TU VW 2XY Q 2Z[ \ 2]^_ T`a b c 2def Tg h i 2jkl Qm no p qr st 2u v w x yz{ | }~ q  TsrvLjp/faces/FacesServer;sockLjava/net/Socket;inLjava/io/BufferedReader;outLjava/io/PrintWriter;pxLjp/faces/FacesXML;ipstrLjava/lang/String;ciLjp/faces/ClientInfo;*(Ljp/faces/FacesServer;Ljava/net/Socket;)VCodeLineNumberTable getClientInfo()Ljp/faces/ClientInfo;run()VgetIPStr()Ljava/lang/String; sendToClient(Ljava/lang/String;)V stopClient SourceFileFacesClient.java BI 45 67  K >?jp/faces/ClientInfo @Ajp/faces/FacesXML B <=java/io/BufferedReaderjava/io/InputStreamReader SJIS B B 89java/io/PrintWriterjava/io/OutputStreamWriter B B :;java/io/IOExceptionjava/lang/StringBuffer"initilization error on Client IP: . disconnected. K M I NI B Mread error on Client IP:  M write error on Client IP: Iconnection error on Client IP: jp/faces/FacesClientjava/lang/Threadjava/net/SocketgetInetAddress()Ljava/net/InetAddress;java/net/InetAddressgetHostAddress/(Ljp/faces/FacesServer;Ljp/faces/FacesClient;)VgetInputStream()Ljava/io/InputStream;*(Ljava/io/InputStream;Ljava/lang/String;)V(Ljava/io/Reader;)VgetOutputStream()Ljava/io/OutputStream;+(Ljava/io/OutputStream;Ljava/lang/String;)V(Ljava/io/Writer;Z)Vappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;toStringjp/faces/FacesServerprintServerMsgjava/lang/ThrowableprintStackTrace(I)V(C)Ljava/lang/StringBuffer;read([CII)IreadXMLprint checkError()Z deleteClient(Ljp/faces/FacesClient;)Vclose!23456789:;<=>?@ABCD**+*,*,*Y * Y+* * YY,*YY,*NY* !-"*#1beE2 89 :;<$=1@IAeDEGIFGD* EOHIDL5Y$M,+4%W*+&W+4* , '*+&竪38L*WY(* ! N-:*#GMttE2 Y[]_ac(_.f9[MjtmoJKD*EwLMDqI*Y+) **+'*WY,* !*#E$DHNIDyA**-*.*/*0#L*WY1* !+" E <@OPfaces/jp/faces/FacesServer.class0100644000076600007660000001361207425146705017332 0ustar kitazawakitazawa朋詐-; d  ` `  ` ` `       ` `      # #   + # + + `   + ` `  ` `  H H  M ` M # `  ` M  `srvsockLjava/net/ServerSocket;roomsLjava/util/HashMap;fclistnumlistLjava/util/List;pgLjp/faces/JDBC;jdbcflagZerrMapLjp/faces/XmlErrMap;(I)VCodeLineNumberTable getXmlErrMap()Ljp/faces/XmlErrMap;getWaitingCnum()IgetPG()Ljp/faces/JDBC;getRooms()Ljava/util/HashMap; getClients getRoomInfo((Ljava/lang/String;I)Ljp/faces/RoomInfo;getFacesClientFromID(I)Ljp/faces/FacesClient; sendToRoom((Ljava/lang/String;Ljava/lang/String;I)V sendToApp'(Ljava/lang/String;Ljava/lang/String;)V appUserCount(Ljava/lang/String;)I roomUserCount(Ljava/lang/String;I)I deleteClient(Ljp/faces/FacesClient;)VprintServerMsg(Ljava/lang/String;)VgetDateStrFormat()Ljava/lang/String; runServer stopServer()Vmain([Ljava/lang/String;)V SourceFileFacesServer.java rjava/util/HashMap gh ihjava/util/Vector jk lm no jp/faces/JDBCjp/faces/RoomInfo r0 sjava/lang/Integer rs jp/faces/XmlErrMap pq s   y         jp/faces/FacesClient  y  y  y java/lang/StringBuffer   disconnected.      's (s )*  + ,-. /jp/faces/CalendarFormatstarting server... 0java/net/ServerSocket efserver started on port 12 r3 connected to the server. xy 4s5 6java/io/IOException)connection error. closing serversocket...7 8 9serversocket closed :java/lang/NumberFormatExceptionjp/faces/FacesServerinvalid port number. stopped.$invalid number of argument. stopped.java/lang/Object(Ljp/faces/FacesServer;)V setAppName setRoomNumput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;java/util/Listiterator()Ljava/util/Iterator;java/util/Iteratornext()Ljava/lang/Object;intValuehasNext()Zadd(Ljava/lang/Object;)Zget&(Ljava/lang/Object;)Ljava/lang/Object;values()Ljava/util/Collection;java/util/Collectionelements()Ljava/util/Enumeration;java/util/Enumeration nextElement getClientInfo()Ljp/faces/ClientInfo;jp/faces/ClientInfogetNnumhasMoreElements getRoomNum sendToClientsize getAppNamegetIPStrappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;toStringremove(I)Ljava/lang/StringBuffer;getSyncCounters()Ljp/faces/SyncCounters;jp/faces/SyncCountersevalRoomForDelete%(Ljava/lang/String;I)Ljava/util/List; deleteLogNodedeleteSelfSubNode puserDelete(ILjava/lang/String;I)Vjava/lang/SystemoutLjava/io/PrintStream;java/io/PrintStreamprint clearTablesaccept()Ljava/net/Socket;*(Ljp/faces/FacesServer;Ljava/net/Socket;)VsetNnumjava/lang/Threadstartjava/lang/ThrowableprintStackTracecloseparseInt!`defghihjklmnopqrst**Y*Y*Y* * * * Y Y*M,,YN-Y,W*-W*Y*uF5%#*(/677B:K;Q<V=^>l?w@ABvwt*uJxytU<=*N#-:6 = -*YWu>TVWXYZ[&\,]/^1_4Y=bAcSdz{t* uo|}t*ux~}t*utW+*+N--Y :u !&)tW*M, N=-:!:"#:$%&-u2 $'3?BLUt R*,:B!:."#:$:'6 +(&留u2 (/4;AGQtj6*,N-(-!:"#:+(&膠u" %+5!t;*+M,,)u !tD*+N-!:6""#:$'6&u* $.47At p+$%=+$*N+$'6+Y,+-./.01*-: +2W*Y3W"*+Y,4.56.0-7*+Y,8.59.56.0-7*-::;:-<:: / =: *+Y,>. .?.0-7 *-::   @*-:  :  :   : A * * -*-BCu!   2?DK]b !"#$%#( )*-%.,/5081D2I3O0Y5a6o7 tB"+Y,D.*.E.0KF*Gu@A!B t) HYIK*Ju KLstK1*  * L*MYNO+Y,P.501*OQM#Y*,RN+Y,--.S.01-$*TU-VMX1,Y*ZvvWuBWY Z^ _6a9cAeKhdjomsavq|rtvtX$*O[\1*  * ]L+YWu{| }~# t{7<*,*2^< M,Y<`YaMb1c1_u* )16faces/jp/faces/FacesXML.class0100644000076600007660000001752707425146705016535 0ustar kitazawakitazawa朋詐-                @    : 4 4 : 4  ; ; ; : ; @ ;   ; ; ; ; ; ; ; ; ; ; ; ;  ; _ _  ; ;   :   ; ; !" p# ;$ % & '( )* +, -. /0 12 34 56 7 89:documentLorg/w3c/dom/Document;objDomLjp/faces/GenDom;ciLjp/faces/ClientInfo;fcLjp/faces/FacesClient;srvLjp/faces/FacesServer; DocumentStrLjava/lang/String;pgLjp/faces/JDBC;fclistLjava/util/HashMap;/(Ljp/faces/FacesServer;Ljp/faces/FacesClient;)VCodeLineNumberTablereadXML(Ljava/lang/String;)V processQN(Lorg/w3c/dom/NamedNodeMap;)V addNewRoom(Ljava/lang/String;II)Z processQR processQF processQE processQS(Lorg/w3c/dom/NamedNodeMap;I)V processQER processQTprocessDprocessUserNode(Lorg/w3c/dom/Node;)VDocumentAnalysis()V SourceFile FacesXML.java jp/faces/GenDom ; < => ? @A BC org/xml/sax/InputSourcejava/io/StringReader D EF G H java/lang/StringEUCJIS IJ Kjava/lang/ExceptionL Mjava/lang/StringBuffer TU VmaxW XY ZU [\app ] ^_r 0 `a b\c de fgjava/util/Vector ha ij kl mCjava/util/HashMapjp/faces/RoomInfo ^njava/lang/Integer oR _ p qr sR tun vUCOUNT wU xy zU {y |Ukeyall } ~self       jp/faces/CalendarFormat U  _ _  saveto   1   org/w3c/dom/Element  y   UQN QR QF QE QS QT QER D jp/faces/FacesXMLjava/lang/Object(Ljp/faces/FacesServer;)Vjp/faces/FacesClient getClientInfo()Ljp/faces/ClientInfo;jp/faces/FacesServergetPG()Ljp/faces/JDBC; getClients()Ljava/util/HashMap;(Ljava/io/Reader;)VmakeDom1(Lorg/xml/sax/InputSource;)Lorg/w3c/dom/Document;org/w3c/dom/Node normalizegetBytes(Ljava/lang/String;)[B([B)Vjava/lang/ThrowableprintStackTraceappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;jp/faces/ClientInfogetNnum()I(I)Ljava/lang/StringBuffer;toString()Ljava/lang/String; sendToClientorg/w3c/dom/NamedNodeMap getNamedItem&(Ljava/lang/String;)Lorg/w3c/dom/Node; getNodeValueparseInt(Ljava/lang/String;)I setAppName setRoomNum(I)Vequals(Ljava/lang/Object;)Z appUserCount jp/faces/JDBCpuserSet)(ILjava/lang/String;Ljava/lang/String;I)Vget&(Ljava/lang/Object;)Ljava/lang/Object;addput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;indexOf(Ljava/lang/Object;)IgetRooms(II)V getRoomNumappSet getRoomInfo((Ljava/lang/String;I)Ljp/faces/RoomInfo; getRoomMaxP roomUserCount(Ljava/lang/String;I)I getAppNameoutputLogCountoutputByNodeName&(Lorg/w3c/dom/Node;)Ljava/lang/String; outputAllsaveByNodeNamesaveAll clearByKeyclearByNodeNameAndKey'(Lorg/w3c/dom/Node;Lorg/w3c/dom/Node;)V clearBySelfclearAllclearByNodeNameAndSelfclearByNodeName checkQSNode/(Lorg/w3c/dom/NamedNodeMap;I)Ljava/lang/String; sendToRoom((Ljava/lang/String;Ljava/lang/String;I)V checkQERNode.(Lorg/w3c/dom/NamedNodeMap;)Ljava/lang/String;getDateTStrFormatgetFacesClientFromID(I)Ljp/faces/FacesClient; deleteLogNodedeleteSelfSubNode cloneNode(Z)Lorg/w3c/dom/Node; getAttributes()Lorg/w3c/dom/NamedNodeMap;values()Ljava/util/Collection;java/util/Collectioniterator()Ljava/util/Iterator;java/util/Iteratornext()Ljava/lang/Object; checkNodeNamecheckNodeListNamehasNext()ZremoveAttributegetNode sendToApp'(Ljava/lang/String;Ljava/lang/String;)V getFirstChild()Lorg/w3c/dom/Node; getNodeName! p8***Y+*+*,*, *+ *+ &  !"#$'%/&7'J*+ **YY+***Y+MM,3AD"/02&3/437D:I< QM*Y * !"# $%+6+&'Y:()6 :+*'YNc-(M* ,+* ,+-'Y:26()6 :* ,*,.W(*,.W/M* ,+/M* ,+,/0#*** !,*,12* ,3!4Y5N-*6W* ,-7W(* ,34N-*86 -*6W=IL"DF(H,J/L=NLPSS`VgWoXwYZ\^abejkpqtuvz {|}+7AGP<*9+3::;Y*<:+=>:Y?:@YAB7W1;Y*<:+=>@YAB7W*9+7W* *+C*+D4;Y*<:+=>@YAB7Wc*+D:6 E6D*+F6*YG + H "I $%/L* ++~"(/8LP]cj~/2:++J'YNL** K* LD:-(M0*N%c*-O%S** K* LD:7*P%(** K* LDM,*,P%:(-;JZqv\** K* LDM+5+J'YN,3*,-Q%$, *,R%,*,R%* '+:>LP[** K* LDM+,+J'YNv+S'Y:$-(T0 ,Ud,-VZ+W':-(T0 ,X4,Y- ,-Z,-[,,Y ,,YR + 9 GPZdrw #*+013jB** K* LDN+*-&-+\Y:** K* L]<=?*@ACg?** K* LDM+',#,+^YN*-* K* L]LMO(P>S4_Y`M*,a%[\]n+l+J'YN_-(M*,)bY:G** KD: ,)c** K* LD: ,)d. ehik)m:n?oHp_qdrmv +eN+fYM,g':,h':6a:(T0p*9* K3::i:  j: 67 k;:(l0+m +n o擢g6()6 :  I*b:  9 L6 ** K D:** K* LD:(l01+m( +n,S':-pSq-pgq-f:W'-pWqh6(T0*-r* Ks()6 :(-phq*b: -r%*-r* K* L]:'*/2<Kahqtw+09>DNS^iqv2*tL+fM+uv0 *,w+ux0 *,y+uz0 *,{}+u|0 *,}g+u~0*,* !J+u0 *,4+u0 *,+u0 *,*+R '5=KSaiw   faces/jp/faces/GenDom.class0100644000076600007660000000334607425146705016276 0ustar kitazawakitazawa朋詐-l ) *+ , -. -/ 01 234 567 89: ); < = > ? @A B CD CEFGHIerrMapLjp/faces/XmlErrMap;hmZsrvLjp/faces/FacesServer;(Ljp/faces/FacesServer;)VCodeLineNumberTablemakeDom1(Lorg/xml/sax/InputSource;)Lorg/w3c/dom/Document; SourceFile FacesXML.java !JK LM N OP QRS T&U VJjava/io/IOExceptionW XJorg/xml/sax/SAXParseExceptionY Z[java/lang/StringBuffer XML error in line \] ^_ \` abc de fbg hi jk.javax/xml/parsers/ParserConfigurationExceptionorg/xml/sax/SAXExceptionjp/faces/GenDom"org/xml/sax/helpers/DefaultHandler()Vjp/faces/FacesServer getXmlErrMap()Ljp/faces/XmlErrMap;(javax/xml/parsers/DocumentBuilderFactory newInstance,()Ljavax/xml/parsers/DocumentBuilderFactory;newDocumentBuilder%()Ljavax/xml/parsers/DocumentBuilder;!javax/xml/parsers/DocumentBuilderparseorg/w3c/dom/Node normalizejava/lang/ThrowableprintStackTracejava/lang/SystemoutLjava/io/PrintStream;append,(Ljava/lang/String;)Ljava/lang/StringBuffer; getLineNumber()I(I)Ljava/lang/StringBuffer;toString()Ljava/lang/String;java/io/PrintStreamprintln(Ljava/lang/String;)V getMessagejp/faces/XmlErrMap getLoaded()Z getErrMessage&(Ljava/lang/String;)Ljava/lang/String;  !"#- **+$%& '%&#MN+-+M,jN- : Y  * *: : ,# kt$F14 6 78<!=#ABBMCWDiFkJrKtOPS'(faces/jp/faces/JDBC.class0100644000076600007660000000554207425146705015627 0ustar kitazawakitazawa朋詐- *BC DEFGH IJ )KL MNO BP Q R S TU VW XY Z[ \] \^ Z_`a )bcde fghijklmn )o X^pqConnLjava/sql/Connection;()VCodeLineNumberTablesqlexec((Ljava/lang/String;)Ljava/sql/ResultSet; ResultCount(Ljava/sql/ResultSet;)I sqlupdate(Ljava/lang/String;)IappSet(Ljava/lang/String;)VpuserSet)(ILjava/lang/String;Ljava/lang/String;I)V puserDelete(ILjava/lang/String;I)V appDelete clearTablesclose SourceFile JDBC.java -.org.postgresql.Driverr st.jdbc:postgresql://192.168.254.10:5432/kitazawakitazawau vw +,java/lang/Exceptionx yzjava/lang/StringBufferError: {| {} ~ 8 .  2 ?. 6!DELETE FROM app WHERE appname = '' 56INSERT INTO app VALUES('',0)!DELETE FROM puser WHERE userid = {INSERT INTO puser VALUES(,'','')UPDATE app SET usercount =  WHERE appname = 'DELETE FROM puserUPDATE app SET usercount = 0 >. jp/faces/JDBCjava/lang/Objectjava/lang/ClassforName%(Ljava/lang/String;)Ljava/lang/Class;java/sql/DriverManager getConnectionM(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/Connection;java/lang/SystemoutLjava/io/PrintStream;append,(Ljava/lang/String;)Ljava/lang/StringBuffer;,(Ljava/lang/Object;)Ljava/lang/StringBuffer;toString()Ljava/lang/String;java/io/PrintStreamprintlnjava/lang/ThrowableprintStackTracejava/sql/ConnectioncreateStatement()Ljava/sql/Statement;java/sql/Statement executeQueryjava/sql/ResultSetnext()Z executeUpdate(I)Ljava/lang/StringBuffer;!)*+, -./s;*WL*+!L Y  ++ 0  6: 12/h4*N-+M,N Y  -- 0, /<>.?2@34/~>=+9++!N Y  -- 0& KMO P ORT8U<X56/k7=*N-+=!N Y  -- 0be fi1j5l!78/[;* Y +W* Y +W0uv:w!9:/u* Y W* Y  ,!-"W** Y #$-W0GMt;</hD* Y W)* Y #$,W0C=8/:* Y +W0 >.//*%W*&W0?./_/*'*(!L Y  ++  0*.@Afaces/jp/faces/RoomInfo.class0100644000076600007660000002354507425146705016660 0ustar kitazawakitazawa朋詐- v  u u u u u u            T % % % u u 9 u u u  6  9  > 9 u      u T         u T T    9   ! 9" #$%& ' 9() 9* 9+,-. nodeNameshmLjava/util/HashMap; nodeSaveMapAppNameLjava/lang/String;roomNumIroomMaxP syncCountLjp/faces/SyncCounters;srvLjp/faces/FacesServer;(Ljp/faces/FacesServer;)VCodeLineNumberTablegetSyncCounters()Ljp/faces/SyncCounters;FileSave8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;saveByNodeName&(Lorg/w3c/dom/Node;)Ljava/lang/String;saveAll()Ljava/lang/String;outputLogCountoutputByNodeNameclearAll()VclearByNodeName(Lorg/w3c/dom/Node;)VclearByNodeNameAndKey'(Lorg/w3c/dom/Node;Lorg/w3c/dom/Node;)VclearByNodeNameAndSelfclearByNodeNameAndSelfString'(Ljava/lang/String;Ljava/lang/String;)V clearBySelf clearByKey outputAll checkQERNode.(Lorg/w3c/dom/NamedNodeMap;)Ljava/lang/String; checkQSNode/(Lorg/w3c/dom/NamedNodeMap;I)Ljava/lang/String; checkNodeNamecheckNodeListName deleteLogNode(I)V countLogNode()IgetEmptyRoomNum(I)IdeleteSelfSubNodegetNode setAppName(Ljava/lang/String;)V setRoomNum(II)V getAppName getRoomNum getRoomMaxP SourceFile RoomInfo.java java/util/HashMap wx yx |} ~} jp/faces/SyncCounters java/lang/Long/ 01 2 3java/lang/StringBuffer 45.xml java/io/File 67 87 9:3; < =user.dir >?7  ?@ABCEFGI#JBK\O_QeRpS}VY[]abF.**+-Y*./+0/1l7**2Y*./1u4Y3*45~ ^6Y7M*+089N-^,-::;:3<=><?@=>@?,AW,BC*+08:,+0D:,AWE:F:v,G9::>H?>I?;:  3 <=><? @=>@?AWJ,BC飴YK+0L '05AMYenx ",6@/*M*MK#*+0N*+0N臼!"E!*+08N--,0NW ;+0N,0:*-O *+89N-6-;:)<=Y:0,P *+NW*+8:^E:F:AG9:;:'<=Y:  0,P QJ傘R ,:CPU\eht}c3*RM,SN-GT:*+0O-J祓  )2 [/*EM,FN-G+0NW-J膠%. H6Y7L+UDM+,AW*EN-F:+G9::,AWJ*R:S:GT:*8::+D:,AW :  )EN-F: {+ G9::  >H? >I? ;:  3 <= ><? @= >@?  AW JJ,+BCV# "#%!&)',(?*H'R-[.d/g0s13569<=>?@ABCDEGHK L*>4/>PvB+W=YN6-0X= :=)YY*Z5 (\ ^ab#d@g R6+[=Y:0N+W=Y:R0X6: 0:  U\( ]X6**.^6: 66+_=Y:0:  U\C ]X6* *.-`Ya-: 6761+W=Y:bN0X6: 6 bN6* -cYa-Ya-'36(Keh(((~tyz{'}6AKVhpv 17P;+>H?*+d+eW +;MN:,,H=N,I=::-*-08:0+eW3Y:0+eW-*-0eWF  #&*<FW`eswS*EM,FN:-G:f89:dgP fNW-J単* +0?IRj*EL+FM>N,G:E:F:&G9:dgPJ,J>  & / 2>CRU _hb*EM,FN6 :6 O鬣-G:E:  F: Z G9:  I dgP: ;:  h=Y:"0X6  \.`O :  ) J-J{6.(n !#$%%$0'3(>*E+N,Q-].b/q0z1346,'=>?=B9 *EM,FNc-G:E:F:;G9;:<=Y:0fP QJ-J*EM,FN9-G9;:<=Y:0fP -Q-J脹ZLMNOQ$R-S0TAVPWaXhSrN{^_`acde`i QiL*jY+*0L**j Y+K*dL*;M,Y>J,kd:,k0:Y+lmnL,o*pY+LLY+qL*rN Y+-CL-sN-盪Y+tLY+*dLY+qL+^rs u(w2zO|V}Z~_m{~ #;O"*+. "* + ** *.**faces/jp/faces/SyncCounters.class0100644000076600007660000000402507425146705017557 0ustar kitazawakitazawa朋詐-t /0 / 1 2 34 567 /8 9 : ; <= >?@ A BC D E 3F >G HI J 3KL M NOPcountersLjava/util/List;srvLjp/faces/FacesServer;(Ljp/faces/FacesServer;)VCodeLineNumberTableevalRoom)(Ljava/lang/String;ILjava/lang/String;I)ZevalRoomForDelete%(Ljava/lang/String;I)Ljava/util/List; setCounter(Ljava/lang/String;I)Z SourceFileSyncCounters.java #Qjava/util/Vector  !"R STU VWjava/lang/StringBufferevalRoom selfname XY XZ [\] ^_` abjp/faces/Counter c\d ef gh i, jf klm no #p qfjava/lang/Exception rh sljp/faces/SyncCountersjava/lang/Object()Vjava/util/Listiterator()Ljava/util/Iterator;java/lang/SystemoutLjava/io/PrintStream;append,(Ljava/lang/String;)Ljava/lang/StringBuffer;(I)Ljava/lang/StringBuffer;toString()Ljava/lang/String;java/io/PrintStreamprintln(Ljava/lang/String;)Vjava/util/Iteratornext()Ljava/lang/Object;getCounterNamejava/lang/Stringequals(Ljava/lang/Object;)Z qsListAdd(I)VqsAllremovehasNext()Zjp/faces/FacesServer roomUserCount(Ljava/lang/String;I)I,(Ljava/lang/String;ILjp/faces/FacesServer;)Vadd resetMaxCountincrementCount! !"#$%9**Y*+&'(%*:Y   <:-$+*W*+'Y-*:*W&F! "%#($4&@'G(Q)]+_.a#k3x4567:!)*%XYN*:9:+-W*W: -DG&* HIJL"M,O8PGSLJVV+,%k*N8-:+!*W-*Y+*W&:c d eg$h*i2j>l@oBdKtPugviz-.faces/jp/faces/XmlErrMap.class0100644000076600007660000000231307425146705016765 0ustar kitazawakitazawa朋詐-N *+ , - ./ * 01 2 3 456 78 79 7:; 7< =>?@stFileLjava/lang/String;propLjava/util/Properties;loadedZ()VCodeLineNumberTable getLoaded()Z makeMsgMap getErrMessage&(Ljava/lang/String;)Ljava/lang/String; SourceFileXmlErrMap.java Messages_en.properties  $# java/util/Properties java/io/FileInputStream A BC Djava/lang/Exception/E FG HI JK HL M&jp/faces/XmlErrMapjava/lang/Object(Ljava/lang/String;)Vload(Ljava/io/InputStream;)Vclosejava/lang/StringindexOf(Ljava/lang/String;)I substring(I)Ljava/lang/String;trim()Ljava/lang/String;(II)Ljava/lang/String; getProperty!  6***! "# !$# n2**Y Y* L*+ + L// !"()*+%,)--//3%& d8+Y6,+`N-Y6 -N*-!@ AB$C,D5F' !()faces/COPYING0100644000076600007660000004307707406050134013431 0ustar kitazawakitazawa GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. faces/README.jp0100644000076600007660000000103107425146111013650 0ustar kitazawakitazawa FACEs Server version 0.1.3 FACEs Serverは、主にFlashをクライアントに使用するマルチユーザコンテンツの 制作、運用のために作られたJavaアプリケーションです。 FACEs Serverについては以下のURLをごらんください。 http://faces.bascule.co.jp/ 配布条件(Copyright) GNU General Public License です。詳しくは COPYING というファイルを読ん で下さい。 Copyright (C) 2001 Bascule Design Inc. FACEs Server is free software; you can redistribute it and/or modify it under the terms of GNU General Public License. See the file COPYING for more details. faces/sample/0040755000076600007660000000000007406051620013650 5ustar kitazawakitazawafaces/sample/test.fla0100644000076600007660000005600007406320227015313 0ustar kitazawakitazawa佻燹> Root Entryp|YrRASHP0mContents"!Page 1 K Symbol 4B !#$%&'()*+,Root Entryp|YrRASHnJuyContents!Page 1 y Symbol 4B Symbol 3  !"#$%&'()*+,-./0123456789:CPicPage CPicLayer CPicFrameCPicText MS UI Gothic(d3(00000? C[ 1OCPicPage CPicLayer CPicFrameL64uu6<L64u方<棄方4方<棄方4u6? C[ 1OCPicPage CPicLayer CPicFrame CPicButton\<Aon (release) { textBox = "disconnected"; this.closeSocket(); } CPicText L@textBox MS UI Gothic(?efunction loadEnd () { mySocket = new XMLSocket(); mySocket.onConnect = checkConnect; mySocket.connect("localhost", 8080); //mySocket.connect("192.168.254.11", 8080); mySocket.onClose = checkClose; } function checkClose () { trace ("disconnected"); } function closeSocket () { mySocket.close(); trace ("closeSocket test\n"); } function checkConnect (bOK) { if (bOK) { mySocket.onXML = getData; trace ("trueconnection"); sendStr(""); } else { trace ("falseconnection"); } } function getData (receiveXML) { var e = receiveXML.firstChild; if (e != null && e.nodeName == "P") { if (e.attributes.n == "1") { setProperty("_root.mouse1",_x,e.attributes.x); setProperty("_root.mouse1",_y,e.attributes.y); } else if (e.attributes.n == "2") { setProperty("_root.mouse2",_x,e.attributes.x); setProperty("_root.mouse2",_y,e.attributes.y); } } else if (e != null && e.nodeName == "N") { selfname = e.attributes.n; trace("selfname=" + selfname + "\n"); } else if (e != null && e.nodeName == "D") { disconnectedname = e.attributes.n; if (e.attributes.n == "1") { setProperty("_root.mouse1",_x,0); setProperty("_root.mouse1",_y,0); } else if (e.attributes.n == "2") { setProperty("_root.mouse2",_x,0); setProperty("_root.mouse2",_y,0); } trace("disconnectedname=" + disconnectedname + "\n"); } } function sendPos (name,x, y) { str = "

"; sendStr(str); } function sendStr (str) { theXML = new XML(); theXML.parseXML(str); mySocket.send(theXML); }  C[ 1O CPicSprite||sonClipEvent (mouseMove) { if(_root.selfname == "1"){ _root.sendPos("1",_root._xmouse, _root._ymouse); } } mouse1 ||qonClipEvent (mouseMove) { if(_root.selfname == "2"){ _root.sendPos("2",_root._xmouse, _root._ymouse); } }mouse2 懸懸*onClipEvent (load) { _root.loadEnd(); } loadaction? C[ 2OO  CDocumentPage Page 1V[ 1S材:A%< Symbol 4 action_mouse:1: Symbol 3button3死::*@hhhhh誓Vector::Debugging Permitted0Vector::External Font Files0Vector::Generator CommandVector::Preview as GIF0Vector::Override Sounds0Vector::TemplateVector::Protect0Vector::Quality50Vector::Omit Trace Actions0Vector::Debugging PasswordVector::TopDown0"PublishFormatProperties::generatorVector::Report0Vector::Version5Vector::Stream Compress7Vector::Event Format0Vector::Event Compress7Vector::Stream Format0PropSheet::ActiveTab1620 CColorDef3PfP0PHP`Px333(3f<03CH3F`3Hxf0f30ff(0f5Hf<`f@x3330333xf3d03]H3Z`3Xx3333303f3PPH33Px`33Px33Pf30f33PHff3(PHf3<x`f3Cxf3Ffff`f03f0ffx0fkHfd`f`x3f033fPH3ffxPH3fdx`3f]x3fZff0f3fPHfff`ffP0xffPxffPH3HfHxHn`hx3H33x`3fx`3xx`3kx3dfHf3x`ff0xfx0xfdxf]面`3`f``面x`px3`33x3fx3x3面xx3nf`f3xffxfxf面xxfkx3xfxxxxx3x333f333xfxf3fffffxxH3 HfH(H2`8x`3 `f``面(`0xx3xfxx x(xPx3H33x`f3x`3(x`35x3<3`33xf3 x3x面3(x323x33f3 333(xfH3fx`ff0xf(0xf<xfCf`3fxffxfx面f(xf5fx3ffff ff((xH3x`f0xPPP`3xfxP面(P<x3f(xx`3xfxP面xPd`3xfxP面Px3f面(xx3fxx3f面xx3ff`zf*]ThSymbol 3  !"#$%&'()*+,-./0123456789:L64uu6<L64u方<棄方4方<棄方4u6? C[ 1OCPicPage CPicLayer CPicFrame CPicButton\<Aon (release) { textBox = "disconnected"; this.closeSocket(); } CPicText L@textBox MS UI Gothic(?7function loadEnd () { mySocket = new XMLSocket(); mySocket.onConnect = checkConnect; mySocket.connect("localhost", 8080); mySocket.onClose = checkClose; } function checkClose () { trace ("disconnected"); } function closeSocket () { mySocket.close(); trace ("closeSocket test\n"); } function checkConnect (bOK) { if (bOK) { mySocket.onXML = getData; trace ("trueconnection"); sendStr(""); } else { trace ("falseconnection"); } } function getData (receiveXML) { var e = receiveXML.firstChild; if (e != null && e.nodeName == "P") { if (e.attributes.n == "1") { setProperty("_root.mouse1",_x,e.attributes.x); setProperty("_root.mouse1",_y,e.attributes.y); } else if (e.attributes.n == "2") { setProperty("_root.mouse2",_x,e.attributes.x); setProperty("_root.mouse2",_y,e.attributes.y); } } else if (e != null && e.nodeName == "N") { selfname = e.attributes.n; trace("selfname=" + selfname + "\n"); } else if (e != null && e.nodeName == "D") { disconnectedname = e.attributes.n; if (e.attributes.n == "1") { setProperty("_root.mouse1",_x,0); setProperty("_root.mouse1",_y,0); } else if (e.attributes.n == "2") { setProperty("_root.mouse2",_x,0); setProperty("_root.mouse2",_y,0); } trace("disconnectedname=" + disconnectedname + "\n"); } } function sendPos (name,x, y) { str = "

"; sendStr(str); } function sendStr (str) { theXML = new XML(); theXML.parseXML(str); mySocket.send(theXML); }  C[ 1O CPicSprite||sonClipEvent (mouseMove) { if(_root.selfname == "1"){ _root.sendPos("1",_root._xmouse, _root._ymouse); } } mouse1 ||qonClipEvent (mouseMove) { if(_root.selfname == "2"){ _root.sendPos("2",_root._xmouse, _root._ymouse); } }mouse2 懸懸*onClipEvent (load) { _root.loadEnd(); } loadaction? C[ 2OO[ 2OO  CDocumentPage Page 1V[ 1S材:n< Symbol 4 action_mouse:1: Symbol 3button3死::*@hhhhh誓Vector::External Font Files0Vector::Debugging Permitted0Vector::Generator CommandVector::Preview as GIF0Vector::Override Sounds0Vector::Quality50Vector::Protect0Vector::TemplateVector::Debugging PasswordVector::Omit Trace Actions0Vector::TopDown0Vector::Report0"PublishFormatProperties::generatorVector::Event Format0Vector::Stream Compress7Vector::Version5Vector::Event Compress7Vector::Stream Format0PropSheet::ActiveTab1620 CColorDef3PfP0PHP`Px333(3f<03CH3F`3Hxf0f30ff(0f5Hf<`f@x3330333xf3d03]H3Z`3Xx3333303f3PPH33Px`33Px33Pf30f33PHff3(PHf3<x`f3Cxf3Ffff`f03f0ffx0fkHfd`f`x3f033fPH3ffxPH3fdx`3f]x3fZff0f3fPHfff`ffP0xffPxffPH3HfHxHn`hx3H33x`3fx`3xx`3kx3dfHf3x`ff0xfx0xfdxf]面`3`f``面x`px3`33x3fx3x3面xx3nf`f3xffxfxf面xxfkx3xfxxxxx3x333f333xfxf3fffffxxH3 HfH(H2`8x`3 `f``面(`0xx3xfxx x(xPx3H33x`f3x`3(x`35x3<3`33xf3 x3x面3(x323x33f3 333(xfH3fx`ff0xf(0xf<xfCf`3fxffxfx面f(xf5fx3ffff ff((xH3x`f0xPPP`3xfxP面(P<x3f(xx`3xfxP面xPd`3xfxP面Px3f面(xx3fxx3f面xx3ff`zf*]Th