• R/O
  • SSH

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修订版191c26cf7525b900b95cbfa175f986c0a7293e10 (tree)
时间2019-01-18 05:19:37
作者sebastian_bugiu <sebastian_ <bugiu@head...>
Commitersebastian_bugiu <sebastian_

Log Message

Adding lobby support.

更改概述

差异

diff -r ffe267892920 -r 191c26cf7525 src/headwayEnt/headwayEnt/Blackhole_Darksun_WebServer/ApplicationConfig.java
--- a/src/headwayEnt/headwayEnt/Blackhole_Darksun_WebServer/ApplicationConfig.java Wed Jan 16 22:33:19 2019 +0200
+++ b/src/headwayEnt/headwayEnt/Blackhole_Darksun_WebServer/ApplicationConfig.java Thu Jan 17 22:19:37 2019 +0200
@@ -33,6 +33,8 @@
3333 c.add(FriendDataListBodyHandler.class);
3434 c.add(LobbyBodyHandler.class);
3535 c.add(LobbyListBodyHandler.class);
36+ c.add(LobbyInvitationBodyHandler.class);
37+ c.add(LobbyInvitationListBodyHandler.class);
3638 classes = Collections.unmodifiableSet(c);
3739
3840
diff -r ffe267892920 -r 191c26cf7525 src/headwayEnt/headwayEnt/Blackhole_Darksun_WebServer/Tables/MessageBodyHandlers/LobbyInvitationBodyHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/headwayEnt/headwayEnt/Blackhole_Darksun_WebServer/Tables/MessageBodyHandlers/LobbyInvitationBodyHandler.java Thu Jan 17 22:19:37 2019 +0200
@@ -0,0 +1,49 @@
1+package Blackhole_Darksun_WebServer.Tables.MessageBodyHandlers;
2+
3+import Blackhole_Darksun_WebServer.Tables.Lobby;
4+import Blackhole_Darksun_WebServer.Tables.LobbyInvitation;
5+
6+import javax.ws.rs.Consumes;
7+import javax.ws.rs.Produces;
8+import javax.ws.rs.WebApplicationException;
9+import javax.ws.rs.core.MediaType;
10+import javax.ws.rs.core.MultivaluedMap;
11+import javax.ws.rs.ext.MessageBodyReader;
12+import javax.ws.rs.ext.MessageBodyWriter;
13+import javax.ws.rs.ext.Provider;
14+import java.io.IOException;
15+import java.io.InputStream;
16+import java.io.OutputStream;
17+import java.lang.annotation.Annotation;
18+import java.lang.reflect.Type;
19+
20+@Provider
21+@Produces("application/json")
22+@Consumes("application/json")
23+public class LobbyInvitationBodyHandler extends BodyHandler implements MessageBodyWriter<LobbyInvitation>, MessageBodyReader<LobbyInvitation> {
24+
25+ @Override
26+ public boolean isWriteable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
27+ return LobbyInvitation.class.isAssignableFrom(aClass);
28+ }
29+
30+ @Override
31+ public long getSize(LobbyInvitation user, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
32+ return -1;
33+ }
34+
35+ @Override
36+ public void writeTo(LobbyInvitation user, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> multivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException {
37+ writeGson(user, type, genericType, outputStream);
38+ }
39+
40+ @Override
41+ public boolean isReadable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
42+ return LobbyInvitation.class.isAssignableFrom(aClass);
43+ }
44+
45+ @Override
46+ public LobbyInvitation readFrom(Class<LobbyInvitation> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> multivaluedMap, InputStream inputStream) throws IOException, WebApplicationException {
47+ return (LobbyInvitation) readGson(type, genericType, inputStream);
48+ }
49+}
diff -r ffe267892920 -r 191c26cf7525 src/headwayEnt/headwayEnt/Blackhole_Darksun_WebServer/Tables/MessageBodyHandlers/LobbyInvitationListBodyHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/headwayEnt/headwayEnt/Blackhole_Darksun_WebServer/Tables/MessageBodyHandlers/LobbyInvitationListBodyHandler.java Thu Jan 17 22:19:37 2019 +0200
@@ -0,0 +1,49 @@
1+package Blackhole_Darksun_WebServer.Tables.MessageBodyHandlers;
2+
3+import Blackhole_Darksun_WebServer.Tables.LobbyInvitation;
4+import Blackhole_Darksun_WebServer.Tables.LobbyInvitationList;
5+
6+import javax.ws.rs.Consumes;
7+import javax.ws.rs.Produces;
8+import javax.ws.rs.WebApplicationException;
9+import javax.ws.rs.core.MediaType;
10+import javax.ws.rs.core.MultivaluedMap;
11+import javax.ws.rs.ext.MessageBodyReader;
12+import javax.ws.rs.ext.MessageBodyWriter;
13+import javax.ws.rs.ext.Provider;
14+import java.io.IOException;
15+import java.io.InputStream;
16+import java.io.OutputStream;
17+import java.lang.annotation.Annotation;
18+import java.lang.reflect.Type;
19+
20+@Provider
21+@Produces("application/json")
22+@Consumes("application/json")
23+public class LobbyInvitationListBodyHandler extends BodyHandler implements MessageBodyWriter<LobbyInvitationList>, MessageBodyReader<LobbyInvitationList> {
24+
25+ @Override
26+ public boolean isWriteable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
27+ return LobbyInvitationList.class.isAssignableFrom(aClass);
28+ }
29+
30+ @Override
31+ public long getSize(LobbyInvitationList user, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
32+ return -1;
33+ }
34+
35+ @Override
36+ public void writeTo(LobbyInvitationList user, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> multivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException {
37+ writeGson(user, type, genericType, outputStream);
38+ }
39+
40+ @Override
41+ public boolean isReadable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
42+ return LobbyInvitationList.class.isAssignableFrom(aClass);
43+ }
44+
45+ @Override
46+ public LobbyInvitationList readFrom(Class<LobbyInvitationList> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> multivaluedMap, InputStream inputStream) throws IOException, WebApplicationException {
47+ return (LobbyInvitationList) readGson(type, genericType, inputStream);
48+ }
49+}
diff -r ffe267892920 -r 191c26cf7525 src/test/java/Blackhole_Darksun_WebServer/MainTest.java
--- a/src/test/java/Blackhole_Darksun_WebServer/MainTest.java Wed Jan 16 22:33:19 2019 +0200
+++ b/src/test/java/Blackhole_Darksun_WebServer/MainTest.java Thu Jan 17 22:19:37 2019 +0200
@@ -30,16 +30,16 @@
3030 client.register(MapBodyHandler.class);
3131 client.register(MapListBodyHandler.class);
3232 client.register(StringBodyHandler.class);
33- client.register(UserBodyHandler.class);
3433 client.register(UserFriendBodyHandler.class);
3534 client.register(UserFriendListBodyHandler.class);
3635 client.register(UserFriendInvitationBodyHandler.class);
3736 client.register(UserFriendInvitationListBodyHandler.class);
38- client.register(SessionListBodyHandler.class);
3937 client.register(FriendDataBodyHandler.class);
4038 client.register(FriendDataListBodyHandler.class);
4139 client.register(LobbyBodyHandler.class);
4240 client.register(LobbyListBodyHandler.class);
41+ client.register(LobbyInvitationBodyHandler.class);
42+ client.register(LobbyInvitationListBodyHandler.class);
4343 }
4444
4545 static void printLongerTrace(Throwable t) {
@@ -112,6 +112,11 @@
112112
113113 final Lobby createdLobby = createLobbyArr[0].readEntity(Lobby.class);
114114
115+ final Response getLobbyStatus = client.target(URI).path("get_lobby_status").path(userResponse0.getAuthToken())
116+ .request().post(Entity.entity(createdLobby, MediaType.APPLICATION_JSON_TYPE));
117+ Assert.assertEquals(getLobbyStatus.getStatusInfo().getStatusCode(), Response.Status.OK.getStatusCode());
118+ final LobbyInvitationList lobbyInvitationList = getLobbyStatus.readEntity(LobbyInvitationList.class);
119+
115120 // Now the other user must check for lobby invitations and join the lobby.
116121 final Response getLobbyInvitations = client.target(URI).path("get_lobby_invitations").path(userResponse1.getAuthToken()).request().get();
117122 Assert.assertEquals(getLobbyInvitations.getStatusInfo().getStatusCode(), Response.Status.OK.getStatusCode());