Exemplo n.º 1
0
        public void Send(IPEndPoint remoteEP, MainPacket <T> packet)
        {
            packet.Data = Convert.Encode(packet.Data);
            var sendBytes = packet.GetBytes();

            udpClient.Send(sendBytes, sendBytes.Length, remoteEP);
        }
Exemplo n.º 2
0
        public void Send(MainPacket <T> packet)
        {
            packet.Data = Convert.Encode(packet.Data);
            var bytesSendData = packet.GetBytes();

            if (ns == null)
            {
                throw new Exception("is not connected.");
            }
            if (!ns.CanWrite)
            {
                throw new Exception("stream can't write!");
            }
            lock (ns)
            {
                ns.Write(bytesSendData, 0, bytesSendData.Length);
                ns.Flush();
            }
        }