1
+ using System ;
2
+ using System . IO ;
3
+
4
+ using Antmicro . Renode . Utilities ;
5
+
6
+ namespace Antmicro . Renode . WebSockets
7
+ {
8
+ public class WebSocketAPIBaseAttribute : Attribute
9
+ {
10
+ public WebSocketAPIBaseAttribute ( string name , string version )
11
+ {
12
+ Name = name ;
13
+ Version = new Version ( version ) ;
14
+ }
15
+
16
+ public string Name ;
17
+ public Version Version ;
18
+ }
19
+
20
+ public class WebSocketAPIActionAttribute : WebSocketAPIBaseAttribute
21
+ {
22
+ public WebSocketAPIActionAttribute ( string action , string version ) : base ( action , version )
23
+ {
24
+ }
25
+ }
26
+
27
+ public class WebSocketAPIEventAttribute : WebSocketAPIBaseAttribute
28
+ {
29
+ public WebSocketAPIEventAttribute ( string eventName , string version ) : base ( eventName , version )
30
+ {
31
+ }
32
+ }
33
+
34
+ public enum WebSocketAPIResponseStatus
35
+ {
36
+ SUCCESS ,
37
+ FAIL
38
+ }
39
+
40
+ public class WebSocketAPIResponse
41
+ {
42
+ public object data ;
43
+ public string error ;
44
+ }
45
+
46
+ public interface IWebSocketAPIProvider : IAutoLoadType
47
+ {
48
+
49
+ }
50
+
51
+ public delegate void WebSocketAPIEventHandler ( object eventData ) ;
52
+
53
+ public static class WebSocketAPIUtils
54
+ {
55
+ public static WebSocketAPIResponse CreateActionResponse ( object response , string errorMessage = null )
56
+ {
57
+ return new WebSocketAPIResponse
58
+ {
59
+ data = response ,
60
+ error = errorMessage
61
+ } ;
62
+ }
63
+
64
+ public static WebSocketAPIResponse CreateEmptyActionResponse ( string errorMessage = null )
65
+ {
66
+ return new WebSocketAPIResponse
67
+ {
68
+ data = new object ( ) ,
69
+ error = errorMessage
70
+ } ;
71
+ }
72
+
73
+ public static void RaiseEvent ( this WebSocketAPIEventHandler webSocketEvent , object data )
74
+ {
75
+ webSocketEvent . Invoke ( data ) ;
76
+ }
77
+
78
+ public static void RaiseEventWithoutBody ( this WebSocketAPIEventHandler webSocketEvent )
79
+ {
80
+ webSocketEvent . Invoke ( new object ( ) ) ;
81
+ }
82
+ }
83
+
84
+ public class WebSocketAPISharedData
85
+ {
86
+ public void SetDefaults ( )
87
+ {
88
+ cwd = Path . Combine ( Environment . CurrentDirectory , "working-dir" ) ;
89
+ }
90
+
91
+ public string cwd ;
92
+ }
93
+ }
0 commit comments