Remoting in .net - c#

I am doing applications on .net remoting ,i write the code for
Client -----------> server
but
client <------------ server
i don't know how to do it(just like a chat),Please give suggestions and some samples to look up.
without any request from server i send messages from my client application

Try using MarshalByRefObject and events. This would allow the Server to respond back to the client.
Here is a sample on code project
Another Sample with Event CallBack

Related

Sending signals from a remote server to a .NET application

I have a .NET application which sends PHP GET and POST requests to my server (on an AWS EC-2 instance).
I now have a need for the local application to know in real-time when an event on the server happens.
Basically two "accounts" are linked and they need to synchronize, so when one makes a change on the server, then the server must send a signal to the other to update it's "view".
I'm aware that I could achieve this by constantly querying to server to check for changes, but that seems horrendous.
Could someone please point in the right direction here?
Thanks!
Certainly you could use signalR, signalR can be hosted like website, when your client starts it can connect to this signalR website. SiganlR should be hosted separately from your server application.
Let say A,B client and your Server application got connected to signalR. Now when A modifies something using post method to your PHP server, PHP server then can invoke a method in signalR , then signalR can broadcast message to all the clients connected. You can use group concept in signalR to target specific audience.

Sending messages from server to client c#

My client sends messages to the my server using tcp protocol (my server has a listener).
I'm trying to send messages back from the server to the client, but I'm not sure what do I need to add to the client in order to get those messages.
I tried looking it up, but I didn't understand how to implement it.
Could you please assist?
It's the exact same process, but in reverse.
If you intend to receive messages independently (i.e. not in response to a request by the client), you need to make the client a TCP server, too. The client needs to implement exactly the same thing as the server you have now and the server needs to connect to the client.
Can't you use WCF, which supports callback contracts?
If you want a console example of a client server application using a network library see here http://www.networkcomms.net/how-to-create-a-client-server-application-in-minutes/.
If you want a WPF application example then see here http://www.networkcomms.net/creating-a-wpf-chat-client-server-application/

WebSocket java plugin unable to connect

I am using this http://anismiles.wordpress.com/2011/02/03/websocket-support-in-android%E2%80%99s-phonegap-apps/#comment-689 plugin. I am experiencing a problem where when I create the websocket object and a regular tcp server written in c#. I confirm the the connection headers are recieved, however, the onopen or onmessage events in the javascript are not fired? Any suggestions? Thanks!
You mention using a regular tcp server. Are you aware that a websocket connection is slightly more complicated that a regular tcp connection? You have to complete a handshake then frame all subsequent messages. Your browser handles all this for you on the client; you have to provide equivalent code on the server.
RFC 6455 describes the protocol if you want to write your own server. Or you could use an existing C# server - using either the .NET v4.5 class or a third party server.

Handling events in a Windows application

I have a mobile applciation thats interacts with a server. The mobile application should be allowed to do a http posting to the server.
The server should be able to handle the event and display out using a custom windows .net application on the server almost immediately based on event.
So what are the right ways to do it?
Is there any event handling that works on c#.net that can be applied on the above scenario?
So far i only thought of msmq event handling. The mobile app does a http post on the server, the server creates a msmq on the server side and the windows applications listens for the new msmq message.
If you must use HTTP post then you could write your own web server in C# and add handling for specific requests from your mobile device.
This project outlines how to create a web server in C#. Inside of the StartListen() function you can check for your target message instead of "GET". Alternatively you could use the functionality from this open source project: http://webserver.codeplex.com/ and hook the appropriate HTTPListener functionality.
The real thing to understand here is that the "web server" is really just a thread that is listening for a specific data stream on a socket. You could easily adapt simple socket send / receive code like this to implement your functionality.

is it possible to make an Asp.net IRC client?

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

Categories

Resources