/// <summary>
        /// Send the provided packet data
        /// </summary>
        /// <param name="packet"></param>
        public void SendData(PacketData packet)
        {
            lock (socket)
            {
                NetworkStream ns = socket.GetStream();

                byte[] rawData  = packet.ToByte();
                byte[] longData = BitConverter.GetBytes(rawData.LongLength);

                if (BitConverter.IsLittleEndian)
                {
                    Array.Reverse(longData);
                }

                byte[] finalData = new byte[rawData.Length + longData.Length];
                Array.Copy(longData, 0, finalData, 0, longData.Length);
                Array.Copy(rawData, 0, finalData, longData.Length, rawData.Length);

                ns.Write(finalData, 0, finalData.Length);
                lastMsg = Terminal.GetTime();
            }
        }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="socketObject"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public void PushSend(SocketObject socketObject, PacketData data)
 {
     PushSend(socketObject, data.ToByte());
 }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void PushSend(PacketData data)
 {
     PushSend(data.ToByte());
 }