Creating webplugins - c#

I am trying to create a program that will be passed input data from events a user fires from a webpage on their browser. I am aiming at google-chrome currently with the program being in either java or C#. I know this is possible because Spotify does this, so does the Battlefield 3 PC gui. How can I go about doing this? Does the user need to install an extension or can I get that information straight from google-chrome? Note: The webpage is not being run on localhost.

You're going to want to look into web sockets. Web sockets are just cool. I got a huge grin on my face the first time I got demo working. :D
Here's a tutorial that helped me out:
http://www.developerfusion.com/article/143158/an-introduction-to-websockets/
You can create a socket listen in your appilcation then connect to it from javascript, passing whatever data you desire. It's nicer then ajax as it's a persistent open connection and you don't have the overhead of http calls.

Related

Making two programs talk with each other

My group in the university are working on a project, which includes us making a C# program. We have a vision of making a server side console program that is constantly calculating data and then make a client side program that can fetch the data from our server side program. The client side program will then be able to display the data and the user is able to navigate forth and back around the data. Both of these programs will be run on the same computer solely for exercise purpose.
I am wondering how I can get data from the server side program and be able to display it on the client side program.
If both client and server are always on the same machine, there is no need at all to use WCF or Sockets. You can use named pipes for the interprocess communication.
If you're trying to do a more serious client/server application, I recommend you to try Redis which provides a lot of remote features like pub/sub and caching, so you'll avoid reinventing the wheel.
As mentioned in the comments that sounds like you would like to create a "server" like application which you could do with WCF.
http://tech.pro/tutorial/855/wcf-tutorial-basic-interprocess-communication
There are also some workarounds if you wish to do so, using a Database or use a folder containing Text Files,that would include a folder watcher, which you than read, but they are not that elegant.
You can get data to the client program by configuring it by using web.api self hosting. Here is a great link. The server app can be configured to use the same thing. They can both listen and answer one another.
http://www.c-sharpcorner.com/UploadFile/b1df45/Asp-Net-web-api-self-hosting/
Why don't you give ASP.NET Web API a chance?
You'll be creating a REST API that not only a C# program can talk to (any language/implementation - even another server) can talk to your server as long as the end point is correct (in your case would be your IP address and port number) & of course, you don't need both programs to be on the same computer as well :)

What is the right method for a web chat application in c#

i'm trying to make a chat application using c# that connects to a web server in order to check if there are messages available.
I've tried that by creating HttpWebRequest to check for messages every second, but i notice that it's not good for the server, imagine if there are thousands of users and each user sends an HttpWebRequest every second, that would be heavy.
I heard something about synchronous connection but i think it also sends the same number of HttpWebRequest, (i'm not sure about this part).
So please does any one know the right method for a chat application?
Perhaps SignalR might be useful in your case.
ASP.NET SignalR is a new library for ASP.NET developers that makes it incredibly simple to add real-time web functionality to your applications. What is "real-time web" functionality? It's the ability to have your server-side code push content to the connected clients as it happens, in real-time.
Actually the most typical tutorial using this technology is web chat.
Use the Remoting.Net
see this :
http://www.codeproject.com/Articles/62813/NET-Remoting-Events-Explained
http://www.codeproject.com/Articles/12586/Remote-Execution-Using-NET-Remoting

Serial Port over the Web

I am starting to program in C# and build applications over the web.
I have a board with a PIC microcontroller that I made that communicates with the PC via USB-Serial converter (FT232).
Now I want to do this: I want to create a website on another computer that allows you to communicate with the PC with the PIC board. Via the other computer I want to be able to control the PIC board.
I think that in order to do that I have to start learning about ActiveX, if I'm not mistaken. Does ActiveX allow me to write on another computer's serial port?
I really want to learn that.
Could you please guide me in the correct direction, and if possible a book or tutorial?
Thank you very much, and sorry for any english mistakes.
No, ActiveX is to let a web page interact with the computer of the visitor of that web page, an old system which should not be used again. Although HTML5 seems to want to reimplement a lot of ActiveX-like functionality again, this is not what you want.
If you create a C# application or service that uses the SerialPort class to talk to your PIC, and use for example a WCF service to accept commands over the internet.
You can then create a web page that lets the user issue commands, while the back end of the web page calls the WCF service to send the command to the PIC.
You could build a website or a webservice which runs on the computer with the PIC board. This website would allow you to send commands to the local attached board.
If you have got a .NET SDK for your board you should be able to wrap all the commands in the service or website.
Might look at something like this product http://www.virtualserialport.com/products/serial-over-ethernet/, if you want to make it look like a local serial port. If that's not necessary, I'd write a service that listened on a socket and simply sent the serial data between the socket and the serial port.

How do I implement WebSockets from scratch with the .NET 4 Framework (and nothing else)?

Ok I want to build a simple chat app where people can go a url, type in a name and a message and click submit and it will basically show that message to everyone that is current connected.
Firstly i would like to state i've had zero experience in sockets programming and the like. I'm simply a web 2.0 person building websites with css/html/js/ajax and backend i have asp.net on vb and sql server for database.
The many tutorials i've read linked me to http://superwebsocket.codeplex.com/
I've downloaded it, but im totally lost. i can't get the samples working and i don't even know what to run.
So basically coming from an ajax background, i was wondering why do we even need to download any additional stuff to do web sockets? I mean in ajax i can simply create a asd.aspx file and use Response.Write(text) (text based on the input which are available through dissecting the url) and voila, the server side is done, all that's left is just to create new XMLHttpRequest and stuff in the client side.
So ok I'm not worried about the client side part of Web Sockets. but the server side part of web sockets is just difficult. so in the client side i have this: ws://localhost:8080/websocket. Is it true that it will work if is also an .aspx file as such: ws://localhost:8080/websocket.aspx ?
I'm wondering so how do i continue from here? in Ajax i will supply parameters from client in the url as such: page.aspx?a=1&b=2 and do output in the server using Response.Write it's all clear but how do we do it in web sockets?
I mean of course i do not demand a full explanation with a forum reply but if someone could link me to a tutorial/book that actually does explain these stuff it would be great.
Microsoft's implementation has a full chat client sample for both HTML5 and pure C#.
http://html5labs.interoperabilitybridges.com/prototypes/websockets/websockets/download
I'm guessing this implementation is what would end up in ASP.NET and .NET framework so I'm using it because of that.

Website but more like chat application behaviour

Hi I wanna make a website preferably using asp.net 3.5 in c#. In this web app, I need to push messages very frequently. (like if sender sends a message, it should immediately reflect to the receivers). So more like chat application but not bidirectional.
My question is how can i refresh receivers webpage immediately?
or How can i push message to the receivers immediately?
any help is highly appreciated?
I'm guessing you're talking about features like Facebook Chat. According to various facebook dev blog posts, I believe they use ajax to make a long polled request; meaning as soon as one user sends a message, theres another ajax request made which isn't responded to by the server until there's something to report (i.e. a new message). This is often called "Comet".
Note: do NOT attempt to do this on a standard server setup - most server software starts a new thread for each request. You'll need custom server software to avoid this. Unfortunately, I've searched for hours in the past and can't find a definitive answer to which software accomplishes this best.
You might consider using a Comet Look at the "implementation" section for some ideas.

Categories