public static ChatResponse createOkResponse() { ChatResponse response = ChatResponse.CreateBuilder() .SetType(ChatResponse.Types.Type.Ok).Build(); return(response); }
public static ChatResponse createErrorResponse(String text) { ChatResponse response = ChatResponse.CreateBuilder() .SetType(ChatResponse.Types.Type.Error) .SetError(text).Build(); return(response); }
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); }
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()); }
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); }