Skip to content

Commit

Permalink
change process ProcesseListen APi to processName
Browse files Browse the repository at this point in the history
  • Loading branch information
elad.bahar committed Mar 27, 2017
1 parent 486a5c9 commit 56f0c8c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 77 deletions.
10 changes: 5 additions & 5 deletions sampleapp/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ plugin.initialize(function(status) {

});

var processId = 12964;
plugin.get().listenOnProcess(processId, function(status, error) {
console.log("listen process: ", processId, status, error);
var processName = "LeagueClientUx";
plugin.get().listenOnProcess(processName,function(status, data) {
console.log("listen process: ", processName, status, data);
})
// plugin.get().stopListenProcess(processId, function(status, data) {
// plugin.get().stopProcesseListen(processId, function(status, data) {
// console.log("stop listen process: ", processId, status, data);
// })


plugin.get().onOutputDebugString.addListener(function(processId, line) {
plugin.get().onOutputDebugString.addListener(function(processId, processName, line) {
console.log("onOutputDebugString" + processId + ": " + line);
});
});
Binary file modified sampleapp/simple-io-plugin.dll
Binary file not shown.
15 changes: 7 additions & 8 deletions simple-io-plugin/SimpleIOPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public SimpleIOPlugin() {

#region Events
public event Action<object, object, object> onFileListenerChanged;
public event Action<object, object> onOutputDebugString;
public event Action<object, object, object> onOutputDebugString;
#endregion Events

#region IDisposable
Expand Down Expand Up @@ -378,16 +378,16 @@ public void stopFileListen(string id) {
FileListenerManager.stopFileListen(id);
}

public void listenOnProcess(int processId, Action<object, object> callback) {
public void listenOnProcess(string processname, Action<object, object> callback) {
OutputDebugStringManager.Callback = OnOutputDebugString;
Task.Run(() => {
OutputDebugStringManager.ListenOnProcess(processId, callback);
OutputDebugStringManager.ListenOnProcess(processname, callback);
});
}

public void stopProcesseListen(int processId, Action<object, object> callback) {
public void stopProcesseListen(string processname, Action<object, object> callback) {
Task.Run(() => {
OutputDebugStringManager.StopListenOnProcess(processId, callback);
OutputDebugStringManager.StopListenOnProcess(processname, callback);
});
}

Expand All @@ -397,10 +397,9 @@ private void OnFileChanged(object id, object status, object data) {
}
}

private void OnOutputDebugString(int processId, string text) {
private void OnOutputDebugString(int processId,string processName, string text) {
if (onOutputDebugString != null) {
//onOutputDebugString.BeginInvoke(processId, text, null, null);
onOutputDebugString(processId, text);
onOutputDebugString(processId, processName, text);
}
}

Expand Down
61 changes: 0 additions & 61 deletions simple-io-plugin/simple-io-plugin.csproj

This file was deleted.

6 changes: 3 additions & 3 deletions unittest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static void Main(string[] args)
}));

plugn.onOutputDebugString += plugn_onOutputDebugString;
plugn.listenOnProcess(12964, new Action<object, object>((x, y) => {
plugn.listenOnProcess("LeagueClientUx", new Action<object, object>((x, y) => {
}));

Expand Down Expand Up @@ -74,7 +74,7 @@ static void Main(string[] args)
try
{
Trace.WriteLine("left button pressed:" + plugn.isMouseLeftButtonPressed);
plugn.stopProcesseListen(12964, new Action<object, object>((x, y) => {
plugn.stopProcesseListen("LeagueClientUx", new Action<object, object>((x, y) => {
}));
Thread.Sleep(5000);
Expand All @@ -94,7 +94,7 @@ static void Main(string[] args)
Console.ReadLine();
}

static void plugn_onOutputDebugString(object arg1, object arg2) {
static void plugn_onOutputDebugString(object arg1,object name, object arg2) {
Console.WriteLine(string.Format("onOutputDebugString pid:{0} text:{1}", arg1, arg2));
}
static void plugn_OnFileListenerChanged(object id, object status, object data)
Expand Down

0 comments on commit 56f0c8c

Please sign in to comment.