Simple Chat Web Application

  • Thread starter Thread starter tomdekok
  • Start date Start date
T

tomdekok

Guest
Hi All,

I just started to learn VB .NET thought i would write an extreme simple web application so network chat becomes possible.
I am talking about a text view window, a single line text input field and a "send" button, nothing more.
Anywhere you can get the newly created webpage to chat.

The problem: All text is sent to the client webpage and not to the server, even though all source says "SERVER". And i don't know how to update the client pages whenever someone has typed some chat text either.

(This all may sound boooring, but know this, i am studying my butt off to get into VB .NET. I know how to program in C very well which helps, but this goes so slow, because nowadays there are so many components to learn. *sigh*

Questions:
Does anyone have an example project in VB .NET for web based chat?
Can anyone help me with the above client/server problem and cleint page update difficulty?

Thanks in advance!!
 
Ok, I just looked at the site and downloaded some sources. God i really thought this would be it. Unfortunately i am using Visual Studio .NET and the sources are all in VB6.....
I have mailed the chap to see if he can convert the source to VB .NET and hope for the best.
 
Web based chat can be very different to client/server chat.

If you want it relatively similar, you have to write a control to sit within the webpage that maintains a connection to a piece of server side software that handles all the actual chatting. So the only difference here between a normal chat app and a webpage chat app is that the client is in the browser.

I could tell you how to do it in VB6, but not in .NET I'm afraid. What I do know, is that you use the System.Sockets class for TCP communications.
 
Thank for responding!
Yes, indeed System.Sockets. I am kind of sorry i choose .NET over VB 6, because now things are very hard to learn. .NET is kind of "extended" and there actually is not ONE complete reference manual available for programmers that gives insight to all the namespaces and objects that are available and on how to use them. And there are some...
If this wasn't the future, i would go straight back to learning VB 6.

Anyway.. Let me put things even simpler...
Suppose i would have a webpage that sends text back to the server. Have this. Now, the server picks it up, sends it back and see: the client gets updated with the text. No problem here.

The two remaining problems are these:
1. How can I record the IP or username sent by EACH client?
2. How can I (the server) reload the object for text display after having received some text from a client ?

for 1: There must be a way to do an IP poll (easily? :-) )
for 2: I read about some page_load thing, but that doesn't refresh the text window.

If i know this, i actually believe it would work! Without winsock misery and stuff... Maybe i am wrong, if so, tell me!
 
Grabbing IP addresses depends. Are you going to work this via HTTP - and push out the updated page each time a string is received, or are you going to go with System.Sockets? I would advise the latter..
If so, IP address of the Client will be available through some property of the class no doubt.

As for reloading the object - you shouldn't need to, since the object will be activex - essentially a vb program in its own right, running within the webbrowser. As such, you wouldn't need to reload it, just have the server send it a string containing any new text.

Note, when I say server - i don't mean the webserver itself, more the chat server software that you're writing to go on it. :)
 
Ok, i will look into this.

I just found a C++ (I am a former C programmer, so i do get the source mostly :-) that actually works as a great chat prog. Only it isn't made for web.
I am going to try to convert the visual part to web form and see if then - with the c++ source behind the form - it still would work.

Hope i am not wasting my time.. lol
 
GOT IT HALF!!

Guess what? I found an actual VB .NET source for a chat app.

The next problem becomes converting the visual part of the client to a web form:

1. not every object member is supported.
2. the webpage does a page_load on every click.

On 1:
Me.Invoke(New DisplayInvoker(AddressOf Me.DisplayText), params)

Me refers to Form1 in the regular source where the Form1.Invoke() member is supported. With the WebForm1 the Invoke member isn't available. How do I change the source so that this action can still be taken?

On 2: The reload of the webpage happens every time the send button is clicked. How can you refresh a text window inside a web form without refreshing the whole page, because that results in a disconnect/connect event at server side.

By the way, it it runs quite ok actually after converting the visual part and some source. Nothing comes into the client win, because of the missing Invoke() (it is taken out), but the webform DOES send the text to the other chat windows (regular ones) and the server, so there is threading and socket use. Just not complete (and correct yet).

And the port that is used, even though the client is running through IIS, is 8080 in this case.

Help me out guys (and girls?)!!
 
You're right! I actually didn't see this one.. :-)

I have been at winsockVB.com. Unfortunately they are only focused on VB6, which is indeed very easy to implement. In .NET this is all changed and quite difficult. God! What have i started!!
If i could install VB6 next to Studio .NET, i would in a jiffy. But that doesn't work.
 
Yes, but with a LOT of adjustments! I had VB6 before, then installed Visual Studio .NET Arch. and there the errors came!!

Do you have any idea why I cannot use "Dim data As String = Encoding.ASCII.Getstring(bytes)". I am getting an error on "Encoding" not declared. And i can't find ANYTHING anywhere on what namespace, object, etc. "Encoding" belongs to.
 
LOL Ok, then i will try. But i wasn't kidding you know... (and i am not stupid either :-)

Thanks for the System.Text namespace. Damn, i really need a COMPLETE reference. You search for "Encoding" under .NET Enterprise and you will find nothing anywhere. I find that weird.

I have been into sockets more and think i am getting it now, even under .NET. Now the next problem arises, as i am able to create multi threaded apps, i want to have a WEB based chat client. This needs to run on Thin clients in the end.
My main problem is in the update of the read-only text window where the chat is happening. It is cleared every time an event is triggered. How can i make sure the page_load event happens only once??
 
It surely comes with a lot of Cd's, and i installed them all. And i believe everything is in there, the problem is it is "somewhere".

If you don't know what namespace you are searching for, you get what i had, sometimes nothing. But i agree it is by itself complete.
Thanks for the link, it helps a lot!
 
I typed the word "encoding" in to the IDE help search facility and got 500 topics, so it's clearly not short of information :P
 
ROTFL I see what you mean! And you are right - but you knew that of course..
I guess i have to get used to this way of searching. Usually i use VB or SDK to search, that is why.
Am i stupid? Ok, don;t answer this please...:-)

Thanks for you answers by the way, i really appreciate it!!
 
Back
Top