Exemple #1
0
        public void server_NewMessageReceived(WebSocketSession session, string message)
        {
            //MessageBox.Show ("Message recived from Web", "My Application", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);

            //session.Send(message);
            acWebSocketMessage rawMessage = new acWebSocketMessage(message);

            if (rawMessage.getId() != "")
            {
                // Tutaj jest obsluga odpowiedzi z przegladarki - wyslane z AC
                if (rawMessage.getRequestID() != "" && rawMessage.getRequestID() != null)
                {
                    // requestID!=null -> answer for AC request, ???
                    //MessageBox.Show ("Komunikat powrotny z przegladarki po wyslaniu komunikatu z AC", "My Application", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);

                    syncControl.messages[rawMessage.getRequestID()].setAnswer(rawMessage);
                }
                // Tutaj jest obsluga gdy wysylamy komunikat z przegladarki do AC
                else
                {
                    //MessageBox.Show ("Komunikat pierwotny z przegladarki do AC", "My Application", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                    // Zapytanie  przychodzi z przegladarki
                    //requestID==null -> request from browser, call method, wait for return and send result
                    syncControl.Invoke(receiveRequestDelegate, rawMessage);
                    //session.Send("{\"method\" : \"mth\", \"id\" : \"000\", \"requestID\" : \""+ rawMessage.getId() +"\" , \"data\" : \"Data from server\"}");
                }
            }
            else if (rawMessage.getStatus() == "error")
            {
                MessageBox.Show("NewMessegeReceived 5", "My Application", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                // wrong message
            }
        }
Exemple #2
0
        public acWebSocketMessage sendMessageAndWaitSync(acWebSocketMessage message)
        {
            Editor ed = acApp.DocumentManager.MdiActiveDocument.Editor;

            // send message to webapp
            server.sendMessage(message);

            // add id to request array
            addMessage(message.getId());
            // wainting for answer
            while (messages[message.getId()].answer == null)
            {
            }
#if DEBUG
            ed.WriteMessage("\nAnswer from Web: " + messages[message.getId()].answer.toJSON().ToString());
#else
            ed.WriteMessage("\nData sent sucessfully");
#endif
            try
            {
                acWebSocketMessage answer = messages[message.getId()].answer;
                removeMessage(message.getId());
                return(answer);
            }
            catch (System.Exception e)
            {
                ed.WriteMessage("\nWizFDS exception:" + e.ToString());
                removeMessage(message.getId());
                return(null);
            }
        }
Exemple #3
0
        public void receiveAnswer(acWebSocketMessage message)
        {
            Editor ed = acApp.DocumentManager.MdiActiveDocument.Editor;

            ed.WriteMessage("Answer received. Calling method in current thread ..." + message.getId() + " - id\n");

            // receive message with requestId!=null
            // and send result to waiting thread
        }
Exemple #4
0
        public acWebSocketMessage callMethod(acWebSocketMessage message)
        {
            String          method    = message.getMethod();
            String          status    = "";
            dynamic         data      = new System.Dynamic.ExpandoObject();
            isCreatedObject isCreated = new isCreatedObject();

            //string jsonF = JsonConvert.SerializeObject(message.getData(), Formatting.Indented);
            //ed.WriteMessage(jsonF);


            if (method != "" && method != null)
            {
                switch (method)
                {
                // Implemented functions in Web app
                case "syncAllWeb":
                    ImportFds.SyncAllWeb(message.getData());
                    break;

                case "createLibraryLayersWeb":
                    if (ImportFds.CreateLibraryLayersWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "getCadGeometryWeb":
                    acWebSocketMessage answer = ImportFds.GetCadElementsWeb(message.getData());
                    if (answer.getStatus() == "success")
                    {
                        status = answer.getStatus();
                        data   = answer.getData();
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "selectObjectWeb":
                    if (ImportFds.SelectObjectWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                // Creating layers from web app
                case "createObstSurfWeb":
                    isCreated = ImportFds.CreateObstSurfWeb(message.getData());
                    if (isCreated.isCreated)
                    {
                        status = "success";
                        data   = isCreated.acObj;
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "createVentSurfWeb":
                    isCreated = ImportFds.CreateVentSurfWeb(message.getData());
                    if (isCreated.isCreated)
                    {
                        status = "success";
                        data   = isCreated.acObj;
                    }
                    else
                    {
                        status = "error";
                    }
                    status = "success";
                    break;

                case "createJetfanSurfWeb":
                    isCreated = ImportFds.CreateJetfanSurfWeb(message.getData());
                    if (isCreated.isCreated)
                    {
                        status = "success";
                        data   = isCreated.acObj;
                    }
                    else
                    {
                        status = "error";
                    }
                    status = "success";
                    break;

                case "createSpecSurfWeb":
                    isCreated = ImportFds.CreateSpecSurfWeb(message.getData());
                    if (isCreated.isCreated)
                    {
                        status = "success";
                        data   = isCreated.acObj;
                    }
                    else
                    {
                        status = "error";
                    }
                    status = "success";
                    break;

                case "createFireSurfWeb":
                    isCreated = ImportFds.CreateFireSurfWeb(message.getData());
                    if (isCreated.isCreated)
                    {
                        status = "success";
                        data   = isCreated.acObj;
                    }
                    else
                    {
                        status = "error";
                    }
                    status = "success";
                    break;

                case "createSlcfSurfWeb":
                    isCreated = ImportFds.CreateSlcfSurfWeb(message.getData());
                    if (isCreated.isCreated)
                    {
                        status = "success";
                        data   = isCreated.acObj;
                    }
                    else
                    {
                        status = "error";
                    }
                    status = "success";
                    break;

                case "createDevcSurfWeb":
                    isCreated = ImportFds.CreateDevcSurfWeb(message.getData());
                    if (isCreated.isCreated)
                    {
                        status = "success";
                        data   = isCreated.acObj;
                    }
                    else
                    {
                        status = "error";
                    }
                    status = "success";
                    break;

                // Other functions which are implemented but not used

                // GENERAL FUNTIONS
                case "syncPartWeb":     // Not ready
                    break;

                case "syncLayersWeb":
                    ImportFds.SyncLayersWeb(message.getData());
                    break;

                // MESH & OPEN
                case "createMeshWeb":
                    isCreated = ImportFds.CreateMeshWeb(message.getData());
                    if (isCreated.isCreated)
                    {
                        status = "success";
                        data   = isCreated.acObj;
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "updateMeshWeb":
                    if (ImportFds.UpdateMeshWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "deleteMeshWeb":
                    if (ImportFds.DeleteMeshWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                // TODO OPEN!!!

                // SURFACE
                case "updateObstSurfWeb":
                    if (ImportFds.UpdateObstSurfWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "deleteObstSurfWeb":
                    if (ImportFds.DeleteObstSurfWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                // OBSTRUCTION & HOLE
                case "createObstWeb":     // OK
                    isCreated = ImportFds.CreateObstWeb(message.getData());
                    if (isCreated.isCreated)
                    {
                        status = "success";
                        data   = isCreated.acObj;
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "updateObstWeb":     // OK
                    isCreated = ImportFds.UpdateObstWeb(message.getData());
                    if (isCreated.isCreated)
                    {
                        status = "success";
                        data   = isCreated.acObj;
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "deleteObstWeb":
                    if (ImportFds.DeleteObstWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "createHoleWeb":     // OK
                    isCreated = ImportFds.CreateHoleWeb(message.getData());
                    if (isCreated.isCreated)
                    {
                        status = "success";
                        data   = isCreated.acObj;
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "updateHoleWeb":     // OK
                    if (ImportFds.UpdateHoleWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "deleteHoleWeb":
                    if (ImportFds.DeleteHoleWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                // TODO: Changing obst surface ??

                // VENTILATION & JETFAN
                case "deleteVentSurfWeb":     // OK
                    if (ImportFds.DeleteVentSurfWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    status = "success";
                    break;

                case "updateVentSurfWeb":     // OK
                    //if (webToAc.UpdateSurfWeb(message.getData())) status = "success";
                    //else status = "error";
                    status = "success";
                    break;

                case "createVentWeb":
                    isCreated = ImportFds.CreateVentWeb(message.getData());
                    if (isCreated.isCreated)
                    {
                        status = "success";
                        data   = isCreated.acObj;
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "updateVentWeb":
                    if (ImportFds.UpdateVentWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "deleteVentWeb":
                    if (ImportFds.DeleteVentWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                // OUTPUT
                case "createDevcWeb":
                    isCreated = ImportFds.CreateDevcWeb(message.getData());
                    if (isCreated.isCreated)
                    {
                        status = "success";
                        data   = isCreated.acObj;
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "updateDevcWeb":
                    if (ImportFds.UpdateDevcWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "deleteDevcWeb":
                    if (ImportFds.DeleteDevcWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "createSlcfWeb":
                    isCreated = ImportFds.CreateSlcfWeb(message.getData());
                    if (isCreated.isCreated)
                    {
                        status = "success";
                        data   = isCreated.acObj;
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "updateSlcfWeb":
                    if (ImportFds.UpdateSlcfWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;

                case "deleteSlcfWeb":
                    if (ImportFds.DeleteSlcfWeb(message.getData()))
                    {
                        status = "success";
                    }
                    else
                    {
                        status = "error";
                    }
                    break;


                default:
                    status = "error - method not found";
                    break;
                }
            }

            acWebSocketMessage result = new acWebSocketMessage(status, message.getMethod(), data, message.getId());

            return(result);
        }
Exemple #5
0
        static void CallMessageHandler(acWebSocketMessage message)
        {
            Editor ed = acApp.DocumentManager.MdiActiveDocument.Editor;

            ed.WriteMessage("Message received. Method: " + message.getMethod() + " id: " + message.getId() + "\n");
            ed.WriteMessage("Sync:" + acWebSocketServer.syncControl.syncValue);
            if (message.getMethod() == "start")
            {
                acWebSocketServer.syncControl.syncValue = "start";
                System.Threading.Thread thread = new System.Threading.Thread(
                    new System.Threading.ThreadStart(BackgroundProcess)
                    );

                thread.Start();
            }
            else if (message.getMethod() == "stop")
            {
                acWebSocketServer.syncControl.syncValue = "stop";
            }
        }