Beispiel #1
0
 private void CloseConnetion()
 {
     try
     {
         _client.Client.Shutdown(SocketShutdown.Send);
     }
     catch (Exception)
     {
         Logger.LogWarning("Socket errored before shutdown and disconnect");
     }
     Logger.LogInformation("Http no data to read, closed {0}", Id);
     RemoteDisconnected?.Invoke(this);
 }
Beispiel #2
0
        /// <summary>
        /// Called on the client when a remote disconnects.
        /// </summary>
        /// <param name="writer"></param>
        protected virtual void OnRemoteDisconnected(NetworkWriter writer)
        {
            if (m_Connections == null)
            {
                return;
            }

            int connectionID = writer.ReadInt16();

            RemoteDisconnected?.Invoke(m_Connections[connectionID]);
            DebugLog(string.Format("Remote {0} disconnected from the server.", connectionID));
            m_Connections.Remove(connectionID);
        }
Beispiel #3
0
        virtual internal void OnRemoteDisconnected(INetworkNode Remote)
        {
            if (Remote == null)
            {
                return;
            }

            Task.Run(() =>
            {
                RemoteDisconnected?.Invoke(this, new InternetConnectionEventArgs
                {
                    Local  = this,
                    Remote = Remote
                });
            });

            if ((Server != null) && (Remote.Socket == Server.Socket))
            {
                Server = null;
            }
        }
Beispiel #4
0
        virtual internal void OnRemoteDisconnected(INetworkNode Remote)
        {
            if (Remote == null)
            {
                return;
            }

            if (RemoteDisconnected != null)
            {
                Task.Run(() =>
                {
                    RemoteDisconnected?.Invoke(this, new InternetConnectionEventArgs
                    {
                        Local  = this,
                        Remote = Remote
                    });
                });
            }

            if (Remotes.Contains(Remote))
            {
                Remotes.Remove(Remote);
            }
        }
Beispiel #5
0
 protected virtual void FireRemoteDisconnected(IPEndPoint remote, bool wasLastConnection = true)
 {
     RemoteDisconnected?.Invoke(remote, wasLastConnection);
 }