Esempio n. 1
0
        public HttpResponseMessage ReconnectSocket()
        {
            //HttpResponseMessage response;
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);

            try
            {
                if (GlobalVariables.GlobalSocketList.Count > 0)
                {
                    AsynchronousClient.ReconnectClient(GlobalVariables.GlobalSocketList);
                    return(SocketHelper.SocketHelperConnectionStatus());
                }
                else
                {
                    return(SocketHelper.SocketHelperConnectionStatus());
                }
                //int openBefore = GlobalVariables.socketstatus.OpenSockets;
                //int closedBefore = GlobalVariables.socketstatus.ClosedSockets;
                //string statusBefore = "Connected Sockets: " + openBefore + " Disconnected Sockets: " + closedBefore;
                //AsynchronousClient.ReconnectClient(GlobalVariables.GlobalSocketList);
                //int openAfter = GlobalVariables.socketstatus.OpenSockets;
                //int closedAfter = GlobalVariables.socketstatus.ClosedSockets;
                //string statusAfter = "Connected Sockets: " + openAfter + " Disconnected Sockets: " + closedAfter;
                //string statusall = @"{
                //                        ""Status"": ""Reconnecting Sockets!"",
                //                        ""ConnectionStatusBeforeReconnect"": {
                //                            ""Connected"": " + openBefore + @",
                //                            ""Disconnected"": " + closedBefore + @"
                //                        },
                //                        ""ConnectionStatusAfterReconnect"": {
                //                            ""Connected"": " + openAfter + @",
                //                            ""Disconnected"": " + closedAfter + @"
                //                        }
                //                    }";

                //response = Request.CreateResponse(HttpStatusCode.OK, statusall);
            }
            catch (Exception e)
            {
                response = Request.CreateResponse(HttpStatusCode.OK, @"{""Status"": ""Failed to Reconnect Sockets!"", ""ExceptionMessage"": """ + e.Message + @"""}");
                return(response);
            }
            return(response);
        }