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

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

        IReport report = package.Unwrap();

        ReceivedPackage?.Invoke(this, new ReportEventArgs(report));
        report.Sender.SentPackage?.Invoke(report.Sender, new ReportEventArgs(report));

        return(report.Content);
    }
Example #2
0
    private T ReceivePackage <T>(Package <T> package)
    {
        if (!package.IsValid)
        {
            return(default(T));
        }

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

        Report <T> report = package.Unwrap();

        ReceivedPackage?.Invoke(this, new ReportEventArgs(report));
        report.Sender.SentPackage?.Invoke(report.Sender, new ReportEventArgs(report));

        return(report.Content);
    }
Example #3
0
        public void ReceivePackage(CommandPackage package)
        {
            switch (package.command)
            {
            case ServerCommands.BROADCAST:
                ReceivedPackage?.Invoke(this, package);
//					PrintUtils.PrintNormal(Encoding.ASCII.GetString(package.data, 0, package.data.Length));
                break;

            case ServerCommands.MESSAGE:
                ReceivedPackage?.Invoke(this, package);
//					PrintUtils.PrintNormal(Encoding.ASCII.GetString(package.data, 0, package.data.Length));
                break;
            }
        }
Example #4
0
 public void ReceivePackage(CommandPackage package)
 {
     ReceivedPackage?.Invoke(this, package);
 }