fb20d6171cc6da895f2f1a9fbb7254f6e0e14616
[ldk-java] / c_sharp / src / org / ldk / structs / Ping.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A ping message to be sent or received from a peer
11  */
12 public class Ping : CommonBase {
13         internal Ping(object _dummy, long ptr) : base(ptr) { }
14         ~Ping() {
15                 if (ptr != 0) { bindings.Ping_free(ptr); }
16         }
17
18         /**
19          * The desired response length
20          */
21         public short get_ponglen() {
22                 short ret = bindings.Ping_get_ponglen(this.ptr);
23                 GC.KeepAlive(this);
24                 return ret;
25         }
26
27         /**
28          * The desired response length
29          */
30         public void set_ponglen(short val) {
31                 bindings.Ping_set_ponglen(this.ptr, val);
32                 GC.KeepAlive(this);
33                 GC.KeepAlive(val);
34         }
35
36         /**
37          * The ping packet size.
38          * This field is not sent on the wire. byteslen zeros are sent.
39          */
40         public short get_byteslen() {
41                 short ret = bindings.Ping_get_byteslen(this.ptr);
42                 GC.KeepAlive(this);
43                 return ret;
44         }
45
46         /**
47          * The ping packet size.
48          * This field is not sent on the wire. byteslen zeros are sent.
49          */
50         public void set_byteslen(short val) {
51                 bindings.Ping_set_byteslen(this.ptr, val);
52                 GC.KeepAlive(this);
53                 GC.KeepAlive(val);
54         }
55
56         /**
57          * Constructs a new Ping given each field
58          */
59         public static Ping of(short ponglen_arg, short byteslen_arg) {
60                 long ret = bindings.Ping_new(ponglen_arg, byteslen_arg);
61                 GC.KeepAlive(ponglen_arg);
62                 GC.KeepAlive(byteslen_arg);
63                 if (ret >= 0 && ret <= 4096) { return null; }
64                 org.ldk.structs.Ping ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Ping(null, ret); }
65                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
66                 return ret_hu_conv;
67         }
68
69         internal long clone_ptr() {
70                 long ret = bindings.Ping_clone_ptr(this.ptr);
71                 GC.KeepAlive(this);
72                 return ret;
73         }
74
75         /**
76          * Creates a copy of the Ping
77          */
78         public Ping clone() {
79                 long ret = bindings.Ping_clone(this.ptr);
80                 GC.KeepAlive(this);
81                 if (ret >= 0 && ret <= 4096) { return null; }
82                 org.ldk.structs.Ping ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Ping(null, ret); }
83                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
84                 return ret_hu_conv;
85         }
86
87         /**
88          * Checks if two Pings contain equal inner contents.
89          * This ignores pointers and is_owned flags and looks at the values in fields.
90          * Two objects with NULL inner values will be considered "equal" here.
91          */
92         public bool eq(org.ldk.structs.Ping b) {
93                 bool ret = bindings.Ping_eq(this.ptr, b == null ? 0 : b.ptr);
94                 GC.KeepAlive(this);
95                 GC.KeepAlive(b);
96                 if (this != null) { this.ptrs_to.AddLast(b); };
97                 return ret;
98         }
99
100         public override bool Equals(object o) {
101                 if (!(o is Ping)) return false;
102                 return this.eq((Ping)o);
103         }
104         /**
105          * Serialize the Ping object into a byte array which can be read by Ping_read
106          */
107         public byte[] write() {
108                 byte[] ret = bindings.Ping_write(this.ptr);
109                 GC.KeepAlive(this);
110                 return ret;
111         }
112
113         /**
114          * Read a Ping from a byte array, created by Ping_write
115          */
116         public static Result_PingDecodeErrorZ read(byte[] ser) {
117                 long ret = bindings.Ping_read(ser);
118                 GC.KeepAlive(ser);
119                 if (ret >= 0 && ret <= 4096) { return null; }
120                 Result_PingDecodeErrorZ ret_hu_conv = Result_PingDecodeErrorZ.constr_from_ptr(ret);
121                 return ret_hu_conv;
122         }
123
124 }
125 } } }