protected virtual void HandleInterfaceOnConnectonApproved(
     [NotNull] INetworkLayerInterface sender,
     [NotNull] ConnectionEventArgs connectionEventArgs
     )
 {
     Log.Info($"Connection approved [{connectionEventArgs.Connection?.Guid}].");
     OnConnectionApproved?.Invoke(sender, connectionEventArgs);
 }
 protected virtual void HandleInterfaceOnDisconnected(
     [NotNull] INetworkLayerInterface sender,
     [NotNull] ConnectionEventArgs connectionEventArgs
     )
 {
     Log.Info($"Disconnected [{connectionEventArgs.Connection?.Guid}].");
     Client.RemoveBeta4Client(connectionEventArgs.Connection);
     OnDisconnected?.Invoke(sender, connectionEventArgs);
 }
        protected virtual bool HandleConnectionRequested(INetworkLayerInterface sender, IConnection connection)
        {
            if (string.IsNullOrEmpty(connection?.Ip))
            {
                return(false);
            }

            return(true);
        }
 protected virtual void HandleInterfaceOnConnected(
     INetworkLayerInterface sender,
     ConnectionEventArgs connectionEventArgs
     )
 {
     Log.Info($"Connected [{connectionEventArgs.Connection?.Guid}].");
     Client.CreateBeta4Client(Context, connectionEventArgs.Connection);
     OnConnected?.Invoke(sender, connectionEventArgs);
 }
        protected virtual bool HandleConnectionRequested(INetworkLayerInterface sender, IConnection connection)
        {
            if (string.IsNullOrEmpty(connection?.Ip))
            {
                return(false);
            }

            return(string.IsNullOrEmpty(Database.PlayerData.Ban.CheckBan(connection.Ip.Trim())) &&
                   Options.Instance.SecurityOpts.CheckIp(connection.Ip.Trim()));
        }
        protected void AddNetworkLayerInterface(INetworkLayerInterface networkLayerInterface)
        {
            if (mNetworkLayerInterfaces == null)
            {
                throw new ArgumentNullException(nameof(mNetworkLayerInterfaces));
            }

            if (networkLayerInterface == null)
            {
                throw new ArgumentNullException(nameof(networkLayerInterface));
            }

            networkLayerInterface.OnPacketAvailable += HandleInboundMessageAvailable;
            mNetworkLayerInterfaces.Add(networkLayerInterface);
        }
        private bool FireHandler(
            HandleConnectionEvent handler,
            string name,
            [NotNull] INetworkLayerInterface sender,
            [NotNull] ConnectionEventArgs connectionEventArgs
            )
        {
            handler?.Invoke(sender, connectionEventArgs);

            if (handler == null)
            {
                Log.Error($"No handlers for '{name}'.");
            }

            return(handler != null);
        }
        private void HandleInboundMessageAvailable(INetworkLayerInterface sender)
        {
            if (sender == null)
            {
                throw new ArgumentNullException(nameof(sender));
            }

            if (!sender.TryGetInboundBuffer(out var buffer, out var connection))
            {
                Log.Error("Failed to obtain packet when told a packet was available.");

                return;
            }

            HandleInboundData(buffer, connection);

            sender.ReleaseInboundBuffer(buffer);
        }
 public static void HandleDc(INetworkLayerInterface sender, ConnectionEventArgs connectionEventArgs)
 {
     DestroyNetwork();
     if (Globals.MainForm != null && Globals.MainForm.Visible)
     {
         if (Globals.MainForm.DisconnectDelegate != null)
         {
             Globals.MainForm.BeginInvoke(Globals.MainForm.DisconnectDelegate);
             Globals.MainForm.DisconnectDelegate = null;
         }
     }
     else if (Globals.LoginForm.Visible)
     {
         Connecting = false;
         InitNetwork();
     }
     else
     {
         MessageBox.Show(@"Disconnected!");
         Application.Exit();
     }
 }
 protected virtual void HandleInterfaceOnDisconnected(INetworkLayerInterface sender, ConnectionEventArgs connectionEventArgs)
 {
     Log.Info($"Disconnected [{connectionEventArgs.Connection?.Guid ?? Guid.Empty}].");
     IsConnected = false;
     OnDisconnected?.Invoke(sender, connectionEventArgs);
 }
 protected virtual void HandleInterfaceOnConnectonDenied(INetworkLayerInterface sender, ConnectionEventArgs connectionEventArgs)
 {
     Log.Info($"Connection denied [{connectionEventArgs.Connection?.Guid}].");
     OnConnectionDenied?.Invoke(sender, connectionEventArgs);
 }
 protected virtual void HandleInterfaceOnConnectonApproved(INetworkLayerInterface sender, IConnection connection)
 {
     Log.Info($"Connection approved [{connection?.Guid}].");
     OnConnectionApproved?.Invoke(sender, connection);
 }
 protected virtual void HandleInterfaceOnConnected(INetworkLayerInterface sender, IConnection connection)
 {
     Log.Info($"Connected [{connection?.Guid}].");
     new IntersectNetworkSocket(connection).CreateClient();
     OnConnected?.Invoke(sender, connection);
 }
Example #14
0
 protected void OnDisconnected([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs)
 {
     Disconnected?.Invoke(sender, connectionEventArgs);
 }
Example #15
0
 protected void OnConnectionFailed([NotNull] INetworkLayerInterface sender, [NotNull] ConnectionEventArgs connectionEventArgs, bool denied)
 {
     ConnectionFailed?.Invoke(sender, connectionEventArgs, denied);
 }
 protected virtual void HandleInterfaceOnDisconnected(INetworkLayerInterface sender, IConnection connection)
 {
     Log.Info($"Disconnected [{connection?.Guid}].");
     Client.RemoveBeta4Client(connection);
     OnDisconnected?.Invoke(sender, connection);
 }
 protected virtual void HandleInterfaceOnDisconnected(INetworkLayerInterface sender, IConnection connection)
 {
     Log.Info($"Disconnected [{connection?.Guid}].");
     ((Client)connection.UserData).Disconnect();
     OnDisconnected?.Invoke(sender, connection);
 }
 protected void OnConnected(INetworkLayerInterface sender, ConnectionEventArgs connectionEventArgs)
 {
     Connected?.Invoke(sender, connectionEventArgs);
 }