Mercurial > hg > ucis.core
view Xml/Server.cs @ 50:556b4fb511bd
Added HWLib and USBLib functions to support USB Driver Installer
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Mon, 30 Sep 2013 19:23:09 +0200 |
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); } } }