Beispiel #1
0
 void fileTransferView_GetContactListEvent(string contact)
 {
     if (((StateIdle)currentState).MadeConnectionRequests.ContainsKey(contact))
     {
         ConnectionDataMessageData data = ((StateIdle)currentState).MadeConnectionRequests[contact];
         IDictionary<int, string> receivedFileList = peerConnectionManager.getFileListFromPeerDelegate.Invoke(contact, data.IpAddress, data.Port);
         _downloadedFileLists[contact] = receivedFileList;
     }
     else
     {
         AMessageData messageData = new ConnectionDataRequestedMessageData(this.currentUserName, contact);
         Common.Protocol.Message connDataMessage = new Common.Protocol.Message(new MessageHeader(ServiceTypes.CONNECTION_REQ), messageData);
         this.outputMessageQueue.Enqueue(connDataMessage);
         ((StateIdle)currentState).PendingConnectionRequests.Add(new KeyValuePair<string, ConnectionDataMessageData>(contact, null));
         return;
     }
     IDictionary<int, string> fileList = _downloadedFileLists[contact];
     IList<string> toReturn = new List<string>();
     foreach (KeyValuePair<int, string> pair in fileList)
     {
         toReturn.Add(pair.Value);
     }
     fileTransferView.LoadList(contact, toReturn);
 }
 public void ReceiveFile(string filename, string writeLocation)
 {
     if (receiverConnectionHandler == null)
     {
         AMessageData messageData = new ConnectionDataRequestedMessageData(this.currentClientName, this.receiverName);
         Message message = new Message(new MessageHeader(ServiceTypes.CONNECTION_REQ), messageData);
         OnSendServerMessage(message);
         this._lastRequestedFile = new KeyValuePair<string, string>(filename, writeLocation);
         this.alreadyRequested = true;
     }
     else
     {
         int fileId = -1;
         foreach (KeyValuePair<int, string> pair in _fileList)
         {
             if (pair.Value == filename)
             {
                 fileId = pair.Key;
             }
         }
         if (fileId == -1)
             return;
         receiverConnectionHandler.receiveFileDelegate.Invoke(writeLocation, fileId);
     }
 }
Beispiel #3
0
 private void SendConnectionDataResponse(ConnectionDataRequestedMessageData receivedMessageData)
 {
     AMessageData messageData = new ConnectionDataMessageData(this._userName, receivedMessageData.SenderUserName, this._ip, this._port);
     Common.Protocol.Message response = new Common.Protocol.Message(new MessageHeader(ServiceTypes.CONNECTION_DATA), messageData);
     _outputMessagesList.Add(response);
 }
 public void CreatePeerToPeerConnection()
 {
     AMessageData messageData = new ConnectionDataRequestedMessageData(this.currentClientName, this.receiverName);
     Message message = new Message(new MessageHeader(ServiceTypes.CONNECTION_REQ), messageData);
     OnSendServerMessage(message);
 }