Page 1 of 1

Lua in c#

Posted: Wed Sep 07, 2011 6:43 am
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.

Re: Lua in c#

Posted: Wed Sep 07, 2011 7:10 am
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!