-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd8df1b
commit 8bebce3
Showing
5 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
|
||
namespace concurency_workshop.NS_CLIENT | ||
{ | ||
public class CLclient | ||
{ | ||
|
||
private string _name; | ||
public CLclient(NS_SERVER.CLserver server, string name) | ||
{ | ||
_name = name; | ||
|
||
server.MessageReceived += Server_MessageReceived; | ||
} | ||
|
||
private void Server_MessageReceived(object sender, string message) | ||
{ | ||
Console.WriteLine($"{_name} received message: {message}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace concurency_workshop.NS_SERVER | ||
{ | ||
public class CLserver | ||
{ | ||
// Declare a delegate for the event | ||
public delegate void MessageEventHandler(object sender, string message); | ||
|
||
// Declare the event using the delegate | ||
public event MessageEventHandler MessageReceived; | ||
|
||
private string _msg; | ||
public string Msg { | ||
get { return _msg; } | ||
set | ||
{ | ||
_msg = value; | ||
// Trigger the event when the message is set | ||
MessageReceived?.Invoke(this, _msg); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters