private void DealReceivedData(User client, byte[] packetBytes) { SecuruStik.Protocal.Packet packet = (Packet)CommunicatingProtocal.ExplainPacket(packetBytes); SecuruStik.Protocal.Request request = packet as Request; switch (packet.Type) { case MessageType.Request_Login: Login(client, request); break; case MessageType.Request_Logout: Logout(client); break; case MessageType.Request_GetPK: Request_GetPK(client, request); break; case MessageType.Request_SetPK: Request_SetPK(client, request); break; case MessageType.Request_GetSharingInfo: Request_GetSharingInfo(client, request.UserID); break; case MessageType.Request_SetSharingInfo: Request_SetSharingInfo(client, request); break; } }
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; }
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) { } }
private void DealReceivedData(Byte[] packetBytes) { Packet packet = (Packet)CommunicatingProtocal.ExplainPacket(packetBytes); Response response = (Response)packet; if (response.IsSuccess == false) { this.DealReceiveError(response); } else { switch (response.Type) { case MessageType.Request_Login: this.IsInited = true; Resume_ReceiveThread(); break; case MessageType.Response_GetPK: this.DealReceivePK(response.ResponseContent); break; case MessageType.Response_GetSharingInfo: this.DealReceiveSharingInfo(response.ResponseContent); break; } } }