예제 #1
0
        public static ChatResponse createOkResponse()
        {
            ChatResponse response = ChatResponse.CreateBuilder()
                                    .SetType(ChatResponse.Types.Type.Ok).Build();

            return(response);
        }
예제 #2
0
        public static ChatResponse createErrorResponse(String text)
        {
            ChatResponse response = ChatResponse.CreateBuilder()
                                    .SetType(ChatResponse.Types.Type.Error)
                                    .SetError(text).Build();

            return(response);
        }
예제 #3
0
        public static ChatResponse createFriendLoggedOutResponse(chat.model.User user)
        {
            proto.User   userDTO  = proto.User.CreateBuilder().SetId(user.Id).Build();
            ChatResponse response = ChatResponse.CreateBuilder()
                                    .SetType(ChatResponse.Types.Type.FriendLoggedOut)
                                    .SetUser(userDTO).Build();

            return(response);
        }
예제 #4
0
        public static ChatResponse createLoggedFriendsResponse(chat.model.User[] users)
        {
            ChatResponse.Builder response = ChatResponse.CreateBuilder()
                                            .SetType(ChatResponse.Types.Type.GetLoggedFriends);
            foreach (chat.model.User user in users)
            {
                proto.User userDTO = proto.User.CreateBuilder().SetId(user.Id).Build();
                response.AddFriends(userDTO);
            }

            return(response.Build());
        }
예제 #5
0
        public static ChatResponse createNewMessageResponse(chat.model.Message message)
        {
            proto.Message messageDTO = proto.Message.CreateBuilder().
                                       SetSenderId(message.Sender.Id)
                                       .SetReceiverId(message.Receiver.Id)
                                       .SetText(message.Text).Build();

            ChatResponse response = ChatResponse.CreateBuilder()
                                    .SetType(ChatResponse.Types.Type.NewMessage)
                                    .SetMessage(messageDTO).Build();

            return(response);
        }