Пример #1
0
 //----------------------------------------------------------------------------------------------------
 /// <summary>
 /// 송신 : 스테이지 : 커스텀 데이터
 /// </summary>
 /// <param name="in_bits">커스텀 데이터</param>
 //----------------------------------------------------------------------------------------------------
 public void SendStageData( cBitStream in_bits )
 {
     cBitStream bits = new cBitStream();
     WriteOrder(		bits, eOrder.STAGE_DATA );
     bits.Write( in_bits.ToByteArray() );
     Send( bits );
 }
Пример #2
0
        //----------------------------------------------------------------------------------------------------
        /// <summary>
        /// 데이터 송신.
        /// </summary>
        /// <param name="bits">비트스트림 데이터</param>
        //----------------------------------------------------------------------------------------------------
        public void Send( cBitStream bits )
        {
            if( Connected==false ) return;

            if( bits.Length>0 )
            {
                try
                {
                    NetworkStream stream = m_client.GetStream();
                    if( stream == null ) return;
                    lock( stream )
                    {
                        BinaryWriter writer = new BinaryWriter( stream );
                        if( UseCryptogram )
                        {
                            byte[] buf = cCryptogram.Encrypt( bits.ToByteArray(), DataIV, DataKey );
                            writer.Write( (ushort)buf.Length );
                            writer.Write( buf );
                        }
                        else
                        {
                            byte[] buf = bits.ToByteArray();
                            writer.Write( (ushort)buf.Length );
                            writer.Write( buf );
                        }
                        writer.Flush();
                    }
                }
                catch ( Exception ex )
                {
                    Log( m_name+">>"+ex );
                    throw new Exception("error:Send");
                }
            }
        }