-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add friends, groups, notifications. Merge #4
- Loading branch information
Showing
68 changed files
with
3,665 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2017 The Nakama Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.heroiclabs.nakama; | ||
|
||
import lombok.*; | ||
|
||
@Data | ||
@ToString(includeFieldNames = true) | ||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE) | ||
public class DefaultFriend implements Friend { | ||
|
||
private final String avatarUrl; | ||
|
||
private final long createdAt; | ||
|
||
private final String fullname; | ||
|
||
private final String handle; | ||
|
||
private final String id; | ||
|
||
private final String lang; | ||
|
||
private final long lastOnlineAt; | ||
|
||
private final String location; | ||
|
||
private final String metadata; | ||
|
||
private final String timezone; | ||
|
||
private final long updatedAt; | ||
|
||
private final FriendType state; | ||
|
||
public <T> T getMetadata(final Class<T> clazz) { | ||
return DefaultClient.GSON.fromJson(metadata, clazz); | ||
} | ||
|
||
static Friend fromProto(final @NonNull com.heroiclabs.nakama.Api.Friend friend) { | ||
return new DefaultFriend(friend.getUser().getAvatarUrl(), friend.getUser().getCreatedAt(), | ||
friend.getUser().getFullname(), friend.getUser().getHandle(), friend.getUser().getId(), | ||
friend.getUser().getLang(), friend.getUser().getLastOnlineAt(), friend.getUser().getLocation(), | ||
friend.getUser().getMetadata(), friend.getUser().getTimezone(), friend.getUser().getUpdatedAt(), | ||
Friend.FriendType.fromLong(friend.getState())); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/heroiclabs/nakama/DefaultFriendsAddMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2017 The Nakama Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.heroiclabs.nakama; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Data; | ||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Data | ||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE) | ||
class DefaultFriendsAddMessage implements FriendsAddMessage { | ||
|
||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload; | ||
|
||
public byte[] asBytes(final @NonNull String collationId) { | ||
return payload.clone().setCollationId(collationId).build().toByteArray(); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/heroiclabs/nakama/DefaultFriendsBlockMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2017 The Nakama Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.heroiclabs.nakama; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Data; | ||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Data | ||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE) | ||
class DefaultFriendsBlockMessage implements FriendsBlockMessage { | ||
|
||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload; | ||
|
||
public byte[] asBytes(final @NonNull String collationId) { | ||
return payload.clone().setCollationId(collationId).build().toByteArray(); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/heroiclabs/nakama/DefaultFriendsListMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2017 The Nakama Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.heroiclabs.nakama; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Data; | ||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Data | ||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE) | ||
class DefaultFriendsListMessage implements FriendsListMessage { | ||
|
||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload; | ||
|
||
public byte[] asBytes(final @NonNull String collationId) { | ||
return payload.clone().setCollationId(collationId).build().toByteArray(); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/heroiclabs/nakama/DefaultFriendsRemoveMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2017 The Nakama Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.heroiclabs.nakama; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Data; | ||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Data | ||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE) | ||
class DefaultFriendsRemoveMessage implements FriendsRemoveMessage { | ||
|
||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload; | ||
|
||
public byte[] asBytes(final @NonNull String collationId) { | ||
return payload.clone().setCollationId(collationId).build().toByteArray(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2017 The Nakama Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.heroiclabs.nakama; | ||
|
||
import lombok.*; | ||
|
||
@Data | ||
@ToString(includeFieldNames = true) | ||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE) | ||
public class DefaultGroup implements Group { | ||
|
||
private final String id; | ||
@Getter(AccessLevel.PRIVATE) | ||
private final boolean priv; | ||
private final String creatorId; | ||
private final String name; | ||
private final String description; | ||
private final String avatarUrl; | ||
private final String lang; | ||
private final long utcOffsetMs; | ||
private final String metadata; | ||
private final long count; | ||
private final long createdAt; | ||
private final long updatedAt; | ||
|
||
public boolean isPrivate() { | ||
return priv; | ||
} | ||
|
||
public <T> T getMetadata(final Class<T> clazz) { | ||
return DefaultClient.GSON.fromJson(metadata, clazz); | ||
} | ||
|
||
static Group fromProto(final @NonNull com.heroiclabs.nakama.Api.Group group) { | ||
return new DefaultGroup(group.getId(), group.getPrivate(), group.getCreatorId(), group.getName(), | ||
group.getDescription(), group.getAvatarUrl(), group.getLang(), group.getUtcOffsetMs(), | ||
group.getMetadata(), group.getCount(), group.getCreatedAt(), group.getUpdatedAt()); | ||
} | ||
|
||
} |
Oops, something went wrong.