Guest User

Untitled

a guest
Aug 23rd, 2017
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.19 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.  
  16.     public static void Debug(String _message) {
  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:3306/android";
  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.     public enum Packet {
  39.         LOGIN, UPDATE_PROFILE, CONVERSATION_LIST, CONVERSATION_PRIVATE, CONVERSATION_PRIVATE_LIST
  40.     }
  41.  
  42.     /* RealTime */
  43.     public static Vector<Socket> ClientSockets = new Vector<Socket>();
  44.     public static Vector<String> LoginNames = new Vector<String>();
  45.  
  46.     public static Socket RouteToListener(String _string) {
  47.         Common.Debug("RouteToListener ");
  48.         for (int iCount = 0; iCount < LoginNames.size(); iCount++) {
  49.             if (LoginNames.elementAt(iCount).equals(_string)) {
  50.                 return ClientSockets.elementAt(iCount);
  51.             }
  52.         }
  53.         return null;
  54.     }
  55.  
  56.     public static void Disconnect(Socket _socket) {
  57.         for (int iCount = 0; iCount < ClientSockets.size(); iCount++) {
  58.             if (ClientSockets.elementAt(iCount).equals(_socket)) {
  59.                 LoginNames.removeElementAt(iCount);
  60.                 ClientSockets.removeElementAt(iCount);
  61.                 Common.Debug("Disconnect ");
  62.                 break;
  63.             }
  64.         }
  65.     }
  66. }
Add Comment
Please, Sign In to add comment