Mercurial > hg > ucis.core
view Pml/Channels/TCPPmlChannel.cs @ 81:3352f89cf6f5
FBGUI ContainerControl fixes (client area, keyboard capture)
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Sun, 23 Feb 2014 16:56:42 +0100 |
parents | 3ab940a0c7a0 |
children | 8fe322656807 |
line wrap: on
line source
???using System; using System.IO; using System.Net.Sockets; using UCIS.Net; namespace UCIS.Pml { public class TCPPmlChannel : PassivePmlChannel { private TCPStream _socket; private IPmlRW _rw; private bool _open = false; public TCPPmlChannel(Socket socket) : this(new TCPStream(socket)) { } public TCPPmlChannel(TCPStream socket) { if (socket == null) throw new ArgumentNullException("socket"); _socket = socket; _rw = new PmlBinaryRW(_socket); _open = true; //ThreadPool.RunTask(worker, null); } public override void WriteMessage(PmlElement message) { if (!_open) throw new InvalidOperationException("The channel is not open"); lock (_rw) _rw.WriteMessage(message); } public override void Close() { if (!_open) return; _open = false; if (_socket != null) try { _socket.Close(); } catch { } base.Close(); } public override PmlElement ReadMessage() { return _rw.ReadMessage(); } /*private void worker(Object state) { try { while (_open) { base.PushReceivedMessage(_rw.ReadMessage()); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { Close(); } }*/ } }