public override void Deserialize(IoBuffer input, ISerializationContext context) { MaxLots = input.GetInt16(); CurrentLots = input.GetInt16(); CpuPercentAvg = input.Get(); RamUsed = input.GetInt64(); RamAvaliable = input.GetInt64(); }
public override void Deserialize(IoBuffer input, ISerializationContext context) { Type = input.GetEnum <MailRequestType>(); if (Type == MailRequestType.SEND) { var length = input.GetInt32(); var dat = new byte[length]; for (int i = 0; i < length; i++) { dat[i] = input.Get(); } using (var str = new MemoryStream(dat)) { Item = new MessageItem(str); } } else { TimestampID = input.GetInt64(); } }
public static ulong GetUInt64(this IoBuffer buffer) { return((ulong)buffer.GetInt64()); }
static void Main(string[] args) { AsyncDatagramAcceptor acceptor = new AsyncDatagramAcceptor(); acceptor.FilterChain.AddLast("logger", new LoggingFilter()); acceptor.SessionConfig.ReuseAddress = true; acceptor.ExceptionCaught += (s, e) => { Console.WriteLine(e.Exception); e.Session.Close(true); }; acceptor.MessageReceived += (s, e) => { IoBuffer buf = e.Message as IoBuffer; if (buf != null) { Console.WriteLine("New value for {0}: {1}", e.Session.RemoteEndPoint, buf.GetInt64()); } }; acceptor.SessionCreated += (s, e) => { Console.WriteLine("Session created..."); }; acceptor.SessionOpened += (s, e) => { Console.WriteLine("Session opened..."); }; acceptor.SessionClosed += (s, e) => { Console.WriteLine("Session closed..."); }; acceptor.SessionIdle += (s, e) => { Console.WriteLine("Session idle..."); }; acceptor.Bind(new IPEndPoint(IPAddress.Any, port)); Console.WriteLine("UDPServer listening on port " + port); Console.ReadLine(); }