I want to build a web-based irc client with JQuery. I know I need to open a socket to the irc server. What I'm wondering is, is it possible to open a socket purely from server-side C# code? Or would the nature of a web application prevent this and I would have to write a service to run on the host machine?
Thanks for any help :)
Yes, you should be able to make a socket connection from server-side ASP.NET code. On the other hand, given that you'd presumably want a persistent connection to the IRC server (rather than a new one on every request), you may want to write a separate service anyway - you don't want ASP.NET recycling to kick in and wipe all your context, for example.
Your ASP.NET code could then talk to your service to find out what had happened since the last request for that user, etc.
One simple approach would be to setup a singleton WCF service which acts as the bridge to IRC. jQuery AJAX calls against that service could then post messages that were input by the user, as well as retrieve messages sent by other users.
I have implement the chat with ASP.Net by using the SingnalR for duplex communication.
What I really done consist on the following steps.
1) ChatHub.cs
I have write down all the logic to connect with the IRC server and connect to the channels, receive different messages and notification from the IRC server. I then send these notifications to my ChatHub client by calling the javascript call backs from the ChatHub.cs
2) Client.aspx
Simple HTML page and it is using jquery to register the callbacks from the ChatHub.cs
3) IRCDotNet.dll
I have used this library to communicate with the IRC Server.
Hope, It will help somebody. Here is the link to download the IRCDotNet.dll
http://ircdotnet.codeplex.com/releases/view/50639
Related
I have an application in WPF c# which will run on client machine. Another application (maybe some kind of service) on a particular server will be running all the time and will wait for any incoming message from the client app. As soon as the server receives a request from any of the client application, it triggers a command line process and also responds to the client about the staring info(whether it was successful or not) and as well as when the command line process is finished it again responds to the calling client application that it got finished.
I am new to in this area.
So my question is should I use normal windows service or Web service or WCF?(Some kind of link to a demo project will really help). Any other suggestion are also welcomed.
You did not mention if your clients will be outside of your firewall or with in the same intranet. We have intranet scenario, and we use WCF service that communicates with WPF based applications over the internal network. WCF provides Duplex feature which enables two-way client server communication using an easy to implement programming model. I recently wrote an article on this and it can give you a head start for the WCF way.
However, WCF does not have the best support for callbacks over the internet and you may have to look in to effectively using it in your case. But if it is intranet, then my suggestion is surely to go for the WCF way. Hope it helps.
Here’s our architecture:
JIRA webhook sends messages to a Java Jersey REST service when issues are assigned.
C# client application registers the username/host machine combo with the Java web service when a user logs into the machine
When the web service receives a message from JIRA, it finds the assignee username and sends the required data to the C# client app on the host machine(s) the user is logged into.
I’ve thought of a couple approaches to solve the web service to client message.
My first is opening a TCP port on the client and having the service send each message directly to it. This is the most straight-forward approach but makes the client a little heavy in that it maintains the list of user assigned ticket data that they can then manipulate (acknowledge or remove).
The other is having the service maintain the data model and the client requests data periodically. This makes the client simpler but then I’d have to implement a polling interval to grab data, and add some POST methods for acknowledging and removing data from the user’s list.
I was looking into different ways to have the client register a channel with the service, like ServiceStackEvents, but I can’t see a way to make that work with a C# client and Java service. Something like that would be perfect. A way for the service to send callbacks or event messages to a client based on a user filter.
If someone has some suggestions or knows of an API to help with this, please post a link so I can dig into it. The POSTs are all working swimmingly, it’s just getting the data back to the clients that I’m struggling with the best approach.
Thanks!
Client polling is not a terrible solution.
But if you want a firewall and proxy friendly duplex protocol, check out WebSockets https://en.m.wikipedia.org/wiki/WebSocket.
I have Windows service written in C# that basically acts as a timer to fire an event. When the service fires I need to call a Angular.js controller passing variable(s) and receive a PDF file back as the response. I'm new to Angular so any help would be appreciated.
Angular lives on the client side in the web browser (well, typically anyway) so if you want to communicate to it from your C# service you need to find a way to send and receive information between your server (running the service) and the client browser.
How you can go about this depends on your project's needs, but for timed events you're probably best off using websockets to perform this communication. If you're working in C# you might want to check out SignalR for your backend.
I'm about to start to develop and application in C# but I realized that I haven't the enough knowledge to develop it yet :S.
The thing's that I need to find out a way to let the Web server comunicate with my application, i.e., in short, is there a way to let the web server (not the Client which is the trivial case) send a messege to a Client application?
I know that I way to solve it's to make Client applications periodically send messages to the web server but that's not what I want 'cause polling generates overhead
Sorry about my english! I'm not a native speaker.
Thanks in advance!
Generally this type of interaction is achieved with Comet or WebSockets - I'm not sure how your app will be communicating with the server, but I would bet you can do what you're trying to do using one of those.
You could implement a WCF service in your client that could listen for a connection from the server (or anything else). The server can communicate with the client as easy as calling the API.
Getting started with WCF is really easy using the wizards in VS.
Here is a link that talks about using WCF with ASP, but it can be used outside of asp as well.
It seems like you meant "push" messaging, the challenge around this is for the server to keep track of the lost of clients and manage who should recieve which message.
If you want to get it done with minimal overhead you can check out the Amazon Simple Notification Service.
SNS is a cloud-based messaging and notification service hosted and managed for you, SNS is based on a topic/subscriber model and you set it up via a few simple API calls, it is metered but quite inexpensive for the most part.
edit: For C# Libraries and frameworks to do it yourself, I am not an expert in the C# world so I think other answerers will know it better.
Disclosure: I work at amazon so I am naturally inclined to like their product
I need to re-write an existing client-server application.
The existing application communicate using socket, I have to convert it into WCF.
At server side I need to
Monitor connected clients
Validate client request
Broadcast live data (comming from diff source).
Listen to client and respond to it
At client end I need to
Receive server broadcast and display it on UI.
Display UI and take input from user
Submit user data to server and display response
I have chosen tcp protocol on self hosting environment.
I need some immediate level references (link, tutorial, book)...
Have a look at this MSDN article, covers pretty much everything you need to know to build a duplex service in WCF:
http://msdn.microsoft.com/en-us/magazine/cc163537.aspx
You can try this : WCF on MSDN
I don't know if you can get it, but Microsoft book on WCF (course 6461A) is not bad.