예제 #1
0
        internal void SendCommand(UdpCommandType cmd)
        {
            if (CheckCanSend(true) == UdpSendFailReason.None)
            {
                UdpStream stream = socket.GetWriteStream(mtu << 3, UdpSocket.HeaderBitSize);
                stream.WriteByte((byte)cmd, 8);

                UdpHeader header = MakeHeader(false);
                header.Pack(stream, socket);

                UdpHandle handle = MakeHandle(ref header);
                handle.Object = null;

                if (SendStream(stream, handle, false))
                {
                    // track stats
                    stats.PacketSent((uint)stream.Ptr >> 3);
                    socket.Stats.PacketSent((uint)stream.Ptr >> 3);
                }
                else
                {
                    // should we do something here?????
                }
            }
        }
예제 #2
0
        void SendRefusedCommand(UdpEndPoint endpoint)
        {
            UdpStream stream = GetWriteStream(Config.PacketSize << 3, HeaderBitSize);

            stream.WriteByte((byte)UdpCommandType.Refused, 8);

            UdpHeader header = new UdpHeader();

            header.IsObject    = false;
            header.AckHistory  = 0;
            header.AckSequence = 1;
            header.ObjSequence = 1;
            header.Now         = 0;
            header.Pack(stream, this);

            if (Send(endpoint, stream.Data, UdpMath.BytesRequired(stream.Ptr)) == false)
            {
                // do something here?
            }
        }