public static int ReceiveMessage(string message) { BaseEvent be = new BlowingEvent(); m_message = new UDPMessage(); m_message = (UDPMessage) new SerializeTools().RestoreFromString(message, typeof (UDPMessage)); be = m_message.RestoreEventClass(BaseEvent.GetEvents()); InstantLogger.log(message, "", InstantLogger.TypeMessage.normal); InstantLogger.log(be.ToString(), "", InstantLogger.TypeMessage.normal); return 0; }
public static void SendMessage(BaseEvent classEvent) { m_message = new UDPMessage(); m_message.PackEventClass(classEvent); DataContractJsonSerializer JSONSerializer = new DataContractJsonSerializer(typeof (UDPMessage)); MemoryStream stream = new MemoryStream(); JSONSerializer.WriteObject(stream, m_message); stream.Position = 0; m_udpSrv.Send(new StreamReader(stream).ReadToEnd()); }