-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/AlexBHarley/eeNet
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## eeNet | ||
![Build Status](https://ci.appveyor.com/api/projects/status/github/alexbharley/eeNet?branch=master&svg=true) | ||
|
||
#### Node.js style events in C\# | ||
|
||
```C# | ||
class Client | ||
{ | ||
private EventEmitter _ee; | ||
|
||
public Client() | ||
{ | ||
this._ee = new EventEmitter(); | ||
} | ||
|
||
public void PushDataToServer(string data) | ||
{ | ||
this._ee.On("data_received", LogData); | ||
this._ee.On("data_received", SendToBus); | ||
} | ||
|
||
public void ReceiveData(List<string> dataList) | ||
{ | ||
this._ee.Emit("data_received", dataList); | ||
this._ee.RemoveListener("data_received", LogData); | ||
} | ||
|
||
public void LogData(object data) | ||
{ | ||
//Log and store data | ||
} | ||
|
||
public void SendToBus(object data) | ||
{ | ||
//Send data somewhere interesting | ||
} | ||
} | ||
``` | ||
|
||
|