Lua in c#

Please post here if you have problems in using Wing FTP Server.
Post Reply
Curtis Newton
Posts: 7
Joined: Mon Aug 15, 2011 6:55 pm

Lua in c#

Post by Curtis Newton »

Hi,

I try to convert the example from http://www.wftpserver.com/help/ftpserve ... nguage.htm" rel="nofollow" rel="nofollow" rel="nofollow into c# with no success:

Code: Select all

public void get_onlinedomains()
		{
			string strURL = "http://127.0.0.1:5466/admin_webservice.html";
			string strUrlParam = "?admin=administrator&pass=secretphrase&cmd=";
			String strLuaScript = "local nSessionCnt = 0 " +
							  "for _,domain in pairs(c_GetDomainList()) do " +
							  " nSessionCnt = nSessionCnt + c_GetSessionCount(domain) " +
							  "end " +
							  "print(nSessionCnt)";

			string strLuaScriptDec = System.Web.HttpUtility.UrlEncode(strLuaScript);

			
			WebRequest myWebRequest = WebRequest.Create(strURL+strUrlParam+strLuaScriptDec);  

            WebResponse myWebResponse = myWebRequest.GetResponse();  

            myWebResponse.Close();
		}
I do not see any result. What am I missing?


C.
Curtis Newton
Posts: 7
Joined: Mon Aug 15, 2011 6:55 pm

Re: Lua in c#

Post by Curtis Newton »

Code: Select all

public void get_onlinedomains()
		{
			string strURL = "http://127.0.0.1:5466/admin_webservice.html";
			string strUrlParam = "?admin=administrator&pass=secrepphrase&cmd=";
			String strLuaScript = "local nSessionCnt = 0 " +
							  "for _,domain in pairs(c_GetDomainList()) do " +
							  " nSessionCnt = nSessionCnt + c_GetSessionCount(domain) " +
							  "end " +
							  "print(nSessionCnt)";

			string strLuaScriptDec = Uri.EscapeDataString(strLuaScript);
		
			WebRequest myWebRequest = WebRequest.Create(strURL+strUrlParam+strLuaScriptDec);  

            WebResponse myWebResponse = myWebRequest.GetResponse();

			Stream dataStream = myWebResponse.GetResponseStream();

			StreamReader reader = new StreamReader(dataStream);

			string responseFromServer = reader.ReadToEnd();

			reader.Close();
			dataStream.Close();
            myWebResponse.Close();
		}
did it!
Post Reply