web based game in asp.net?

Started by
2 comments, last by SimonForsman 12 years, 4 months ago
I know a little of asp.net, but one thing is bugging me before I write a simple multiuser dungeon with it, the fact that you can only refresh the html when the user clicks a button to, it cant be automatically triggered from the server... or can it? Does anyone know this?

Or is php or some other language something I should use, cause it enables this "auto resend updated page"

Thats the thing thats bugging me at the moment, without it the game is just about working, but with only a really nasty "click me updated" and you could dead if you dont click it every now and again.... just in case a monster starts eating your toes off, youd never know until you clicked "update" which makes no sense at all.

Advertisement

I know a little of asp.net, but one thing is bugging me before I write a simple multiuser dungeon with it, the fact that you can only refresh the html when the user clicks a button to, it cant be automatically triggered from the server... or can it? Does anyone know this?

Or is php or some other language something I should use, cause it enables this "auto resend updated page"

Thats the thing thats bugging me at the moment, without it the game is just about working, but with only a really nasty "click me updated" and you could dead if you dont click it every now and again.... just in case a monster starts eating your toes off, youd never know until you clicked "update" which makes no sense at all.




You can use JavaScript to have the client ask the server if an update is available and update whatever is needed, If you don't mind skipping support for older browsers you can use websockets to establish a persistent connection (Which allows the server to push updates)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
cool! I was wondering if it was possible.

What does the javascript version look like? (the one that asks for the update, does it work on a thread? cause it would need to be continually updated would it not?)


just updating the view window whenever something changes in his view, thats all i would need.

cool! I was wondering if it was possible.

What does the javascript version look like? (the one that asks for the update, does it work on a thread? cause it would need to be continually updated would it not?)


just updating the view window whenever something changes in his view, thats all i would need.


It depends on how bandwidth efficient you want to do it:

The easy way is to have 1 asp script that simply prints a json object (1 if an update is needed, 0 if it isn't), or that returns a 404 or something if no update is needed and then use jquery to load that asp script repeatedly and act on the result.

something like:

<script>
function update() {
$.get("updatecheck.asp", function(data){
if (data=="1") {
$('#view').load("updateview.asp");
}
});
}
window.setInterval(update,2000);
</script>

should do the trick, if updatecheck.asp prints 1 (plain text) then whatever content updateview.asp prints out will be loaded and placed inside the element with the id "view" (This could be as simple as a <div id="view"></div> that you position wherever you want it using CSS. (Everything runs in the backgound)
More complex polling and update schemes can be used aswell (You can google long polling and you could also load xml or json data and update individual elements rather (Thus rather than sending the entire HTML for the new view you just send a list of changes to the view, the code for this would be highly game specific though) than reloading the entire view aswell to greatly reduce bandwidth usage).
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

This topic is closed to new replies.

Advertisement