Example #1
0
        public void Disconnect()
        {
            if (protocol != null)
            {
                DoLogOut();

                protocol.MessageReceived -= HandleMessage;
                protocol.StreamError -= OnStreamError;
                protocol.StopProcessing();

                protocol.Dispose();
                protocol = null;
            }
        }
Example #2
0
        public void Connect(Stream source)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (protocol != null)
            {
                log.Warn("A second connection is being established.  Disconnecting first...");
                Disconnect();
            }

            protocol = new Network(source);
            protocol.MessageReceived += HandleMessage;
            protocol.StreamError += OnStreamError;

            protocol.StartProcessing();
        }