-
Notifications
You must be signed in to change notification settings - Fork 2
Home
The GUI sends messages to the Controller. When the user clicks on a different group, the Controller tells the DataManager to reload the messages.
The Controller receives messages from the GUI and tells the DataManager to send it via the ServerInterface.
Actions: send message, add member, remove member, change group avatar, create group, delete group, reload groups.
** message received from Controller **
A DataManager receives a message from the Controller and sends the message to the ServerInterface.
- (void)sendNewMessage:(NSString*)text toGroup:(Group*)group
withAttachments:(NSArray*)attachments;
update CoreData with new message. tell ServerInterface to update server (sendNewMessage:toGroup:withAttachments).
- (void)addNewMembers:(NSArray*)members
toGroup:(NSString*)groupID;
add member to member list in CoreData. tell ServerInterface to addNewMembers
- (void)removeMember:(NSString*)membershipID
fromGroup:(NSString*)groupID;
remove member from member list in CoreData tell ServerInterface to removeMember
- (void)changeGroupAvatar:(id)image forGroup: (NSString*)groupID;
update group avatar in CoreData.
tell ServerInterface to update server (updateGroup:withName:description:image:andShare:);
- (void)changeGroupName:(NSString*)name forGroup: (NSString*)groupID;
update group name in CoreData.
tell ServerInterface to update server (updateGroup:withName:description:image:andShare:);
- (void)createGroup;
create group in CoreData with new groupID.
tell ServerInterface to update server.
- (void)deleteGroup:(NSString*)groupID
remove group from CoreData.
tell ServerInterface to update server.
- (void)fetchAllGroups;
tell ServerInterface to get all groups (fetchAllGroups:).
- (void)signIn;
- (void)logOut;
- (BOOL)isUser:(NSString*)userID;
** message received from ServerInterface **
- (void)didRefreshGroups:(NSArray*)groups;
update CoreData with groups.
- (void)didUpdateMessages:(NSArray*)messages;
update CoreData with messages
forGroup: (NSString*)groupID;```
update CoreData with members
- (void)didUpdateGroup:(NSString*)groupID withName:(NSString*)name description:(NSString*)description image:(id)image andShare:(BOOL)allowShare;
ServerInterface
---------------
** message received from DataManager **
The ServerInterface receives messages from the DataManager and pushes to the
server (RESTAPI).
- (void)sendNewMessage:(NSString*)message toGroup:(NSString*)groupID withAttachments:(NSArray*)attachments;
tell RESTAPI to send new message to server (MessagesCreateInGroup:text:attachments:andCompleteBlock:)
- (void)addNewMembers:(NSArray*)members toGroup:(NSString*)groupID;
tell RESTAPI to add new members to group on the server.
- (void)removeMember:(NSString*)membershipID fromGroup:(NSString*)groupID;
tell RESTAPI to remove member from group on server.
- (void)updateGroup:(NSString*)groupID withName:(NSString*)name description:(NSString*)description image:(id)image andShare:(BOOL)allowShare;
update group info such as group name and group avatar
tell RESTAPI to update group info on server.
- (void)createGroupNamed:(NSString*)name description:(NSString*)description image:(id)image andShare:(BOOL)allowShare;
tell RESTAPI to create new group.
```- (void)deleteGroup:(NSString*)groupID;```
tell RESTAPI to delete the group.
```- (void)fetchAllGroups;```
tell RESTAPI to fetchAllGroupsForUser:
tell DataManager to refreshGroups with these groups (didRefreshGroups).
** message received from web socket **
The ServerInterface receives notifications, and the notificationCenter posts
the notifications.
```- (void)messageCentralRouter:(NSDictionary *)messageDict```
First post the notification regardless of its type.
Then check if the notification is about messages, members, or group info.
MESSAGE retrieve previous 20 messages (fetch20MessagesBeforeMessageID:inGroup:) tell DataManager to update CoreData with these messages (updateMessages).
MEMBER REMOVED, ADDED, OR CHANGED NICKNAME tell RESTAPI to fetchAllMembersForGroup: tell DataManager to update CoreData with these members(didUpdateMembersForGroup:).
GROUP INFO CHANGED (AVATAR, GROUP NAME) tell RESTAPI to fetchInfoForGroup. tell DataManager to update CoreData with this info (didUpdateGroup:withName:description:image:andShare:).
LIKE return (ignore for now. later design should display like on message)
** helper methods **
These two methods retrieve 20 messages from RESTAPI and returns them in an
dictionary. The messages can be ordered by message ID.
- (NSDictionary*)fetch20MessagesBeforeMessageID:(NSString*)beforeID inGroup:(NSString*)groupID;
- (NSDictionary*)fetch20MostRecentMessagesSinceMessageID:(NSString*)sinceID inGroup:(NSString*)groupID;
This method returns the 20 messages in an array.
RESTAPI
-------
wrapper class for GroupMe REST API
- (void)UsersGetInformationAndCompleteBlock:(void(^)(NSDictionary* userDict))completeBlock;
- (void)GroupsIndexPage:(NSInteger)nthPage with:(NSInteger)groups perPageAndCompleteBlock:(void(^)(NSArray* groupArray))completeBlock;
- (void)GroupsFormerAndCompleteBlock:(void(^)(NSArray* formerGroupArray))completeBlock;
- (void)GroupsShow:(NSString*)groupID andCompleteBlock:(void(^)(NSDictionary* groupDict))completeBlock;
- (void)GroupsCreateName:(NSString*)name description:(NSString*)description image:(id)image share:(BOOL)allowShare andCompleteBlock:(void(^)(NSDictionary* createdGroupDict))completeBlock;
- (void)GroupsUpdate:(NSString*)groupID withName:(NSString*)name description:(NSString*)description image:(id)image orShare:(BOOL)allowShare andCompleteBlock:(void(^)(NSDictionary* updatedGroupDict))completeBlock;
- (void)GroupsDestroy:(NSString*)groupID andCompleteBlock:(void(^)(NSString* deleted_group_id))completeBlock;
- (void)MembersAdd:(NSArray*)members toGroup:(NSString*)groupID andCompleteBlock:(void(^)(NSArray* addedMembers))completeBlock;
- (void)MembersRemoveUser:(NSString*)membershipID fromGroup:(NSString*)groupID andCompleteBlock:(void(^)(NSString* removedMembershipID))completeBlock;
- (void)MembersResults:(NSString*)resultsID inGroup:(NSString*)groupID andCompleteBlock:(void(^)(NSArray* addedMembers))completeBlock attempt:(NSInteger)nthAttempt;
- (void)MessagesIndex20BeforeID:(NSString*)beforeID inGroup:(NSString*)groupID andCompleteBlock:(void(^)(NSArray* messages))completeBlock;
- (void)MessagesIndexMostRecent20SinceID:(NSString*)sinceID inGroup:(NSString*)groupID andCompleteBlock:(void(^)(NSArray* messages))completeBlock;
- (void)MessagesCreateInGroup:(NSString*)groupID text:(NSString*)text attachments:(NSArray*)arrayOfAttach andCompleteBlock:(void(^)(NSDictionary* sentMessage))completeBlock;
- (void)helpAsyncUploadImageToGroupMe:(id)image usingBlock:(void(^)(NSString* imageURL))completeBlock
CoreData Model
--------------
The CoreData Model is bound to the GUI. When the DataManager reloads messages, members, or group info, the CoreData automatically updates the GUI.