-
Notifications
You must be signed in to change notification settings - Fork 1
/
Verifone.java
101 lines (64 loc) · 2.08 KB
/
Verifone.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package bpVerifone;
import java.io.IOException;
/**
*
* @author brtperry
*/
public class Verifone implements IEvent {
private Subscriber subscribe;
public Output output;
private String message;
public Verifone(String ip)
{
subscribe = new Subscriber (this, ip);
}
public boolean Connect()
{
subscribe.Connect();
return subscribe.connected;
}
public void Login() {
if (subscribe.connected) { //message .startsWith("100")
message = "";
try {
subscribe.write("L2,1234,1234,4\r\n");
// get response from login
subscribe.read();
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
}
void process(String d) {
String[] result = d.split(",");
output = new Output ();
output.Field0 = result[0];
output.Field1 = result[1];
output.Field2 = result[2];
output.Field3 = result[3];
try {
switch (output.Field3) {
case "Ready":
subscribe.write("T,001,01,0000,50\r\n");
default: ;
}
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
@Override
public void processMessageEvent(String s) {
message = s;
System.out.println(s);
if (s.contains("connected")) { return; }
process(message);
}
@Override
public void finalOutputEvent(Output out) {
output = out;
}
}