C# Messaging system

Associate
Joined
30 Dec 2005
Posts
415
Hey to all,

I'm currently developing a C# application which acts as a client on a messaging system between a web server and your pc. It was all going fine till I actually got to the messaging bit and hit a wealth of problems.

What technology should I use? XML, SOAP, C# Classes on the webserver?
How do I make the server and the client pc talk? I mean, this was fine when I was at home and had full access to port forwarding to my pc, but now i'm at university, it's a different ball game. The IT staff said to me that most ports are open, but I still don't see how to do this... The web server will socket connect to the university's WAN address, but how does it then gain access to my PC on the uni LAN? Aaah! Do you have to send details of the LAN address in the packets or something?

Any help and advice would be appreciated!!
 
Soldato
Joined
18 Oct 2002
Posts
5,600
Location
Surrey
a SOAP XML web service should be able to get you past most firewall and port blocking issues. These are trivial to develop inC# .net 2.0, I hitnk there is a HOWTO on MSDN that uses a messenger type system as an example.

.net remoting is another possiblity and this might make securing your application a bit easier., again you can use a TCP transport system using port 80 for ease of bypassing those pesky firewalls.


If you want to connect to a server on the outside of the UNI wan, then you need to connect to the internet address that it resides at. don't worry about the PC -> WAN -> internet -> connections, the TCP/IP hamsters will sort all this out for you.

It might be time to get that networking text book out of the library and read the chapter on TCP/IP

Basically the client PC on the Unit WAN connects to the server, the server responds to that PC's request. Don't worry about how the hamsters on the uni network know which PC to take the packets to when they receive the responce form the server, it's not your problem.

Paul
 
Associate
OP
Joined
30 Dec 2005
Posts
415
Eeek! Just had a look at SOAP and it looks like a huge thing for me to get working when I only know the basics of C# visual..need to work on something simpler! Thanks very much for the above info though it's given me some ideas :)

I'm thinking, how about when the c# app loads, it sends a standard port 80 http request to the server and logs you into the chat app on the php server. This then sends the response back in xml. Easy enough :D

Then, when a user sends a message using the c# app, it sends it via http POST to the web server. The web server again responds using xml. Again, easy enough :D

The problem occurs when a user on the web server is sending a message to the C# app...the web server sort of needs to ping the c# app to let it know that there's a new message waiting. The c# app can then use the http request to retrieve the response in xml.

So the hard part is the ping...how do I get PHP to ping the C# app (Bear in mind that PHP will have the WAN and LAN IP addresses of the C# app if that helps). How do I get C# to listen for the ping and then trigger something?

Any ideas?
 
Soldato
Joined
18 Oct 2002
Posts
5,600
Location
Surrey
go to msdn.microsoft.com

look up XML web services and .net, it's really really simple.

basically, you have a web service, that makes stuff available.

the client calls that stuff and get's the answer back. it's just like working with asyncrynous methods in local objects.

SOAP is extremly complex but VS.net hides it all from you, all you need to do is create a reference to the web service and go from there. look at the tutorials on MSDN and stop panicking.

;)

HT

edit: and wtf are yyou looking at PHP for, I thought you were trynig to build a messaging app using C#, SOAP and xml web services?
 
Associate
OP
Joined
30 Dec 2005
Posts
415
happytechie said:
go to msdn.microsoft.com

look up XML web services and .net, it's really really simple.

basically, you have a web service, that makes stuff available.

the client calls that stuff and get's the answer back. it's just like working with asyncrynous methods in local objects.

SOAP is extremly complex but VS.net hides it all from you, all you need to do is create a reference to the web service and go from there. look at the tutorials on MSDN and stop panicking.

;)

HT

edit: and wtf are yyou looking at PHP for, I thought you were trynig to build a messaging app using C#, SOAP and xml web services?

The server being used is a shared one, so I can't install anything extra on it. I was looking at something like this http://devzone.zend.com/node/view/id/689
I'm not specifically looking at SOAP and xml...they were just a few ideas going through my mind.

Anyway thanks for the above details i'll give it another look.
 
Soldato
Joined
18 Oct 2002
Posts
5,600
Location
Surrey
what are you ACTUALLY trying to achieve?

what web server apps do you want to interface with, what functionality do you want to achieve? That page you linked to is a way to CONSUME a SOAP web service in a PHP application and you are talking about clients and not being able to install anything on the server????
 
Associate
OP
Joined
30 Dec 2005
Posts
415
Ok sorry I should have been more clear.

Basically, users will go on a website. There is an AJAX application on there for them to communicate by text with the website staff. Each member of staff has a C# application running on their PCs at all times.

I'm effectively trying to achieve 2 way communication between the web user and the staff member.

Client (on website) -- AJAX Application-- PHP/MYSQL Server -- C# Application -- Staff (on home pc)

The messages are stored in a MySQL database on the webserver, and communicates with the client using PHP and JS. The bit i'm stuck with is communication between the webserver and the C# application. I want to use PHP on the webserver to handle the communication as the database structure is quite complex etc.. it will also be easier to then integrate with the other facilities on the site.

So to make it clear, I need to create communication between PC A using PHP, and PC B using C#.

Btw from reading through that article I gathered it's not just for accessing SOAP web services but for creating them as well - "This article describes the new SOAP extension for PHP. It is intended for PHP developers who want to write their own Web Services servers, or use SOAP to access existing ones."

Anyway i'm not going to argue about that because i'm probably wrong :p
 
Soldato
Joined
18 Oct 2002
Posts
5,600
Location
Surrey
do you have the design documentation / access to the source code for the server app/website?

You might be able to make a C# app that used the same (server side) functionality as that used by the AJAX pages. Whyy not just let the admins use the same AJAX app as the clients are using?

HT
 
Associate
OP
Joined
30 Dec 2005
Posts
415
I originally built the website in question, and am currently rebuilding it. This means there is no problem with it having to fit the design of the current system, as I have to write all the code.

The client side AJAX bit is all done and working fine, but I am yet to build any of the bit for communication between the server and the C# app (basically because I didn't know what technology and protocol to use). So based on what I learn on this thread will effect how that part of the application will function.

The reason for having the C# app instead of lets the staff go on the website is because I know none of them will use it (it's a voluntary thing anyway, and they won't be bothered to keep logging into the website each time they go on the PC. You can also guarantee they won't like a window sitting in the taskbar all day.
 
Associate
Joined
25 Jul 2003
Posts
1,980
toastyman said:
So the hard part is the ping...how do I get PHP to ping the C# app (Bear in mind that PHP will have the WAN and LAN IP addresses of the C# app if that helps). How do I get C# to listen for the ping and then trigger something?

I adont know much at all about this, but I seriously doubt whether this is possible. You would probably have to resort to polling (i.e: getting the c# app to repetetively ask the server if anything has arrived).

toastyman said:
The client side AJAX bit is all done and working fine, but I am yet to build any of the bit for communication between the server and the C# app (basically because I didn't know what technology and protocol to use). So based on what I learn on this thread will effect how that part of the application will function.

It was a little bit silly to fully develop one side of the design before even knowing whether the other side would work at all! Might have been an idea to knock up some very quick tests to actually check what you were planning was feasible.

toastyman said:
Client (on website) -- AJAX Application-- PHP/MYSQL Server -- C# Application -- Staff (on home pc)

This is the main problem - the design is a little silly. At the end of the day you will almost certainly need something more like this:

Client --> AJAX Application --> C# Server Side App --> C# end user app

toastyman said:
The server being used is a shared one, so I can't install anything extra on it.

Obviously with this constraint you can't make your own server side application - in which case you are pretty much screwed (I may be wrong).


<edit>
It probably is possible to do what you want - but having your own server that youc ould just write a server-side app for would be a far better solution.
 
Last edited:
Soldato
Joined
21 Oct 2002
Posts
18,022
Location
London & Singapore
If you don't want to dabble in IIS to host your web services then download a package called Web Services Enhancements (WSE) 3.0 and that will let you host a web service on a TCP socket from your own Windows service. Completely eradicating the need to deploy in IIS :)

Web services are the future so use them. They are very easy to use - almost effortless. But for god's sake don't use PHP with web services... it'll scare you away for good because they are just hacked onto the side.

VS.NET/C# does it properly.
 
Associate
OP
Joined
30 Dec 2005
Posts
415
Lagz said:
I adont know much at all about this, but I seriously doubt whether this is possible. You would probably have to resort to polling (i.e: getting the c# app to repetetively ask the server if anything has arrived).
That has been my backup plan for some time now...looks like I may have to integrate it.



Lagz said:
It was a little bit silly to fully develop one side of the design before even knowing whether the other side would work at all! Might have been an idea to knock up some very quick tests to actually check what you were planning was feasible.
I decided that because I am a lot stronger at PHP/JS than C#, it would be more logical to build the PHP end and get the database sorted and working, so when it comes to doing the C# i'd have something to test with, as it's more likely to go wrong.


Lagz said:
This is the main problem - the design is a little silly. At the end of the day you will almost certainly need something more like this:

Client --> AJAX Application --> C# Server Side App --> C# end user app
Sounding more and more like my mum :(
Yes, the design would be better like this, but for this scenario it's not possible, so I have to work with what I have. Simple as that.

If you don't want to dabble in IIS to host your web services then download a package called Web Services Enhancements (WSE) 3.0 and that will let you host a web service on a TCP socket from your own Windows service. Completely eradicating the need to deploy in IIS

Web services are the future so use them. They are very easy to use - almost effortless. But for god's sake don't use PHP with web services... it'll scare you away for good because they are just hacked onto the side.

I already have been scared by web services! The problem with the above is that the server is Linux based and not Windows, so I can't exactly use IIS. :(
I might just use XML polling for this scenario, and then get web services working on some of my windows machines and have a play.

Thanks to all for your ideas and comments. :)
 
Back
Top Bottom