Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peers now transmit their role before sending file #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

BrunoFreitasgit
Copy link

Fix #12 by transmitting roles before file transfer.

Program.cs Outdated
@@ -9,6 +9,9 @@ namespace p2pcopy
{
class Program
{
public static string ReceiverRole = "receiver";
public static string SenderRole = "sender";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's rather use an enum? and then use .ToString()

Program.cs Outdated
static int SleepTime(DateTime now)
{
List<int> seconds = new List<int>() {10, 20, 30, 40, 50, 60};
List<int> seconds = new List<int>() { 10, 20, 30, 40, 50, 60 };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's try to remove hunks that are unrelated

if (role == myRole.ToString())
{
Console.Error.WriteLine("Peers can't have the same role.");
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you exit the function like this, this won't translate into a non-zero exitcode for the program

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you suggest instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call directly Environment.Exit? I know it doesn't seem very clean, but it would be more correct.

@knocte
Copy link
Contributor

knocte commented Feb 9, 2021

@psantosl can you review/merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should not crash if both peers by mistake have the same role (sender or receiver) at the same time
2 participants