FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PythonConsole/PythonConsole/PythonAPI/RemoteFuncManager.cs at master · Strdate/PythonConsole · GitHub
Strdate
/
PythonConsole
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
26
Code
Issues
5
Pull requests
1
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
PythonConsole
/
PythonConsole
/
PythonAPI
/
RemoteFuncManager.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
57 lines (51 loc) · 1.89 KB
Breadcrumbs
PythonConsole
/
PythonConsole
/
PythonAPI
/
RemoteFuncManager.cs
Copy path
File metadata and controls
57 lines (51 loc) · 1.89 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using
SkylinesPythonShared
;
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Linq
;
using
System
.
Reflection
;
using
System
.
Text
;
namespace
PythonConsole
{
public
class
RemoteFuncManager
{
private
TcpClient
client
;
private
delegate
object
CallMethod
(
object
msg
)
;
private
Dictionary
<
string
,
TargetInfo
>
funcDict
=
new
Dictionary
<
string
,
TargetInfo
>
(
)
;
public
RemoteFuncManager
(
TcpClient
client
)
{
this
.
client
=
client
;
foreach
(
var
field
in
typeof
(
Contracts
)
.
GetFields
(
BindingFlags
.
Static
|
BindingFlags
.
Public
)
)
{
Contract
contract
=
(
Contract
)
field
.
GetValue
(
null
)
;
MethodInfo
method
=
typeof
(
GameAPI
)
.
GetMethod
(
contract
.
FuncName
,
BindingFlags
.
Public
|
BindingFlags
.
Static
)
;
CallMethod
del
=
(
CallMethod
)
Delegate
.
CreateDelegate
(
typeof
(
CallMethod
)
,
method
)
;
funcDict
.
Add
(
"c_callfunc_"
+
contract
.
FuncName
,
new
TargetInfo
(
del
,
contract
)
)
;
}
}
public
void
HandleAPICall
(
object
msg
,
string
type
,
long
requestId
)
{
object
retVal
=
null
;
TargetInfo
info
=
funcDict
[
type
]
;
try
{
retVal
=
info
.
method
(
msg
)
;
if
(
info
.
contract
.
RetType
!=
null
)
{
client
.
SendMsg
(
retVal
,
"s_ret_"
+
info
.
contract
.
RetType
,
requestId
)
;
}
}
catch
(
Exception
ex
)
{
client
.
SendMsg
(
ex
.
Message
+
" (source: "
+
info
.
contract
.
FuncName
+
")"
,
"s_exception"
,
requestId
)
;
}
}
private
struct
TargetInfo
{
internal
TargetInfo
(
CallMethod
method
,
Contract
contract
)
{
this
.
method
=
method
;
this
.
contract
=
contract
;
}
internal
CallMethod
method
;
internal
Contract
contract
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL