Ejemplo n.º 1
0
        private LogHeader ParseCatanMessage(CatanMessage message)
        {
            Type type = Type.GetType(message.TypeName);

            if (type == null)
            {
                throw new ArgumentException("Unknown type!");
            }
            return(JsonSerializer.Deserialize(message.Data.ToString(), type, GetJsonOptions()) as LogHeader);
        }
Ejemplo n.º 2
0
        public async Task <CatanMessage> PostLogMessage <T>(string sessionName, LogHeader logHeader)
        {
            if (String.IsNullOrEmpty(sessionName))
            {
                throw new ArgumentException("names can't be null or empty");
            }
            if (logHeader == null)
            {
                throw new ArgumentException("LogHeader cannot be null");
            }

            string       url     = $"{HostName}/api/catan/session/message/{sessionName}";
            CatanMessage message = new CatanMessage()
            {
                TypeName = logHeader.GetType().FullName,
                Data     = logHeader as object
            };

            CatanMessage returnedMessage = await Post <CatanMessage>(url, CatanProxy.Serialize(message));

            returnedMessage.Data = ParseCatanMessage(returnedMessage);
            return(returnedMessage);
        }