Exemplo n.º 1
0
        //private Dictionary<string, Func<bool>> funcDictionary = new Dictionary<string, Func<bool>>();
        //private List<FailureDefinitionId> failureDefinitionIdList = null;


        void WaitForConnections(ClientHandler c, ExternalEvent evt)
        {
            try
            {
                var         doc       = thisUIapp.ActiveUIDocument.Document;
                Int32       port      = 11001;
                IPAddress   localAddr = IPAddress.Parse("127.0.0.1");
                TcpListener server    = new TcpListener(localAddr, port);
                server.Start();
                //WriteMessage("Waiting for connections\n");
                while (true)
                {
                    RevitProcessor processor =
                        new RevitProcessor(
                            doc,
                            new Channel(doc, server.AcceptTcpClient().GetStream()),
                            new Primitives(thisUIapp))
                    ;
                    Thread thread = new Thread(() => HandleClient(c, evt, processor));
                    thread.Start();
                    //WriteMessage("Connection established\n");
                }
            } catch (Exception e) {
                WriteMessage(e.ToString() + "\n");
            }
        }
Exemplo n.º 2
0
 void HandleClient(ClientHandler c, ExternalEvent evt, RevitProcessor processor)
 {
     c.processor = processor;
     try {
         while (true)
         {
             c.op = processor.ReadOperation();
             c.resumeEvt.Reset();
             evt.Raise();
             c.resumeEvt.WaitOne();
             if (!c.result)
             {
                 break;
             }
         }
         WriteMessage("Client disconnected\n");
     } catch (IOException e) {
         WriteMessage(e.ToString() + "\n");
         WriteMessage("Disconneting from client\n");
     } catch (Exception e) {
         WriteMessage(e.ToString() + "\n");
         WriteMessage("Terminating client\n");
     }
 }