Documentation ¶
Index ¶
- func AsyncDownloader(wg *sync.WaitGroup, client *http.Client, start int64, end int, i int, size int, ...) error
- func CheckFileExistence(request FileRequest, directoryFiles *ClientFiles) bool
- func DisplayNumRecentMessages(mymessages *MyReceivedMessages, recentCount int) string
- func DisplayRecentUnseenMessages(mymessages *MyReceivedMessages) string
- func Download(args string)
- func DummyAsync(wg *sync.WaitGroup, client *http.Client, start int64, end int, i int, size int, ...) error
- func FileSenderCredentials(broadcast bool) (string, string)
- func GetFileParts(completefilename string, partSize uint64, filesize int64, i uint64, ...)
- func GetRequestedFile(activeClient *ClientListen, myname string, fileSenderName string, ...) string
- func ListenOnSelfPort(ln net.Listener, myname string, activeClient *ClientListen, ...)
- func MessageReceiverCredentials() (string, string)
- func RequestMessage(activeClient *ClientListen, name string, messageReceiverName string, ...) string
- func RequestSomeFile(activeClient *ClientListen, myname string, fileName string) string
- func SendFileParts(newfilerequest FileRequest, allfileparts []FilePartInfo, ...) int
- func SendFileRequestToPeer(connection net.Conn, fileRequest FileRequest, requestType string)
- func SendPart(names string, activeClient *ClientListen, newfilerequest FileRequest, ...)
- func SendingToServer(name []byte, query []byte, conn net.Conn, queryType string, listenPort []byte)
- type BaseRequest
- type Client
- type ClientFiles
- type ClientJob
- type ClientListen
- type ClientQuery
- type FilePartContents
- type FilePartInfo
- type FileRequest
- type MessageRequest
- type MyPeers
- type MyReceivedFiles
- type MyReceivedMessages
- type WriteCounter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsyncDownloader ¶
func AsyncDownloader(wg *sync.WaitGroup, client *http.Client, start int64, end int, i int, size int, url string, f *os.File) error
AsyncDownloader downloader function
func CheckFileExistence ¶
func CheckFileExistence(request FileRequest, directoryFiles *ClientFiles) bool
CheckFileExistence checking existence of file to send it to some peer
func DisplayNumRecentMessages ¶
func DisplayNumRecentMessages(mymessages *MyReceivedMessages, recentCount int) string
DisplayNumRecentMessages To display Num recent messages
func DisplayRecentUnseenMessages ¶
func DisplayRecentUnseenMessages(mymessages *MyReceivedMessages) string
DisplayRecentUnseenMessages To display the most recent messages which haven't been seen yet
func DummyAsync ¶
func DummyAsync(wg *sync.WaitGroup, client *http.Client, start int64, end int, i int, size int, url string, f *os.File) error
DummyAsync simulates Async
func FileSenderCredentials ¶
FileSenderCredentials getting the details for sending file request
func GetFileParts ¶
func GetFileParts(completefilename string, partSize uint64, filesize int64, i uint64, fileContents []byte, allFileParts []FilePartInfo, wgSplit *sync.WaitGroup, totalParts int)
GetFileParts - goroutine to get all the parts of file to be sent over the network
func GetRequestedFile ¶
func GetRequestedFile(activeClient *ClientListen, myname string, fileSenderName string, fileName string) string
GetRequestedFile To get file from a peer
func ListenOnSelfPort ¶
func ListenOnSelfPort(ln net.Listener, myname string, activeClient *ClientListen, myfiles map[string]MyReceivedFiles, mymessages *MyReceivedMessages, directoryFiles *ClientFiles)
ListenOnSelfPort listens for clients on network
func MessageReceiverCredentials ¶
MessageReceiverCredentials for receiving message credientials
func RequestMessage ¶
func RequestMessage(activeClient *ClientListen, name string, messageReceiverName string, message string) string
RequestMessage takes message from client and dials to receiver
func RequestSomeFile ¶
func RequestSomeFile(activeClient *ClientListen, myname string, fileName string) string
RequestSomeFile To broadcast the file request to everyone on network
func SendFileParts ¶
func SendFileParts(newfilerequest FileRequest, allfileparts []FilePartInfo, activeClient *ClientListen, myname string) int
SendFileParts send various file parts to peers
func SendFileRequestToPeer ¶
func SendFileRequestToPeer(connection net.Conn, fileRequest FileRequest, requestType string)
SendFileRequestToPeer To send the request to corresponding peer
func SendPart ¶
func SendPart(names string, activeClient *ClientListen, newfilerequest FileRequest, countSent int, allfileparts []FilePartInfo, wgSplit *sync.WaitGroup)
SendPart - To send each file part concurrently
Types ¶
type BaseRequest ¶
type BaseRequest struct { RequestType string // type of request FileRequest // Information about File requseter if its a file request FilePartInfo FilePartInfo // Information about file parts if its a file request MessageRequest // Details of message is its a message request }
BaseRequest : A base request which is used as a generic request for all types of P2P queries
type ClientFiles ¶
type ClientFiles struct {
FilesInDir []string
}
ClientFiles stores the files in the "files" directory of client
type ClientListen ¶
type ClientListen struct { List []string // names of all clients PeerIP map[string]string // IP to name mapping of all clients PeerListenPort map[string]string //Port at which all those clients are listening for P2P requests }
ClientListen Store - all client names,
IP to name mapping of all clients Port at which all those clients are listening for P2P requests
type ClientQuery ¶
ClientQuery : To store name and query of a client
type FilePartContents ¶
type FilePartContents struct {
Contents []byte
}
FilePartContents Contents of a part of file
type FilePartInfo ¶
type FilePartInfo struct { FileName string TotalParts int PartName string PartNumber int FilePartContents []byte }
FilePartInfo Complete Information regarding the file to share
func GetSplitFile ¶
func GetSplitFile(filename string, numberOfActiveClient int) []FilePartInfo
GetSplitFile fuction to return the splitted parts
type FileRequest ¶
FileRequest stores the queries and information about requester
type MessageRequest ¶
type MessageRequest struct { SenderQuery string SenderAddress string SenderName string Message string }
MessageRequest Stores the information about requester, who is sending the message (for the receiver to reply back)
type MyReceivedFiles ¶
type MyReceivedFiles struct { PartsReceived int MyFileName string // name of file MyFile []FilePartContents // Contents of the file FilePartInfo FilePartInfo // Information of various file parts }
MyReceivedFiles : To store the information of files received by client
type MyReceivedMessages ¶
type MyReceivedMessages struct { Counter int // The counter from which client has to start reading the messages MyMessages []MessageRequest // slice of structs of type MessageRequest to store all message requests }
MyReceivedMessages To store the information of the messages receievd