PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

ShellExecute

Hello.. long time no see.. i need some help again.. i want people to be able to submit their high score online to my website and i need to know can edge (or C++) pass the player's name and score without opening any browser?

I tried calling ShellExecute() but i don't really know how to use the parameters. can i have some sample code?

thanks in advance..
Hi,

You can use the http class to submit your highscores, it won't be necessary to use ShellExecute.

For example:
//Call this once, for example on ClassMain::OnInit()
ecd.net[0]->Init(ECONN_SOCKET, this);

//Call this to submit your score
ecd.net[0]->SendHTTPGet("http://www.max-studio.net/highscores.php?score=37348&player;=Jack");

For more information, check the networking tutorial: http://www.edgelib.com/index.php?node=554
i tried the SendHTTPGet method but it doesn't seem to work. it doesn't generate any error but it just doesn't work.

btw, is www.edgelib.com having a problem? i can't connect to the tutorial just now.
correction.. it worked alright. i forgot to add the http:// in front of it. but the tutorial is still unaccessable..
Yes, we're currently busy upgrading the server hosting www.edgelib.com. You can expect the site to be up shortly.
correction again.. it didn't work.. it worked when i submit the data to a local server here. but when i submit it to the net the page doesn't seem to receive anything.

my portion of code :

at ClassMain::OnInit()
shared.ecd->net[0]->Init(ECONN_SOCKET, this);

and at ClassHighScore::SubmitHiScore()

char paramtemp[10];

EHTTPRequest request("http://maxsvr/burningarmor/hiscore_submit.php");
//EHTTPRequest request("http://www.burningarmor.com/bace/hiscore_submit.php");
request.AddParam("a", shared->playername);
ClassEStd::StrCpy(paramtemp, "");
ClassEStd::IntToStr(¶mtemp;[strlen(paramtemp)], shared->currentlevel, 10);
request.AddParam("b", paramtemp);
ClassEStd::StrCpy(paramtemp, "");
ClassEStd::IntToStr(¶mtemp;[strlen(paramtemp)], shared->redset.score, 10);
request.AddParam("c", paramtemp);

shared->ecd->net[0]->SendHTTPPost(&request;);

do i need to add more code there?
I've tested it on my desktop machine, and I was able to succesfully connect and submit a highscore. This is the code I used (also removed a few lines of code which weren't necessary to make it work):

Code:

EHTTPRequest request("http://www.burningarmor.com/bace/hiscore_submit.php");
request.AddParam("a", "Jack");
ClassEStd::IntToStr(paramtemp, 2);
request.AddParam("b", paramtemp);
ClassEStd::IntToStr(paramtemp, 2006);
request.AddParam("c", paramtemp);
ecd.net[0]->SendHTTPPost(&request;);


This is a simple test in OnInit(). Can you tell me what kind of device you're using to test the submission of highscores?
that's strange.. i tried it just now but it didn't work. what do you mean about device? well, i submitted it with my personal computer and it's connected to the internet.

does firewall affect the submission? or should i alter some settings here and there maybe?
I've asked about the device because you might have tested it on a mobile device.

It could be that the firewall is blocking your connection (if you have Windows XP SP2 installed, it can block outgoing connections). Also, you may have to wait a short while until the request is complete.

You can also add the OnNetMessage() event to your framework and check incoming network messages. Messages are documented here: http://www.edgelib.com/index.php?node=265
Nic-Gun wrote:
Code:
EHTTPRequest request("http://maxsvr/burningarmor/hiscore_submit.php");
//EHTTPRequest request("http://www.burningarmor.com/bace/hiscore_submit.php");

Which of these are you trying with? If you're using the one that's not commented out (maxsvr), it'll only work inside your intranet. The second one should be accessible from both your intranet and the internet. So how are you trying to reach it? If it works in IE, it should work in your app as well.

-John
yeah i have SP2 installed so i guess firewall problems could be the issue.. is there any way to escape the firewall from edge?

@presto:
the code worked when i try to submit a high score to the first link, the intranet one. but when i tried to submit it to the second link, it doesn't work at all.

it worked if i submit the high score manually though using the get method..
Nic-Gun wrote:yeah i have SP2 installed so i guess firewall problems could be the issue.. is there any way to escape the firewall from edge?


helo nic,

have you tried to temporarily turn off the windows firewall to see if it is indeed blocking your request?

petre
Petre wrote:helo nic,

have you tried to temporarily turn off the windows firewall to see if it is indeed blocking your request?

petre


well, i dunno how to turn it off :oops: :oops: :oops: guess i'll have to ask my office's admin to turn it off later..

btw, i tried to submit the high score through
EHTTPRequest request("http://www.burningarmor.com:80/bace/hiscore_submit.php");

but it still doesn't work..
When using Windows XP with service pack 2, you usually receive a message when a program tries to connect to the internet (with an option to allow/deny it), did you receive this message?

Add the OnNetMessage event to the framework, and see if you receive the ENET_SERVERFOUND event in the msg parameter. If you don't receive this message, you can be sure that there is a problem with the program connecting to the internet, and it will probably be the firewall. Ask your computer/network administrator if the firewall of your local machine can be turned of temporarily for testing, or (if you have enough privileges) you can do it yourself by right clicking on "My Computer", select "Manage" and opening the "Services" menu. In the services list, you can find "Windows Firewall" and enable/disable it.
i just asked my admin to remove the firewall and he asked me back which port should be opened..

so which port does edge use to connect to the internet?

i also added the OnNetMessage() but the program never seems to reach there.
If not specified, http requests connect through the default http port 80.

If you don't receive any messages in OnNetMessage(), the connection can't be made to the server.
ok then.. port 80 shouldn't be a problem.. now the problem is how can i reach the OnNetMessage() method.. i did put the

shared.ecd->net[0]->Init(ECONN_SOCKET, this);

code at OnInit() and it returns an E_OK.. do i need to add another method so that my program calls the OnNetMessage() method?
The OnNetMessage event will be called when a connection with a server has been made, a previous connection has been closed or data is received. This should happen automatically when calling SendHTTPGet/SendHTTPPost. You can also try calling SearchHost() manually (with port 80), try your own local intranet as well as the online webserver. However, it still doesn't work when the connection has been denied.

Also, try building a test version for a mobile device as well (such as a Windows Mobile Pocket PC). This may work better because there are less restrictions from Windows Mobile than Windows XP related to networking.