Add a c# canvas to an MVC view? - c#

Is there a way to add a canvas (or anything that can render a c# application, more specifically a game such as Tetris) to an MVC view?
I would like to make a game, add it to a view, and send the score of the client to the server to process rewards and other stuff.
I have no idea how to get started, can someone show me the way please?
I would prefer to not use JavaScript for this, I would like a server based application.

Sorry, but you're going to need to use JavaScript since the API for canvas is written in it.
Another issue you're having, I think is you data layering. Which will eventually look like this:
C# Server <- Javascript Events -> Canvas View
Basically Javascript will call async methods to your server every so often, either getting data (current high scores) or sending data (giving new scores). In turn it will update the canvas view. Also, everything that happens to the canvas will be handled in JavaScript through its event handling system. These event handles can trigger other events like calls to the server or a local event like the current falling block to rotate.
I don't see away around JavaScript being a huge part of this, since you can't really do a real time game without a lot of it being client side, at least in a web based game.

Related

KinectSDK poll after using events

I have two sections of a Kinect app I'm making. There's a WPF menu which eventually directs the user to an XNA Game.
The problem is the WPF controls I'm using (like KinectRegion) are adding event listeners to things like AllFramesReady on the KinectSensor object. And as soon as I try to poll for skeleton data in my XNA game, I get the following error:
This API cannot be called when an event listener has been set
My question: How can I reset everything in the KinectSDK so I have a clean slate when starting my XNA game? Or at the very least, get it into a state where I can poll for skeleton data successfully.
I don't know what methods the WPF controls are attaching to handle the events, so I can't explicitly remove them from the event.
Similar issue: Get color Image not in the frame ready event
You are not able to use event handler and polling method at one time. Kinect API won't support that. better way is to use global variable for your polling method and use it on anywhere that you want.

How to use HTTP Handler to make a client2client communication?

I'm new to Web programming!
I try to make an app (something like Client to Client communication with C# Handlers and jQuery).
I.E.:
When 1Client make a click on his clientSide(browser), there paints one point, and on the same time the 2Client sees what 1Client did. And, in turn, where 2Client make a click on his browser, there paints one point, and the 1Client also sees what 2Client did.
I could done already the configuration of IIS, I made an simple show Hello World and it run OK.
And, further, what should i done....
Can you advice me, please, with some exemples, or tutorials, how to do this job.
Sorry for my questions which seems to be not studied.
To show a chat like think. The simplest way that I can think.
First you have a table that keep all the chat lines that enters.
Then in a page you have two controls, one text box that users enter text, and one GridView that you show what is on the table.
All of that you place them on an UpdatePanel and you make an internal update to 2 seconds.
So every enter from the users you inserting to the table, and every insert you show to all users.
This is for start.
you can use signalR for this !
It uses a long polling implementation to simulate websockets and it works rather well.
https://github.com/SignalR/SignalR
Quickstart example:
https://github.com/SignalR/SignalR/wiki/QuickStart-Persistent-Connections
A more complex solution would be to use socket io with iisnode/node.js
http://socket.io/
https://github.com/tjanczuk/iisnode/

Allowing a WPF browser application to navigate to a separate web page when finished?

I have a WPF browser application that collects user data and adds it to a database to tell them when their software is out of date.
All of that works fine, but the problem is when the application finishes its stuff, I want the web page itself to change (i.e., detect the web app has hit a 'finished' state, then autonagivate to a results page or something).
I can't think of a way to accomplish this, since the web app itself doesn't seem to be able to change the IFRAME it's contained in, much less the page outside of that, or signal to javascript or anything.
Any ideas?
I'd make an variable to keep progress/step of work. And a timer which would check if progress=="done" or sth.
Maybe this is not the best way of solving this but I don't know WPF much and that solution first came to mind

How can i automatically have a page save the current time to the DB in 5 minute intervals w/o postback?

Basically i have a C# Web App where a user views a streaming video. While they are viewing it, i have a timer running in the code behind. When they finish viewing the video, they hit a submit button which takes the difference from the start time and end time and emails the total viewing time to me.
The issue is, if they lose their session or their internet connection drops out for a brief moment, the time is lost and i have no proof how long they viewed the 1.5 hour video for.
I was wondering where to start to have it automatically save the time to the database like every 5 minutes behind the scenes without it affecting the streaming video or posting back, that way they have record of how much viewing time there was up until they lost connection.
We used the information from this blog post to accomplish it in our apps. There are code samples that show exactly how to do it. Adjust the
window.setInterval('SaveUserInput()', 10000);
line as needed to change the interval.
You could store the start time in a hidden field when page loads, and then use javascript to post to a webservice at a set interval with the start time.
One option would be to setup an ajax call to talk to the server on an interval to say "I'm still here" - if your ajax call sends a video ID or some other type of session identifier, it can update your database with the appropriate time.
I'd suggest looking into using jQuery for this along with [WebMethods]. It makes it quite simple to accomplish. Here's a nicely written article that talks about how to accomplish it with asp.net: http://dotnetslackers.com/articles/ajax/Using-jQuery-with-ASP-NET.aspx
You say "without a postback" - but does that mean a whole page postback? Otherwise it should be pretty easy to make an AJAX call back to the server from some JavaScript. You could use the JQuery library to easily make the call. Here's a pretty good page discussing how to call a page method from JQuery: http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/
Suggestions to use JQuery or other AJAX library to make ajax call every 5 min are good but if you are new to this, you can use the asp.net ajax extensions Timer object (Toolbox->AJAX Extensions->Timer). its not hard to use, it follows a typical event driven model like other ASP.NET controls

Implementing a Windows script

Hi
I would like to create a script which loads a program on my windows based computer, clicks on one of its buttons, and checks the data inside it (it gets its data from the web). Should I do that in C#? Any example out there?
The program contacts the web and displays information. I would like to get notified when that data has changed.
UPDATE: I've learned that the application doesn't contact a web-service using Charles. This means I have to load the windows application, click the button and look there. How can I do such a thing? I know it is disruptive, and still I would like to do that.
You need to download Wireshark to see what http(s) the program is using.
And once you come to know about http(s) used, you can use the WebRequest and WebResponse classes for making request to the server.
The method you described in checking for changes is quite disruptive: the script you intend to write needs to load the program and clicks the button. The loading and clicking is enough to disrupt whatever you are doing when the script runs.
I suggest changing the method to access the web directly to check for changes, and only displays a notification (WPF or whatever method you are comfortable with) when the data changes.

Categories

Resources