Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SAMOPClient extends SAMOPBase {
- boolean isLogged;
- List<Salary> salaires;
- public SAMOPClient(Socket serviceSocket) throws ProtocolException {
- super(serviceSocket);
- isLogged = false;
- }
- public void loginSSLRequest(String name, String password) throws ProtocolException {
- try {
- this.loginSSLRequest = new LoginSSLRequest(name, password);
- oos.writeObject(this.loginSSLRequest);
- oos.flush();
- super.receive();
- if (receivedObject instanceof SimpleAnswer) {
- SimpleAnswer answer = (SimpleAnswer)receivedObject;
- if (answer.getAnswer() == SimpleAnswer.ACCEPT)
- isLogged = true;
- else
- System.out.println(answer.getDenyReason());
- }
- } catch (Exception ex) {
- throw new ProtocolException(ex.getMessage());
- }
- }
- public void launchPaymentRequest(String employee) throws ProtocolException {
- try {
- this.launchPaymentRequest = new LaunchPaymentRequest(employee);
- oos.writeObject(this.launchPaymentRequest);
- oos.flush();
- super.receive();
- if(receivedObject instanceof PaymentsResponse) {
- PaymentsResponse response = (PaymentsResponse) receivedObject;
- salaires = response.getList();
- } else if (receivedObject instanceof SimpleTextAnswer) {
- SimpleTextAnswer answer = (SimpleTextAnswer) receivedObject;
- System.out.println(answer.getAnswer());
- }
- } catch (Exception ex) {
- throw new ProtocolException(ex.getMessage());
- }
- }
- public void launchPaymentsRequest() throws ProtocolException {
- try {
- this.launchPaymentsRequest = new LaunchPaymentsRequest();
- oos.writeObject(this.launchPaymentsRequest);
- oos.flush();
- super.receive();
- if(receivedObject instanceof PaymentsResponse) {
- PaymentsResponse response = (PaymentsResponse) receivedObject;
- salaires = response.getList();
- } else if (receivedObject instanceof SimpleTextAnswer) {
- SimpleTextAnswer answer = (SimpleTextAnswer) receivedObject;
- System.out.println(answer.getAnswer());
- }
- } catch (Exception ex) {
- throw new ProtocolException(ex.getMessage());
- }
- }
- public void askPayments(int mois) throws ProtocolException {
- try {
- this.askPaymentsRequest = new AskPaymentsRequest(mois);
- oos.writeObject(this.askPaymentsRequest);
- oos.flush();
- super.receive();
- if(receivedObject instanceof PaymentsResponse) {
- PaymentsResponse response = (PaymentsResponse) receivedObject;
- salaires = response.getList();
- } else if (receivedObject instanceof SimpleTextAnswer) {
- SimpleTextAnswer answer = (SimpleTextAnswer) receivedObject;
- System.out.println(answer.getAnswer());
- }
- } catch (Exception ex) {
- throw new ProtocolException(ex.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement