OpenMetaverse.Simulator.Disconnect C# (CSharp) Method

Disconnect() public method

Disconnect from this simulator
public Disconnect ( bool sendCloseCircuit ) : void
sendCloseCircuit bool
return void
        public void Disconnect(bool sendCloseCircuit)
        {
            if (connected)
            {
                connected = false;

                // Destroy the timers
                if (AckTimer != null) AckTimer.Dispose();
                if (StatsTimer != null) StatsTimer.Dispose();
                if (PingTimer != null) PingTimer.Dispose();

                // Kill the current CAPS system
                if (Caps != null)
                {
                    Caps.Disconnect(true);
                    Caps = null;
                }

                if (sendCloseCircuit)
                {
                    // Try to send the CloseCircuit notice
                    CloseCircuitPacket close = new CloseCircuitPacket();
                    UDPPacketBuffer buf = new UDPPacketBuffer(remoteEndPoint);
                    byte[] data = close.ToBytes();
                    Buffer.BlockCopy(data, 0, buf.Data, 0, data.Length);
                    buf.DataLength = data.Length;

                    AsyncBeginSend(buf);
                }

                // Shut the socket communication down
                Stop();
            }
        }

Usage Example

Beispiel #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sim"></param>
        /// <param name="sendCloseCircuit"></param>
        public void DisconnectSim(Simulator sim, bool sendCloseCircuit)
        {
            if (sim != null)
            {
                sim.Disconnect(sendCloseCircuit);

                // Fire the SimDisconnected event if a handler is registered
                if (OnSimDisconnected != null)
                {
                    try { OnSimDisconnected(sim, DisconnectType.NetworkTimeout); }
                    catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
                }

                lock (Simulators) Simulators.Remove(sim);

                if (Simulators.Count == 0) Shutdown(DisconnectType.SimShutdown);
            }
            else
            {
                Logger.Log("DisconnectSim() called with a null Simulator reference", Helpers.LogLevel.Warning, Client);
            }
        }
All Usage Examples Of OpenMetaverse.Simulator::Disconnect