Skip to content

Instantly share code, notes, and snippets.

@tmibvishal
Last active June 12, 2019 07:34
Show Gist options
  • Save tmibvishal/086fe2d464fae702c1ac82310165cd49 to your computer and use it in GitHub Desktop.
Save tmibvishal/086fe2d464fae702c1ac82310165cd49 to your computer and use it in GitHub Desktop.
Workflow of filesend after the 2 users are connected

Workflow of filesend after the 2 users are connected

User Interface

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

Pre requisites (Assumptions)

  1. Two users are connected
  2. Calling them user1 and user2

Goals

  1. Improving and fixing bugs of chatbox
  2. Adding the feature of sending multiple files and allowing receiver user to accept any number of files
  3. 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

Worflow

A. Chatbox

  1. Socket.io is used in the chatbox
  2. 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>"
        }  
  3. Chat messages are temporary and are not stored anywhere because it is assumed for now that connection is terminated on closing the tab

B. Accepting and Rejecting incoming FileList request

  1. Suppose user1 sends the multiple files request to user2 using FileList object
  2. Socket Events
    • FileList Send Request
      • user1 & user2 connected. FileList Send Request from user1 to user2
        • user1 to Server
        "fileListSendRequest" : {
            fileList: "type: FileList"
        }
        then user1 filesSendingState is set to "waiting"
        • Server to user2
        "fileListSendRequest" : {
            fileList: "type: FileList"  
        }
  3. Now based on what files are accepted by user2 Socket Events:
    • File List Request Answer:
      • user2 to Server
      "fileListRequestAnswer" : {
          acceptedFilesAnswers: "type: boolean[]>"  
      }
      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
      • Server to user1
      "fileListRequestAnswer" : {
          acceptedFilesAnswers: "type: boolean[]>"  
      }
  4. 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

Links

@tmibvishal
Copy link
Author

@arpit-saxena
updated it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment