public void StartFTPListeing(FTPRcvObj rcvObj, string savePath)
 {
     try
     {
         if (mFtpServer == null || !mFtpServer.isListening())
         {
             string path;
             if (savePath != null && !savePath.Trim().Equals("")) path = savePath;
             else
                 path = string.Format(WeDoCommon.ConstDef.MSGR_DATA_FILE_DIR, ConfigHelper.Id);
             StateObject stateObj = new StateObject();
             mFtpServer = new FtpServerMgr(ConfigHelper.SocketPortFtp, path);
             mFtpServer.SocStatusChanged += DisplayFTPStatusOnStatusChanged;
             mFtpServer.ReadyToListen += ProcessOnFTPReadyToListen;
             mFtpServer.FTPReceivingProgressed += ProcessOnFTPReceivingProgressed;
             mFtpServer.FTPReceivingFinished += ProcessOnFTPReceivingFinished;
             mFtpServer.FTPReceivingCanceled += ProcessOnFTPReceivingCanceled;
             mFtpServer.FTPReceivingFailed += ProcessOnFTPReceivingFailed;
             mFtpServer.DoRun(stateObj);
         }
         else
         {
             OnFTPReadyToListen(new SocStatusEventArgs(new StateObject()));
         }
     }
     catch (Exception e)
     {
         Logger.error("StartFTPListeing 에러 : " + e.ToString());
     }
 }
Example #2
0
 public void StartFTPListeing(FTPRcvObj rcvObj, string savePath)
 {
     try
     {
         if (mFtpServer == null || !mFtpServer.isListening())
         {
             string path;
             if (savePath != null && !savePath.Trim().Equals(""))
             {
                 path = savePath;
             }
             else
             {
                 path = string.Format(WeDoCommon.ConstDef.MSGR_DATA_FILE_DIR, ConfigHelper.Id);
             }
             StateObject stateObj = new StateObject();
             mFtpServer = new FtpServerMgr(ConfigHelper.SocketPortFtp, path);
             mFtpServer.SocStatusChanged       += DisplayFTPStatusOnStatusChanged;
             mFtpServer.ReadyToListen          += ProcessOnFTPReadyToListen;
             mFtpServer.FTPReceivingProgressed += ProcessOnFTPReceivingProgressed;
             mFtpServer.FTPReceivingFinished   += ProcessOnFTPReceivingFinished;
             mFtpServer.FTPReceivingCanceled   += ProcessOnFTPReceivingCanceled;
             mFtpServer.FTPReceivingFailed     += ProcessOnFTPReceivingFailed;
             mFtpServer.DoRun(stateObj);
         }
         else
         {
             OnFTPReadyToListen(new SocStatusEventArgs(new StateObject()));
         }
     }
     catch (Exception e)
     {
         Logger.error("StartFTPListeing 에러 : " + e.ToString());
     }
 }
Example #3
0
 public DownloadForm(MsgrConnection connection, FTPRcvObj info)
 {
     InitializeComponent();
     this.connection = connection;
     this.rcvObj = info;
     this.formKey = info.Key;
     Initialize();
 }
Example #4
0
 public DownloadForm(MsgrConnection connection, FTPRcvObj info)
 {
     InitializeComponent();
     this.connection = connection;
     this.rcvObj     = info;
     this.formKey    = info.Key;
     Initialize();
 }
 public bool SendMsgRejectFTP(FTPRcvObj obj)
 {
     return(msgClient.NotifyFTPReject(obj.RemoteEndPoint, obj.SenderId, obj.FileName, obj.FileSize));
 }
        /// <summary>
        /// TcpClient인 경우 처리
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void ProcessOnMessageReceived(object sender, SocStatusEventArgs e)
        {
            //OnMessageReceived(e);
            switch (e.Status.Cmd)
            {
                case MsgDef.MSG_TEXT:
                    {
                        OnTCPMsgReceived(e);
                        break;
                    }
                case MsgDef.MSG_BYE:
                    //처리없음
                    break;
                case MsgDef.MSG_FTP_INFO_TO_RCV:
                    //받는쪽. 파일전송의사가 전달됨
                    //1. 서버로 재전송
                    {
                        //string msg = e.Status.Data.Substring(MsgDef.MSG_TEXT.Length+1); //"MSG|..."
                        //this.Send(e.Status.Data);
                        //2. 하위단에서 이벤트처리토록 둠.
                        OnManagerStatusChanged(string.Format("2단계 서버 =>수신자 파일전송공지[{0}]", e.Status.Data));
                        string[] msgToken = e.Status.Data.Split(SocConst.TOKEN);
                        string senderId = msgToken[1];
                        string fileName = msgToken[2];
                        long fileSize = Convert.ToInt64(msgToken[3]);
                        string mapKey = SocUtils.GenerateFTPClientKey(senderId, fileName, fileSize, mKey);
                        FTPRcvObj rcvObj = new FTPRcvObj((IPEndPoint)e.Status.Soc.RemoteEndPoint, mapKey, fileName, fileSize, senderId);
                        OnFTPSendingNotified(new SocFTPInfoEventArgs<FTPRcvObj>(rcvObj));
                        break;
                    }
                case MsgDef.MSG_FTP_READY_TO_SND://header|(senderid|ip)|filename|filesize|(receiverId|ip or m) 'm'은 서버
                    {
                        //수신준비된것이 확인됨.==> FTP기동
                        //필요한 인자: 파일정보, 수신자정보
                        OnManagerStatusChanged(string.Format("4단계 서버=>전송자 파일수신준비완료[{0}]", e.Status.Data));
                        string[] msgToken = e.Status.Data.Split(SocConst.TOKEN);
                        string fileName = msgToken[2];
                        long fileSize = Convert.ToInt64(msgToken[3]);
                        string receiverId = msgToken[4];
                        string mapKey = SocUtils.GenerateFTPClientKey(mKey, fileName, fileSize, receiverId);
                        FTPSendObj sendObj = mFileInfoMap[mapKey];
                        string fullFileName = sendObj.FileName;

                        if (mFileInfoMap.ContainsKey(mapKey))
                            mFileInfoMap.Remove(mapKey);
                        StartFTP(sendObj.RemoteEndPoint, receiverId, fullFileName, fileSize);
                        Thread thServer = new Thread(new ParameterizedThreadStart(SendFile));
                        thServer.Start((object)mapKey);

                        OnFTPSendingAccepted(new SocFTPInfoEventArgs<FTPSendObj>(sendObj));
                        break;
                    }
                case MsgDef.MSG_FTP_REJECT_TO_SND://header|(senderid|ip)|filename|filesize|(receiverId|ip or m) 'm'은 서버
                    {
                        //파일전송의사가 전달됨
                        //처리없음
                        OnManagerStatusChanged(string.Format("4단계 서버=>전송자 파일수신준비거부[{0}]", e.Status.Data));
                        string[] msgToken = e.Status.Data.Split(SocConst.TOKEN);
                        string fileName = msgToken[2];
                        long fileSize = Convert.ToInt64(msgToken[3]);
                        string receiverId = msgToken[4];
                        string mapKey = SocUtils.GenerateFTPClientKey(mKey, fileName, fileSize, receiverId);
                        FTPSendObj sendObj = mFileInfoMap[mapKey];
                        OnFTPSendingRejected(new SocFTPInfoEventArgs<FTPSendObj>(sendObj));
                        break;
                    }
                default:
                    break;

            }
        }
 public bool SendMsgRejectFTP(FTPRcvObj obj)
 {
     return msgClient.NotifyFTPReject(obj.RemoteEndPoint, obj.SenderId, obj.FileName, obj.FileSize);
 }