Esempio n. 1
0
        public override bool SendTarget(PortalPacket p, ushort targetID, bool getResponse)
        {
            if (!CheckAlive())
            {
                return(false);
            }

            var any = false;

            try
            {
                foreach (var c in Clients)
                {
                    try
                    {
                        if (c.SendTarget(p, targetID, getResponse))
                        {
                            any = true;
                        }
                    }
                    catch
                    { }
                }
            }
            catch
            { }

            return(any);
        }
Esempio n. 2
0
        public override bool SendExcept(PortalPacket p, ushort exceptID)
        {
            if (!CheckAlive())
            {
                return(false);
            }

            var any = false;

            try
            {
                foreach (var c in Clients)
                {
                    try
                    {
                        if (c.SendExcept(p, exceptID))
                        {
                            any = true;
                        }
                    }
                    catch
                    { }
                }
            }
            catch
            { }

            return(any);
        }
Esempio n. 3
0
        private bool InternalSend(PortalPacket p, bool getResponse)
        {
            var buffer = p.Compile();

            if (buffer == null)
            {
                ToConsole("Send: Buffer Null for {0}", p.ID);

                return(false);
            }

            if (buffer.Length < PortalPacket.MinSize || buffer.Length > PortalPacket.MaxSize)
            {
                ToConsole(
                    "Send: Size Out Of Range for {0} at {1}/{2}-{3} bytes",
                    p.ID,
                    buffer.Length,
                    PortalPacket.MinSize,
                    PortalPacket.MaxSize);

                return(false);
            }

            lock (_SendLock)
            {
                var size = buffer.Length;

                while (size > 0 && _Client != null)
                {
                    size -= _Client.Send(buffer, buffer.Length - size, size, SocketFlags.None);

                    if (!_Client.Connected)
                    {
                        break;
                    }

                    Thread.Sleep(10);
                }

                if (size > 0)
                {
                    ToConsole("Send: Failed for {0} at {1}/{2} bytes", p.ID, buffer.Length - size, buffer.Length);

                    Dispose();
                    return(false);
                }

                ToConsole("Send: Sent Packet {0} at {1} bytes", p.ID, buffer.Length);
            }

            if (getResponse)
            {
                Receive();
            }

            ProcessReceiveQueue();

            return(true);
        }
Esempio n. 4
0
        public override bool SendTarget(PortalPacket p, ushort targetID)
        {
            if (!IsAlive)
            {
                return(false);
            }

            var any = 0;

            foreach (var c in Clients)
            {
                if (c.SendTarget(p, targetID))
                {
                    ++any;
                }
            }

            return(any > 0);
        }
Esempio n. 5
0
        public override bool Send(PortalPacket p)
        {
            if (!IsAlive)
            {
                return(false);
            }

            var any = 0;

            foreach (var c in Clients)
            {
                if (c.Send(p))
                {
                    ++any;
                }
            }

            return(any > 0);
        }
Esempio n. 6
0
 public override bool Send(PortalPacket p)
 {
     return(CheckAlive() && InternalSend(p));
 }
Esempio n. 7
0
 public override bool SendTarget(PortalPacket p, ushort targetID)
 {
     return CheckAlive() && _ServerID == targetID && InternalSend(p);
 }
Esempio n. 8
0
 public abstract bool Send(PortalPacket p);
Esempio n. 9
0
 public abstract bool SendExcept(PortalPacket p, ushort exceptID, bool getResponse);
Esempio n. 10
0
 public bool SendTarget(PortalPacket p, ushort targetID)
 {
     return(SendTarget(p, targetID, false));
 }
Esempio n. 11
0
        public override bool Send(PortalPacket p)
        {
            if (!CheckAlive())
            {
                return false;
            }

            var any = false;

            try
            {
                foreach (var c in Clients)
                {
                    try
                    {
                        if (c.Send(p))
                        {
                            any = true;
                        }
                    }
                    catch
                    { }
                }
            }
            catch
            { }

            return any;
        }
Esempio n. 12
0
 public bool SendExcept(PortalPacket p, ushort exceptID)
 {
     return SendExcept(p, exceptID, false);
 }
Esempio n. 13
0
 public static bool SendExcept(PortalPacket p, ushort exceptID, bool getResponse)
 {
     return IsAlive && Transport.SendExcept(p, exceptID, getResponse);
 }
Esempio n. 14
0
 public static bool SendExcept(PortalPacket p, ushort exceptID)
 {
     return IsAlive && Transport.SendExcept(p, exceptID);
 }
Esempio n. 15
0
 public static bool Send(PortalPacket p, bool getResponse)
 {
     return IsAlive && Transport.Send(p, getResponse);
 }
Esempio n. 16
0
 public static bool Send(PortalPacket p)
 {
     return IsAlive && Transport.Send(p);
 }
Esempio n. 17
0
 public abstract bool SendTarget(PortalPacket p, ushort targetID);
Esempio n. 18
0
 public abstract bool SendExcept(PortalPacket p, ushort exceptID);
Esempio n. 19
0
 public override bool SendExcept(PortalPacket p, ushort exceptID)
 {
     return(CheckAlive() && _ServerID != exceptID && InternalSend(p));
 }
Esempio n. 20
0
 public bool Send(PortalPacket p)
 {
     return Send(p, false);
 }
Esempio n. 21
0
 public static bool SendTarget(PortalPacket p, ushort targetID, bool getResponse)
 {
     return IsAlive && Transport.SendTarget(p, targetID, getResponse);
 }
Esempio n. 22
0
 public bool SendTarget(PortalPacket p, ushort targetID)
 {
     return SendTarget(p, targetID, false);
 }
Esempio n. 23
0
        private bool InternalSend(PortalPacket p, bool getResponse)
        {
            var buffer = p.Compile();

            if (buffer == null)
            {
                ToConsole("Send: Buffer Null for {0}", p.ID);

                return false;
            }

            if (buffer.Length < PortalPacket.MinSize || buffer.Length > PortalPacket.MaxSize)
            {
                ToConsole(
                    "Send: Size Out Of Range for {0} at {1}/{2}-{3} bytes",
                    p.ID,
                    buffer.Length,
                    PortalPacket.MinSize,
                    PortalPacket.MaxSize);

                return false;
            }

            lock (_SendLock)
            {
                var size = buffer.Length;

                while (size > 0 && _Client != null)
                {
                    size -= _Client.Send(buffer, buffer.Length - size, size, SocketFlags.None);

                    if (!_Client.Connected)
                    {
                        break;
                    }

                    Thread.Sleep(10);
                }

                if (size > 0)
                {
                    ToConsole("Send: Failed for {0} at {1}/{2} bytes", p.ID, buffer.Length - size, buffer.Length);

                    Dispose();
                    return false;
                }

                ToConsole("Send: Sent Packet {0} at {1} bytes", p.ID, buffer.Length);
            }

            if (getResponse)
            {
                Receive();
            }

            ProcessReceiveQueue();

            return true;
        }
Esempio n. 24
0
 public override bool Send(PortalPacket p, bool getResponse)
 {
     return CheckAlive() && InternalSend(p, getResponse);
 }
Esempio n. 25
0
 public static bool SendTarget(PortalPacket p, ushort targetID)
 {
     return(IsAlive && Transport.SendTarget(p, targetID));
 }
Esempio n. 26
0
 public abstract bool Send(PortalPacket p, bool getResponse);
Esempio n. 27
0
 public override bool Send(PortalPacket p)
 {
     return CheckAlive() && InternalSend(p);
 }
Esempio n. 28
0
 public abstract bool SendTarget(PortalPacket p, ushort targetID, bool getResponse);
Esempio n. 29
0
 public override bool Send(PortalPacket p, bool getResponse)
 {
     return(CheckAlive() && InternalSend(p, getResponse));
 }
Esempio n. 30
0
 public static bool Send(PortalPacket p)
 {
     return(IsAlive && Transport.Send(p));
 }
Esempio n. 31
0
 public abstract bool Send(PortalPacket p);
Esempio n. 32
0
 public static bool SendExcept(PortalPacket p, ushort exceptID)
 {
     return(IsAlive && Transport.SendExcept(p, exceptID));
 }
Esempio n. 33
0
 public abstract bool SendExcept(PortalPacket p, ushort exceptID);
Esempio n. 34
0
 public override bool SendExcept(PortalPacket p, ushort exceptID)
 {
     return CheckAlive() && _ServerID != exceptID && InternalSend(p);
 }
Esempio n. 35
0
 public abstract bool SendTarget(PortalPacket p, ushort targetID);
Esempio n. 36
0
        private bool InternalSend(PortalPacket p)
        {
            if (!IsAlive)
            {
                return false;
            }

            var buffer = p.Compile();

            if (buffer == null)
            {
                if (_DisplaySendOutput)
                {
                    ToConsole("Send: Buffer Null for {0}", p.ID);
                }

                return false;
            }

            var size = buffer.Length;

            if (size < PortalPacket.MinSize || size > PortalPacket.MaxSize)
            {
                if (_DisplaySendOutput)
                {
                    ToConsole(
                        "Send: Size Out Of Range for {0} at {1}/{2}-{3} bytes",
                        p.ID,
                        size,
                        PortalPacket.MinSize,
                        PortalPacket.MaxSize);
                }

                return false;
            }

            var length = size;

            lock (_SendLock)
            {
                while (length > 0 && _Client != null)
                {
                    length -= _Client.Send(buffer, size - length, length, SocketFlags.None);

                    if (!_Client.Connected || length <= 0)
                    {
                        break;
                    }

                    Thread.Sleep(10);
                }
            }

            if (length > 0)
            {
                if (_DisplaySendOutput)
                {
                    ToConsole("Send: Failed for {0} at {1}/{2} bytes", p.ID, size - length, size);
                }

                return false;
            }

            if (_DisplaySendOutput)
            {
                ToConsole("Send: Sent Packet {0} at {1} bytes", p.ID, size);
            }

            lock (_GetResponseLock)
            {
                if (p.GetResponse)
                {
                    Receive();
                    ProcessReceiveQueue();
                }
            }

            return true;
        }
Esempio n. 37
0
 public static bool Send(PortalPacket p, bool getResponse)
 {
     return(IsAlive && Transport.Send(p, getResponse));
 }
Esempio n. 38
0
 public override bool SendTarget(PortalPacket p, ushort targetID)
 {
     return(CheckAlive() && _ServerID == targetID && InternalSend(p));
 }
Esempio n. 39
0
 public static bool SendExcept(PortalPacket p, ushort exceptID, bool getResponse)
 {
     return(IsAlive && Transport.SendExcept(p, exceptID, getResponse));
 }
Esempio n. 40
0
        private bool InternalSend(PortalPacket p)
        {
            if (!IsAlive)
            {
                return(false);
            }

            var buffer = p.Compile();

            if (buffer == null)
            {
                if (_DisplaySendOutput)
                {
                    ToConsole("Send: Buffer Null for {0}", p.ID);
                }

                return(false);
            }

            var size = buffer.Length;

            if (size < PortalPacket.MinSize || size > PortalPacket.MaxSize)
            {
                if (_DisplaySendOutput)
                {
                    ToConsole(
                        "Send: Size Out Of Range for {0} at {1}/{2}-{3} bytes",
                        p.ID,
                        size,
                        PortalPacket.MinSize,
                        PortalPacket.MaxSize);
                }

                return(false);
            }

            var length = size;

            lock (_SendLock)
            {
                while (length > 0 && _Client != null)
                {
                    length -= _Client.Send(buffer, size - length, length, SocketFlags.None);

                    if (!_Client.Connected || length <= 0)
                    {
                        break;
                    }

                    Thread.Sleep(10);
                }
            }

            if (length > 0)
            {
                if (_DisplaySendOutput)
                {
                    ToConsole("Send: Failed for {0} at {1}/{2} bytes", p.ID, size - length, size);
                }

                return(false);
            }

            if (_DisplaySendOutput)
            {
                ToConsole("Send: Sent Packet {0} at {1} bytes", p.ID, size);
            }

            lock (_GetResponseLock)
            {
                if (p.GetResponse)
                {
                    Receive();
                    ProcessReceiveQueue();
                }
            }

            return(true);
        }
Esempio n. 41
0
 public override bool Send(PortalPacket p)
 {
     return(InternalSend(p));
 }
Esempio n. 42
0
 public abstract bool Send(PortalPacket p, bool getResponse);
Esempio n. 43
0
        private bool InternalSend(PortalPacket p)
        {
            if (p == null)
            {
                return(false);
            }

            if (IsDisposing && p.ID != 255)
            {
                return(false);
            }

            if (!IsAlive)
            {
                return(false);
            }

            /*
             * while (!_ReceiveSync.WaitOne(10))
             * {
             *      if (!IsAlive || (Portal.Ticks % 1000 == 0 && !IsConnected))
             *      {
             *              return false;
             *      }
             *
             *      Thread.Sleep(1);
             * }
             */
            if (IsDisposing && p.ID != 255)
            {
                return(false);
            }

            if (!IsAlive)
            {
                return(false);
            }

            try
            {
                _NoReceive = true;

                var buffer = p.Compile();

                if (buffer == null)
                {
                    if (_DisplaySendOutput)
                    {
                        ToConsole("Send: Buffer Null for {0}", p.ID);
                    }

                    Dispose();
                    return(false);
                }

                var size = buffer.Size;

                if (size < PortalPacket.MinSize || size > PortalPacket.MaxSize)
                {
                    if (_DisplaySendOutput)
                    {
                        ToConsole(
                            "Send: Size Out Of Range for {0} at {1} / {2} - {3} bytes",
                            p.ID,
                            size,
                            PortalPacket.MinSize,
                            PortalPacket.MaxSize);
                    }

                    Dispose();
                    return(false);
                }

                var length = buffer.Send(_Client, 0, size);

                if (length < size)
                {
                    if (_DisplaySendOutput)
                    {
                        ToConsole("Send: Failed for {0} at {1} / {2} bytes", p.ID, length, size);
                    }

                    Dispose();
                    return(false);
                }

                if (_DisplaySendOutput)
                {
                    ToConsole("Send: Packet {0} at {1} bytes", p.ID, size);
                }

                if (p.GetResponse)
                {
                    if (!Receive(true))
                    {
                        if (_DisplaySendOutput)
                        {
                            ToConsole("Send: {0} requires a response which could not be handled.", p.ID);
                        }

                        Dispose();
                        return(false);
                    }

                    ProcessReceiveQueue();
                }

                _NoReceive = false;

                return(true);
            }
            catch (Exception e)
            {
                ToConsole("Send: Exception Thrown", e);

                Dispose();
                return(false);
            }
            finally
            {
                _NoReceive = false;
            }
        }
Esempio n. 44
0
 public abstract bool SendExcept(PortalPacket p, ushort exceptID, bool getResponse);
Esempio n. 45
0
 public bool Send(PortalPacket p)
 {
     return(Send(p, false));
 }
Esempio n. 46
0
 public abstract bool SendTarget(PortalPacket p, ushort targetID, bool getResponse);
Esempio n. 47
0
 public bool SendExcept(PortalPacket p, ushort exceptID)
 {
     return(SendExcept(p, exceptID, false));
 }
Esempio n. 48
0
        public override bool SendTarget(PortalPacket p, ushort targetID)
        {
            if (!CheckAlive())
            {
                return false;
            }

            var any = false;

            try
            {
                foreach (var c in Clients)
                {
                    try
                    {
                        if (c.SendTarget(p, targetID))
                        {
                            any = true;
                        }
                    }
                    catch
                    { }
                }
            }
            catch
            { }

            return any;
        }
Esempio n. 49
0
        public override bool SendExcept(PortalPacket p, ushort exceptID, bool getResponse)
        {
            if (!CheckAlive())
            {
                return false;
            }

            var any = false;

            try
            {
                foreach (var c in Clients)
                {
                    try
                    {
                        if (c.SendExcept(p, exceptID, getResponse))
                        {
                            any = true;
                        }
                    }
                    catch
                    { }
                }
            }
            catch
            { }

            return any;
        }