We have the following user interface
export interface IUser {
socketID: string;
state: string;
outRequest: string;
partner: string;
inRequests: Set<string>;
filesSendingState: string; // idle || waiting || sending || receiving
}
filesSendingState is "idle" by default
- Two users are connected
- Calling them user1 and user2
- Improving and fixing bugs of chatbox
- Adding the feature of sending multiple files and allowing receiver user to accept any number of files
- Connecting the workflow of Anweshan and Arpit
a. Anweshan: Before Connecting the users
b. Arpit: After files are send by user1 and accepted by user2
- Socket.io is used in the chatbox
- Socket Events:
- Chat:
- user1 & user2 connected. Message from user1 to user2
- user1 to Server
"message" : { messageValue: "<message body>" }
- Server to user1 and user2
"message" : { username: "<username1>", messageValue: "<message body>", timeStamp: "<timestamp>" }
- user1 & user2 connected. Message from user1 to user2
- Chat:
- Chat messages are temporary and are not stored anywhere because it is assumed for now that connection is terminated on closing the tab
- Suppose user1 sends the multiple files request to user2 using FileList object
- Socket Events
- FileList Send Request
- user1 & user2 connected. FileList Send Request from user1 to user2
- user1 to Server
then user1 filesSendingState is set to "waiting""fileListSendRequest" : { fileList: "type: FileList" }
- Server to user2
"fileListSendRequest" : { fileList: "type: FileList" }
- user1 & user2 connected. FileList Send Request from user1 to user2
- FileList Send Request
- Now based on what files are accepted by user2
Socket Events:
- File List Request Answer:
- user2 to Server
then user1 and user2 filesSendingState is set to "sending" and "receiving" repectively if atleast 1 file is accepted otherwise user1 and user2 filesSendingState status becomes "idle" and no file is transfered"fileListRequestAnswer" : { acceptedFilesAnswers: "type: boolean[]>" }
- Server to user1
"fileListRequestAnswer" : { acceptedFilesAnswers: "type: boolean[]>" }
- File List Request Answer:
- acceptedFilesAnswers is an array with length(acceptedFilesAnswers) = length(fileList) that contains answer to individual files that were sent by user1. For files which has answer true, file sending process begins
Please rename the "file_request" emit to "fileRequest"
We are using camelCase everywhere in our project.