Skip to content

Commit 89d63a1

Browse files
committed
update send methods
1 parent 77f7b14 commit 89d63a1

File tree

7 files changed

+36
-43
lines changed

7 files changed

+36
-43
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<artifactId>ezyfox-server-java-client</artifactId>
1313

14-
<version>1.1.1</version>
14+
<version>1.1.2</version>
1515
<name>ezyfox-server-java-client</name>
1616
<url>https://youngmonkeys.org/</url>
1717

src/main/java/com/tvd12/ezyfoxserver/client/entity/EzyApp.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.tvd12.ezyfoxserver.client.entity;
22

3-
import com.tvd12.ezyfox.entity.EzyArray;
43
import com.tvd12.ezyfox.entity.EzyData;
54
import com.tvd12.ezyfoxserver.client.EzyClient;
65
import com.tvd12.ezyfoxserver.client.handler.EzyAppDataHandler;
@@ -24,10 +23,6 @@ public interface EzyApp {
2423

2524
void send(String cmd);
2625

27-
void send(EzyArray request);
28-
29-
void send(EzyArray request, boolean encrypted);
30-
3126
void send(String cmd, EzyData data);
3227

3328
void send(String cmd, EzyData data, boolean encrypted);

src/main/java/com/tvd12/ezyfoxserver/client/entity/EzyPlugin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public interface EzyPlugin {
2525

2626
void send(String cmd, EzyData data);
2727

28+
void send(String cmd, EzyData data, boolean encrypted);
29+
2830
void udpSend(EzyRequest request);
2931

3032
void udpSend(String cmd);

src/main/java/com/tvd12/ezyfoxserver/client/entity/EzySimpleApp.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@ public void send(EzyRequest request) {
3333
send(cmd, data);
3434
}
3535

36-
@Override
37-
public void send(EzyArray request) {
38-
send(request, false);
39-
}
40-
41-
@Override
42-
public void send(EzyArray request, boolean encrypted) {
43-
EzyArray requestData = EzyEntityFactory.newArray();
44-
requestData.add(id, request);
45-
client.send(EzyCommand.APP_REQUEST, requestData, encrypted);
46-
}
47-
4836
@Override
4937
public void send(String cmd) {
5038
send(cmd, EzyEntityFactory.EMPTY_OBJECT);
@@ -62,6 +50,12 @@ public void send(String cmd, EzyData data, boolean encrypted) {
6250
send(commandData, encrypted);
6351
}
6452

53+
private void send(EzyArray request, boolean encrypted) {
54+
EzyArray requestData = EzyEntityFactory.newArray();
55+
requestData.add(id, request);
56+
client.send(EzyCommand.APP_REQUEST, requestData, encrypted);
57+
}
58+
6559
@Override
6660
public void udpSend(EzyRequest request) {
6761
String cmd = (String) request.getCommand();

src/main/java/com/tvd12/ezyfoxserver/client/entity/EzySimplePlugin.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.tvd12.ezyfoxserver.client.entity;
22

3-
import com.tvd12.ezyfox.builder.EzyArrayBuilder;
43
import com.tvd12.ezyfox.entity.EzyArray;
54
import com.tvd12.ezyfox.entity.EzyData;
65
import com.tvd12.ezyfox.entity.EzyEntity;
@@ -33,22 +32,28 @@ public void send(EzyRequest request) {
3332
EzyData data = request.serialize();
3433
send(cmd, data);
3534
}
36-
35+
3736
@Override
3837
public void send(String cmd) {
3938
send(cmd, EzyEntityFactory.EMPTY_OBJECT);
4039
}
4140

4241
@Override
4342
public void send(String cmd, EzyData data) {
44-
EzyArrayBuilder commandData = EzyEntityFactory.newArrayBuilder()
45-
.append(cmd)
46-
.append(data);
47-
EzyArray requestData = EzyEntityFactory.newArrayBuilder()
48-
.append(id)
49-
.append(commandData.build())
50-
.build();
51-
client.send(EzyCommand.APP_REQUEST, requestData);
43+
send(cmd, data, false);
44+
}
45+
46+
@Override
47+
public void send(String cmd, EzyData data, boolean encrypted) {
48+
EzyArray commandData = EzyEntityFactory.newArray();
49+
commandData.add(cmd, data);
50+
send(commandData, encrypted);
51+
}
52+
53+
private void send(EzyArray request, boolean encrypted) {
54+
EzyArray requestData = EzyEntityFactory.newArray();
55+
requestData.add(id, request);
56+
client.send(EzyCommand.PLUGIN_REQUEST, requestData, encrypted);
5257
}
5358

5459
@Override
@@ -65,14 +70,11 @@ public void udpSend(String cmd) {
6570

6671
@Override
6772
public void udpSend(String cmd, EzyData data) {
68-
EzyArrayBuilder commandData = EzyEntityFactory.newArrayBuilder()
69-
.append(cmd)
70-
.append(data);
71-
EzyArray requestData = EzyEntityFactory.newArrayBuilder()
72-
.append(id)
73-
.append(commandData.build())
74-
.build();
75-
client.udpSend(EzyCommand.APP_REQUEST, requestData);
73+
EzyArray commandData = EzyEntityFactory.newArray();
74+
commandData.add(cmd, data);
75+
EzyArray requestData = EzyEntityFactory.newArray();
76+
requestData.add(id, commandData);
77+
client.udpSend(EzyCommand.PLUGIN_REQUEST, requestData);
7678
}
7779

7880
@Override

src/main/java/com/tvd12/ezyfoxserver/client/handler/EzyConnectionSuccessHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected final EzyRequest newHandshakeRequest() {
3535
getClientId(),
3636
generateClientKey(),
3737
"JAVA",
38-
"1.1.1",
38+
"1.1.2",
3939
client.isEnableSSL(),
4040
getStoredToken()
4141
);
@@ -55,9 +55,9 @@ protected byte[] generateClientKey() {
5555
.build()
5656
.generate();
5757
byte[] publicKey = keyPair.getPublic().getEncoded();
58-
byte[] privatekey = keyPair.getPrivate().getEncoded();
58+
byte[] privateKey = keyPair.getPrivate().getEncoded();
5959
client.setPublicKey(publicKey);
60-
client.setPrivateKey(privatekey);
60+
client.setPrivateKey(privateKey);
6161
return publicKey;
6262
}
6363

src/test/java/com/tvd12/ezyfoxserver/client/testing/entity/EzySimplePluginTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void sendRequest() {
6060
commandData.add(cmd, requestData);
6161
EzyArray finalRequestData = EzyEntityFactory.newArray();
6262
finalRequestData.add(pluginId, commandData);
63-
verify(client, times(1)).send(EzyCommand.APP_REQUEST, finalRequestData);
63+
verify(client, times(1)).send(EzyCommand.PLUGIN_REQUEST, finalRequestData, false);
6464
}
6565

6666
@Test
@@ -96,7 +96,7 @@ public void sendEmptyRequestData() {
9696
commandData.add(cmd, requestData);
9797
EzyArray finalRequestData = EzyEntityFactory.newArray();
9898
finalRequestData.add(pluginId, commandData);
99-
verify(client, times(1)).send(EzyCommand.APP_REQUEST, finalRequestData);
99+
verify(client, times(1)).send(EzyCommand.PLUGIN_REQUEST, finalRequestData, false);
100100
}
101101

102102
@Test
@@ -135,7 +135,7 @@ public void udpSendRequest() {
135135
commandData.add(cmd, requestData);
136136
EzyArray finalRequestData = EzyEntityFactory.newArray();
137137
finalRequestData.add(pluginId, commandData);
138-
verify(client, times(1)).udpSend(EzyCommand.APP_REQUEST, finalRequestData);
138+
verify(client, times(1)).udpSend(EzyCommand.PLUGIN_REQUEST, finalRequestData);
139139
}
140140

141141
@Test
@@ -171,7 +171,7 @@ public void udpSendEmptyRequestData() {
171171
commandData.add(cmd, requestData);
172172
EzyArray finalRequestData = EzyEntityFactory.newArray();
173173
finalRequestData.add(pluginId, commandData);
174-
verify(client, times(1)).udpSend(EzyCommand.APP_REQUEST, finalRequestData);
174+
verify(client, times(1)).udpSend(EzyCommand.PLUGIN_REQUEST, finalRequestData);
175175
}
176176

177177
@Test

0 commit comments

Comments
 (0)