Mercurial > hg > ucis.core
view Xml/Server.cs @ 9:9533a87363f3
Fixed deadlock in QueuedPacketStream
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Fri, 18 Jan 2013 16:29:50 +0100 |
parents | 3ab940a0c7a0 |
children |
line wrap: on
line source
???using System; using System.Collections.Generic; using System.Xml; using UCIS.Net; namespace UCIS.Xml { public class XmlServer : TCPServer.IModule { public Dictionary<string, IModule> Modules = new Dictionary<string, IModule>(StringComparer.OrdinalIgnoreCase); public bool Accept(TCPStream Stream) { XmlSocket XSocket = new XmlSocket(Stream); Stream.ReadTimeout = 5000; XmlDocument FirstMessage = XSocket.ReadDocument(); if (FirstMessage == null) return true; IModule module; if (Modules.TryGetValue(FirstMessage.FirstChild.Name, out module)) { module.Accept(XSocket, FirstMessage); } else { Console.WriteLine("XMLServer.Accept: Module not found: " + FirstMessage.FirstChild.Name); } return true; } public interface IModule { void Accept(XmlSocket Socket, XmlDocument FirstMessage); } } }