Esempio n. 1
0
        public void Start(SocketsConnection.ReceivedData delegate_)
        {
            this.Buffer = new byte[1024];
            this.ReceivedDataDelegate = delegate_;
            this.ReceiveCallback      = new AsyncCallback(this.ClientReceivedData);
            this.SendCallback         = new AsyncCallback(this.ClientSendedData);

            this.AcceptData();
        }
Esempio n. 2
0
        public void Dispose()
        {
            if (!this.Disconnected)
            {
                this.Disconnected = true;

                try
                {
                    this.Socket.Shutdown(SocketShutdown.Both);
                    this.Socket.Close();
                    this.Socket.Dispose();

                    if (this.Buffer != null)
                    {
                        Array.Clear(this.Buffer, 0, this.Buffer.Length);
                    }
                }
                catch
                {
                }

                this.Buffer               = null;
                this.ReceiveCallback      = null;
                this.SendCallback         = null;
                this.ReceivedDataDelegate = null;

                Skylight.GetSocketsManager().Disconnection(this.ID);

                if (Skylight.GetConfig()["emu.messages.connections"] == "1")
                {
                    Logging.WriteLine(">> Connection Dropped [" + this.ID + "] from [" + this.GetIP() + "] for reason: " + this.DisconnectReason);
                }
            }

            GC.SuppressFinalize(this);
        }