Example #1
0
    public object SendPackage(IPackage package)
    {
        if (!package.IsValid)
        {
            return(null);
        }

        SendingPackage?.Invoke(this, new PackageEventArgs(package));
        if (!package.IsValid)
        {
            return(null);
        }
        if (package.Sender != this)
        {
            package.Sender.SendPackage(package);
            return(null);
        }

        return(package.Receiver.ReceivePackage(package));
    }
Example #2
0
    public T SendPackage <T>(Package <T> package)
    {
        if (!package.IsValid)
        {
            return(default(T));
        }

        SendingPackage?.Invoke(this, new PackageEventArgs(package));
        if (!package.IsValid)
        {
            return(default(T));
        }
        if (package.Sender != this)
        {
            package.Sender.SendPackage(package);
            return(default(T));
        }

        return(package.Receiver.ReceivePackage(package));
    }