Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.06 KB | None | 0 0
  1. package geogre.qupty;
  2.  
  3. import java.net.Socket;
  4. import java.time.LocalDateTime;
  5. import java.time.LocalTime;
  6. import java.util.Vector;
  7.  
  8. /**
  9.  * Created by GEORGE on 11/6/2015.
  10.  */
  11. public class Common {
  12.  
  13.     /* Debug */
  14.     public static boolean bDebug = true;
  15.     public static void Debug(String _message)
  16.     {
  17.         if(bDebug)
  18.             System.out.println(LocalTime.now() + " : " + _message);
  19.     }
  20.  
  21.     /* Connection */
  22.     public static final int nServerPort = 55620;
  23.     public static final int nRealTimePort = 54456;
  24.     public static final String sMySQL_User = "root";
  25.     public static final String sMySQL_Password = "4a5awhat";
  26.     public static final String sMySQL_ConnectionURL = "jdbc:mysql://127.0.0.1:9999/test";
  27.  
  28.     /* Packet ID */
  29.     public static final int nLogin = 1;
  30.     public static final int nUpdateProfile = 2;
  31.     public static final int nConversationList = 3;
  32.     public static final int nConversationPrivate = 4;
  33.     public static final int nConversationPrivateList= 5;
  34.     public static final int nConversationGroup = 6;
  35.     public static final int nConversationServer = 7;
  36.     public static final int nDisconnect = 10;
  37.  
  38.     /* RealTime */
  39.     public static Vector<Socket> ClientSockets = new Vector<Socket>();
  40.     public static Vector <String>LoginNames = new Vector<String>();
  41.  
  42.     public static Socket RouteToListener(String _string) {
  43.         Common.Debug("RouteToListener ");
  44.         for (int iCount = 0; iCount < LoginNames.size(); iCount++) {
  45.             if (LoginNames.elementAt(iCount).equals(_string)) {
  46.                 return ClientSockets.elementAt(iCount);
  47.             }
  48.         }
  49.         return null;
  50.     }
  51.     public static void Disconnect(Socket _socket) {
  52.         for (int iCount = 0; iCount < ClientSockets.size(); iCount++) {
  53.             if (ClientSockets.elementAt(iCount).equals(_socket)) {
  54.                 LoginNames.removeElementAt(iCount);
  55.                 ClientSockets.removeElementAt(iCount);
  56.                 Common.Debug("Disconnect ");
  57.                 break;
  58.             }
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement