void ProcessShopEntity(XmlReader reader, IPAddress clientIp) { ShopEntity data = (ShopEntity)Helper.DeserializeXml(typeof(ShopEntity), reader); if (data != null) { data.IpAddress = clientIp.ToString(); int shopId = _command.InsertShop(data); IPEndPoint endPoint = new IPEndPoint(clientIp, data.Port); if (_shopOfClient.ContainsKey(shopId)) { _shopOfClient[shopId] = endPoint; } else { _shopOfClient.Add(shopId, endPoint); object response = _command.ShopEntityResponse(shopId); if (response != null) { NotifyClient(shopId, endPoint, response); } } } }
void ProcessShopInfo(XmlReader reader, IPEndPoint clientEndPoint) { object info = Helper.DeserializeXml(typeof(ShopInfo), reader); if (info != null) { ShopInfo data = (ShopInfo)info; object response = _command.GetShopById(data.Id); if (response != null) { ShopEntity shop = response as ShopEntity; String clientIp = clientEndPoint.Address.ToString(); if (shop.IpAddress != clientIp) { shop.IpAddress = clientIp; _command.UpdateShop(shop); } IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(shop.IpAddress), shop.Port); NotifyClient(shop.Id, endPoint, response); } } }