private void DealReceiveSharingInfo(RequestContent ResponseContent)
        {
            SecuruStik.Protocal.SharingInfo si = ResponseContent as SecuruStik.Protocal.SharingInfo;
            if (si != null)
            {
                try
                {
                    PreKeyring.SharingFile_Update(
                        new DB.SharingInfo
                    {
                        CopyRef  = si.Reference,
                        FileName = si.FileName,
                        ID_From  = si.ID_From,
                        CKEY_E   = si.CKey_E,
                        CKEY_F   = si.CKey_F,
                        CKEY_U   = si.CKey_U,
                        CKEY_W   = si.CKey_W
                    });

                    String savePath = Path.Combine(DropBoxController.Local_ShareInfoFolder,
                                                   String.Format("[{1}]{0}.{2}", si.FileName, si.ID_From, AppSetting.Name_ShareInfoFileExtension)
                                                   );
                    Byte[] sharingInfoBytes = CommunicatingProtocal.Serialize(si);
                    File.WriteAllBytes(BaseExtension.FileStringHelper.GetNonConflictFileName(savePath), sharingInfoBytes);
                }
                catch (System.Exception ex) {}
            }
        }
 public Boolean Send(SecuruStik.Protocal.Packet packet)
 {
     try
     {
         if (this.IsInited == false)
         {
             this.Init();
         }
         if (this.IsLogin == false)
         {
             this.Login();
         }
         byte[] packetBytes = CommunicatingProtocal.Serialize(packet);
         this.bw.Write(packetBytes.Length);
         this.bw.Write(packetBytes);
         this.bw.Flush();
         return(true);
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(new Form {
             TopMost = true, StartPosition = FormStartPosition.CenterScreen
         },
                         "Disconnect with server.\r\nPlease check your network setting or firewall.", ""
                         , MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(false);
     }
 }
        private void Login()
        {
            SecuruStik.Protocal.Request r = new SecuruStik.Protocal.Request(
                MessageType.Request_Login, this.UserEmail);

            byte[] packetBytes = CommunicatingProtocal.Serialize(r);
            this.bw.Write(packetBytes.Length);
            this.bw.Write(packetBytes);
            this.bw.Flush();

            this.IsLogin = true;
        }
Ejemplo n.º 4
0
 private void Send(User user, SecuruStik.Protocal.Packet packet)
 {
     try
     {
         byte[] packetBytes = CommunicatingProtocal.Serialize(packet);
         user.bw.Write(packetBytes.Length);
         user.bw.Write(packetBytes);
         user.bw.Flush();
     }
     catch (System.Exception)
     {
     }
 }