예제 #1
0
 java.util.List<Double> getHistory(String comp, int count) {
   int cmdID = commID++;
   // connect(user.getName(),user.getPassword());
   try {
     out.println(cmdID + ";" + "getch:" + comp + ":" + Integer.toString(count));
     out.flush();
     return (java.util.List<Double>) receiveReply(cmdID);
   } catch (Exception r) {
     r.printStackTrace();
   }
   return null;
 }
예제 #2
0
 String getChatHistory(String user, String pass) {
   int cmdID = commID++;
   connect(user, pass);
   try {
     out.println(cmdID + ";chath");
     out.flush();
     return (String) receiveReply(cmdID);
   } catch (Exception r) {
     r.printStackTrace();
   }
   return null;
 }
예제 #3
0
 String cancelShares(String user, String pass, int id, int sellid) {
   int cmdID = commID++;
   connect(user, pass);
   try {
     out.println(cmdID + ";cancel:" + id + ":" + sellid);
     out.flush();
     return (String) receiveReply(cmdID);
   } catch (Exception r) {
     r.printStackTrace();
   }
   return null;
 }
예제 #4
0
 String sendChat(String s, String user, String pass) {
   int cmdID = commID++;
   connect(user, pass);
   try {
     out.println(cmdID + ";chat:" + s.trim());
     out.flush();
     return (String) receiveReply(cmdID);
   } catch (Exception r) {
     r.printStackTrace();
   }
   return null;
 }
예제 #5
0
 void placeOrder(final User user, String cmd, Company comp, int qty, int id) {
   int cmdID = commID++;
   connect(user.getName(), user.getPassword());
   try {
     out.println(cmdID + ";" + cmd + ":" + comp.name + ":" + Integer.toString(qty) + ":" + id);
     out.flush();
     Shares pen = (Shares) receiveReply(cmdID);
     user.getPendingShares().add(pen);
     user.dataChanged();
   } catch (Exception r) {
     r.printStackTrace();
   }
 }
예제 #6
0
 public void disconnect() {
   int cmdID = commID++;
   this.connected = false;
   try {
     out.println(cmdID + ";logout");
     out.flush();
     in.close();
     out.close();
     socket.close();
   } catch (IOException ex) {
     System.err.println("Server stop failed.");
   }
 }
예제 #7
0
 String login(String domain, String user, String pass) {
   int cmdID = commID++;
   this.domain = domain;
   connect(user, pass);
   try {
     out.println(cmdID + ";login:"******":" + pass);
     out.flush();
     String rep = (String) receiveReply(cmdID);
     return rep.split(":")[0];
   } catch (Exception r) {
     r.printStackTrace();
   }
   return null;
 }
예제 #8
0
 User getUserDetails(String user, String pass) {
   int cmdID = commID++;
   connect(user, pass);
   try {
     usrD = 1;
     out.println(cmdID + ";gud");
     out.flush();
     User vv = (User) receiveReply(cmdID);
     usrD = 0;
     return vv;
   } catch (Exception r) {
     r.printStackTrace();
   }
   return null;
 }