Ejemplo n.º 1
0
        /// <summary>
        /// 读取头信息的总长度 命令id 和序列号
        /// </summary>
        /// <param name="argSocket"></param>
        public void ReadHead(Socket argSocket)
        {
            byte[] vTempBytes = new byte[4];
            argSocket.Receive(vTempBytes);
            TotalMsgLen = SGIPCommand.Bytes4ToInt(vTempBytes); // 长度

            byte[] vCommandIdByte = new byte[4];
            argSocket.Receive(vCommandIdByte);
            CommandId = (uint)SGIPCommand.Bytes4ToInt(vCommandIdByte); // 命令id
            UnicomSN  = new byte[12];
            argSocket.Receive(vTempBytes);
            byte[] vSrcnodeByte = new byte[5];
            Buffer.BlockCopy(vTempBytes, 0, vSrcnodeByte, 1, 4);
            long vSrcNode = SGIPCommand.Bytes4ToLong(vSrcnodeByte);

            Buffer.BlockCopy(vTempBytes, 0, UnicomSN, 0, 4);
            argSocket.Receive(vTempBytes);
            string vDate = SGIPCommand.Bytes4ToInt(vTempBytes) + "";

            Buffer.BlockCopy(vTempBytes, 0, UnicomSN, 4, 4);
            argSocket.Receive(vTempBytes);
            string vSeqNum = SGIPCommand.Bytes4ToInt(vTempBytes) + "";

            SequenceNumber = vSrcNode + vDate + vSeqNum;
            Buffer.BlockCopy(vTempBytes, 0, UnicomSN, 8, 4);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// bind返回
        /// </summary>
        /// <param name="argCommand"></param>
        public BindResp(SGIPCommand argCommand)
        {
            _Header    = argCommand._Header;
            _BodyBytes = argCommand._BodyBytes;

            Result = argCommand._BodyBytes[0];
            byte[] vReserveBytes = new byte[8];
            Buffer.BlockCopy(argCommand._BodyBytes, 1, vReserveBytes, 0, 8);
            Reserve = Encoding.ASCII.GetString(vReserveBytes);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 初始化Read值
        /// </summary>
        /// <param name="argCommand"></param>
        public Bind(SGIPCommand argCommand)
        {
            _Header    = argCommand._Header;
            _BodyBytes = argCommand._BodyBytes;

            _LoginType = argCommand._BodyBytes[0];
            byte[] vLoginNameBytes = new byte[16];
            Buffer.BlockCopy(argCommand._BodyBytes, 1, vLoginNameBytes, 0, 16);
            _LoginName = Encoding.ASCII.GetString(vLoginNameBytes).Trim();

            byte[] vLoginPwdBytes = new byte[16];
            Buffer.BlockCopy(argCommand._BodyBytes, 17, vLoginPwdBytes, 0, 16);
            _Password = Encoding.ASCII.GetString(vLoginPwdBytes).Trim();

            byte[] vReserveByte = new byte[8];
            Buffer.BlockCopy(argCommand._BodyBytes, 33, vReserveByte, 0, 8);
            _Reserve = Encoding.ASCII.GetString(vReserveByte).Trim();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 获取头字节
 /// </summary>
 /// <param name="argSrcNode"></param>
 /// <returns></returns>
 public byte[] GetCommandHeadBytes()
 {
     byte[] vSrcNode   = SGIPCommand.LongToBytesReverse(SocketConfig.SourceNode);
     byte[] vDateCmd   = SGIPCommand.IntToBytesReverse(GetDateCmd());   // 命令产生日期
     byte[] vSeqNum    = SGIPCommand.IntToBytesReverse(GetSeqNumber()); // 序列号
     byte[] vMsgLen    = SGIPCommand.IntToBytesReverse(TotalMsgLen);    // 命令体总长度
     byte[] vCommandId = BitConverter.GetBytes(CommandId);
     Array.Reverse(vCommandId);
     SequenceNumber = SocketConfig.SourceNode.ToString() + SGIPCommand.Bytes4ToInt(vDateCmd) + SGIPCommand.Bytes4ToInt(vSeqNum);
     byte[] vCommandHeadbytes = new byte[(int)SGIPCommandDefine.LEN_SGIP_HEADER];
     byte[] vCmdseq           = new byte[12]; // 总序列号(MessageLength + Commandid + sequenceNumber)
     Buffer.BlockCopy(vMsgLen, 0, vCommandHeadbytes, 0, 4);
     Buffer.BlockCopy(vCommandId, 0, vCommandHeadbytes, 4, 4);
     if (UnicomSN != null)
     {
         Buffer.BlockCopy(UnicomSN, 0, vCmdseq, 0, 12);
         byte[] vTempBytes = new byte[4];
         Buffer.BlockCopy(UnicomSN, 0, vTempBytes, 0, 4);
         byte[] vSrcNodeByte = new byte[5];
         Buffer.BlockCopy(vTempBytes, 0, vSrcNodeByte, 1, 4);
         uint vSrc = BitConverter.ToUInt32(vSrcNodeByte, 0);
         Buffer.BlockCopy(UnicomSN, 4, vTempBytes, 0, 4);
         string vDate = SGIPCommand.Bytes4ToInt(vTempBytes) + "";
         Buffer.BlockCopy(UnicomSN, 8, vTempBytes, 0, 4);
         string vNum = SGIPCommand.Bytes4ToInt(vTempBytes) + "";
         SequenceNumber = vSrc + vDate + vNum;
     }
     else
     {
         Buffer.BlockCopy(vSrcNode, 0, vCmdseq, 0, 4);
         Buffer.BlockCopy(vDateCmd, 0, vCmdseq, 4, 4);
         Buffer.BlockCopy(vSeqNum, 0, vCmdseq, 8, 4);
     }
     Buffer.BlockCopy(vCmdseq, 0, vCommandHeadbytes, 8, 12);
     return(vCommandHeadbytes);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Submit响应
 /// </summary>
 /// <param name="argCommand"></param>
 public SubmitResp(SGIPCommand argCommand)
 {
     _Header = argCommand._Header;
     Result  = argCommand._BodyBytes[0];
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 解绑响应
 /// </summary>
 /// <param name="argCommand"></param>
 public UnBind(SGIPCommand argCommand)
 {
     _Header    = argCommand._Header;
     _BodyBytes = argCommand._BodyBytes;
 }