123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Xml;
- using LYFZ.Network.EnumerateLibrary;
- namespace LYFZ.Network
- {
-
-
-
-
-
- public struct TCP_FileProtocol
- {
- private readonly InformationType infoType;
- private readonly string content;
- private string _ExtraInfo;
- private string _ClientInfo;
-
- public TCP_FileProtocol(string content, string extraInfo="")
- {
- this.infoType = InformationType.Message;
- this.content = content;
- this._ExtraInfo = extraInfo;
- this._ClientInfo = "";
- this._ReceiveFileSize = 0;
- this.dataArray = null;
- this._ServerStartTimeStamp = LYFZ.Network.TCPNetworkServer.TCP_NetworkServer.ServerStartTimeStamp;
- }
-
-
-
-
-
-
-
-
-
- public TCP_FileProtocol(InformationType type, string content, string extraInfo = "", string clientInfo="")
- {
- this.infoType = type;
- this.content = content;
- this._ExtraInfo = extraInfo;
- this._ClientInfo = clientInfo;
- this._ReceiveFileSize = 0;
- this.dataArray = null;
- this._ServerStartTimeStamp = LYFZ.Network.TCPNetworkServer.TCP_NetworkServer.ServerStartTimeStamp;
- }
- public string ClientInfo
- {
- get { return _ClientInfo; }
- set { _ClientInfo = value; }
- }
-
-
-
- public InformationType InfoType
- {
- get { return infoType; }
- }
-
-
-
-
- public string ExtraInfo
- {
- get { return _ExtraInfo; }
- set { _ExtraInfo = value; }
- }
-
-
-
- public string Content
- {
- get { return content; }
- }
- long _ReceiveFileSize;
- public long ReceiveFileSize
- {
- get { return _ReceiveFileSize; }
- set { _ReceiveFileSize = value; }
- }
- string _ServerStartTimeStamp;
-
-
-
- public string ServerStartTimeStamp
- {
- get { return _ServerStartTimeStamp; }
- set { _ServerStartTimeStamp = value; }
- }
- byte[] dataArray;
-
-
-
- public byte[] DataArray
- {
- get { return dataArray; }
- set { dataArray = value; }
- }
-
-
-
-
- public override string ToString()
- {
-
- StringBuilder strXML = new StringBuilder();
- string thisInfoType = InfoType.ToString();
- if (InfoType == InformationType.Message)
- {
- thisInfoType = "msg";
- }
- else if (InfoType == InformationType.File)
- {
- thisInfoType = "file";
- }
- string encodeContent = Content;
- string encodeExtraInfo = ExtraInfo;
-
- encodeContent = LYFZ.WinAPI.SDKSecurity.Encode(Content);
- encodeExtraInfo = LYFZ.WinAPI.SDKSecurity.Encode(ExtraInfo);
-
- strXML.Append("<lyfz_protocol>");
- strXML.Append(String.Format("<information Type=\"{0}\" ExtraInfo=\"{1}\" ReceiveFileSize=\"{2}\" ClientInfo=\"{3}\" ServerStartTimeStamp=\"{4}\"><![CDATA[{5}]]></information>", thisInfoType, encodeExtraInfo, ReceiveFileSize, ClientInfo, this.ServerStartTimeStamp, encodeContent));
- strXML.Append("</lyfz_protocol>");
- return strXML.ToString();
- }
- }
- }
|