-
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 member nickname, 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 update server (updateMembers:forGroup:).
- (void)removeMember:(NSString*)membershipID
fromGroup:(NSString*)groupID;
remove member from member list in CoreData tell ServerInterface to updateserver (updateMembers:forGroup:).
- (void)changeMemberNickname;
update member nickname in CoreData.
tell ServerInterface to update server (updateMembers:forGroup:).
- (void)changeGroupAvatar:(id)image;
update group avatar in CoreData.
tell ServerInterface to update server (updateGroup:withName:description:image:andShare:);
- (void)changeGroupName:(NSString*)name;
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; ```
*** 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.
- (void)updateMembers: (NSArray*)members
forGroup: (NSString*)groupID;
tell RESTAPI to update the group members on the 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 from RESTAPI (fetch20MessagesBeforeMessageID:beforeIDinGroup:).
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)
The ServerInterface receives messages via the web socket from the server, GETs the previous 20 messages, and tells the DataManager to update the CoreData.
*** message received from ServerInterface ***
- (void)updateGroup:(NSString*)groupID
withName:(NSString*)name
description:(NSString*)description
image:(id)image
orShare:(BOOL)allowShare
andCompleteBlock:(void(^)(NSDictionary* updatedGroupDict))completeBlock;
POST group info to server.
- (void)updateMembers:(NSArray*)members
forGroup: (NSString*)groupID;
POST members list to server for specific group.
- (void)sendNewMessage:(NSString*)message
toGroup:(NSString*)groupID
withAttachments:(NSArray*)attachments;
POST new message to server.
- (void)createGroupWithName:(NSString*)name
description:(NSString*)description
image:(id)image
share:(BOOL)allowShare
POST new group to server.
- (void)removeGroup: (NSString*)groupID;
DELETE group from server.
- (NSDictionary*)fetch20MessagesBeforeMessageID:(NSString*)
beforeIDinGroup:(NSString*)groupID
GET 20 messages before MessageID in server.
- (NSDictionary*)fetch20MostRecentMessagesSinceMessageID:(NSString*)
sinceIDinGroup:(NSString*)groupID
GET 20 messages after MessageID in server.
- (NSDictionary*)fetchAllGroupsForUser:(NSString*)userID;
GET all groups for user from server..
- (NSDictionary*)fetchAllMembersForGroup:(NSString)groupID;
GET all members for group from server.
- (NSDictionary*)fetchInfoForGroup:(NSString*)groupID;
GET info for group from server.
*** state control ***
- (BOOL)isReachable;
- (void)setUserToken:(NSString*)token;
The CoreData Model is bound to the GUI. When the DataManager reloads messages, members, or group info, the CoreData automatically updates the GUI.