IT Community - Software Programming, Web Development and Technical Support

Chat Application

This is a discussion on Chat Application within the ASP and ASP.NET Programming forums, part of the Web Development category; hi all, i need to do chat application in my project, is it easy to do in asp.net(c#) ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 02-14-2008, 11:34 PM
Manikandan.S Manikandan.S is offline
D-Web Trainee
 
Join Date: Feb 2008
Posts: 8
Manikandan.S is on a distinguished road
Arrow Chat Application

hi all,
i need to do chat application in my project, is it easy to do in asp.net(c#) if it, pls help me to that

thank u
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-15-2008, 02:50 AM
Kirubhananth Kirubhananth is offline
D-Web Programmer
 
Join Date: Feb 2008
Location: My native is Madurai but now in Chennai
Posts: 61
Kirubhananth is on a distinguished road
Send a message via AIM to Kirubhananth Send a message via Skype™ to Kirubhananth
Talking Re: Chat Application

It is very easy to do chat program if you learn DOT NET clearly.
So study it clearly first, then come to do project
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-11-2008, 05:39 AM
poornima poornima is offline
D-Web Sr.Programmer
 
Join Date: Dec 2007
Posts: 189
poornima is on a distinguished road
Smile Re: Chat Application

Hi,
Visit the below link..

CodeProject: Simple Chat Application in ASP.NET. Free source code and programming help

This will help u...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-19-2008, 09:42 PM
GDevakii GDevakii is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 138
GDevakii is on a distinguished road
Smile Re: Chat Application

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
using System.IO;
using System.Net.Sockets;
using System.Threading;

namespace Wrox.WindowsGUIProgramming.Chapter9
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class ChatApplication : System.Windows.Forms.Form
{
internal System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.TextBox txtMessage;
private System.Windows.Forms.Button btSend;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.ComboBox cmdHost;
private System.Windows.Forms.CheckBox chkSuspendClient;

private PeerConnection p = null;

public ChatApplication()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
p = new PeerConnection(4048, listBox1, cmdHost);
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.txtMessage = new System.Windows.Forms.TextBox();
this.btSend = new System.Windows.Forms.Button();
this.cmdHost = new System.Windows.Forms.ComboBox();
this.chkSuspendClient = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(688, 394);
this.listBox1.TabIndex = 0;
//
// txtMessage
//
this.txtMessage.Location = new System.Drawing.Point(8, 408);
this.txtMessage.Name = "txtMessage";
this.txtMessage.Size = new System.Drawing.Size(576, 20);
this.txtMessage.TabIndex = 1;
this.txtMessage.Text = "";
//
// btSend
//
this.btSend.Location = new System.Drawing.Point(608, 408);
this.btSend.Name = "btSend";
this.btSend.TabIndex = 2;
this.btSend.Text = "Send";
this.btSend.Click += new System.EventHandler(this.btSend_Click);
//
// cmdHost
//
this.cmdHost.Location = new System.Drawing.Point(8, 432);
this.cmdHost.Name = "cmdHost";
this.cmdHost.Size = new System.Drawing.Size(520, 21);
this.cmdHost.TabIndex = 3;
this.cmdHost.Text = "localhost";
//
// chkSuspendClient
//
this.chkSuspendClient.Location = new System.Drawing.Point(544, 432);
this.chkSuspendClient.Name = "chkSuspendClient";
this.chkSuspendClient.Size = new System.Drawing.Size(152, 24);
this.chkSuspendClient.TabIndex = 4;
this.chkSuspendClient.Text = "Suspend Client";
this.chkSuspendClient.CheckedChanged += new System.EventHandler(this.chkSuspendClient_CheckedC hanged);
//
// ChatApplication
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(688, 462);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.chkSuspendClient,
this.cmdHost,
this.btSend,
this.txtMessage,
this.listBox1});
this.MaximizeBox = false;
this.Name = "ChatApplication";
this.Text = "Chat!";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new ChatApplication());
}

private void btSend_Click(object sender, System.EventArgs e)
{
p.Write(txtMessage.Text);
}

private void chkSuspendClient_CheckedChanged(object sender, System.EventArgs e)
{
if(chkSuspendClient.Checked==true)
{
p.Enabled = true;
}
else
{
p.Enabled = false;
}
}
}


public class PeerConnection
{
private System.Net.Sockets.TcpListener peerListener = null;
private System.Net.Sockets.TcpClient peerClient = null;
private System.Net.Sockets.NetworkStream netStream = null;
private Thread t1 = null;
private IntPtr formHandle;
private int port = 0;
private bool clientEnabled = true;
private ListBox lb;
private ComboBox cmb;

public PeerConnection(int port, ListBox formHandle, ComboBox cmdHost)
{
this.port = port;
this.lb = formHandle;
this.cmb = cmdHost;
t1 = new Thread(new ThreadStart(CreateListener));
t1.Name = "Listener Thread";
t1.Priority = ThreadPriority.AboveNormal;
t1.Start();
}

delegate void CallbackListbox(string message);

void SetListboxString(string item)
{
lb.Items.Add(item);
}

private void CreateListener()
{
Socket tc = null;

peerListener = new TcpListener(port);
peerListener.Start();

CallbackListbox clb = new CallbackListbox(SetListboxString);
while(true)
{
tc = peerListener.AcceptSocket();
byte[] byMessage = new byte[256];
Thread.Sleep(500);
int iLength = tc.Receive(byMessage, 0, byMessage.Length, SocketFlags.None);
if(iLength>0)
{
string message = System.Text.Encoding.Default.GetString(byMessage);
try
{
if(lb.InvokeRequired) lb.Invoke(clb, new object[]{message});
}
catch(Exception e)
{
message = e.Message;
}
finally
{
System.Diagnostics.Debug.WriteLine(message);
}
}
}
}

private void CreateClient(object message)
{
peerClient = new TcpClient();
peerClient.Connect(cmb.SelectedText, port);

netStream = peerClient.GetStream();

StreamWriter sw = new StreamWriter(netStream);
sw.Write((string)message);
sw.Flush();

peerClient.Close();
}

internal void Write(string message)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(CreateClient), message);
}

internal bool Enabled
{
set
{
if(t1.ThreadState==ThreadState.Suspended&&value==t rue)
{
t1.Resume();
}
else if(t1.ThreadState!=ThreadState.Suspended&&value==f alse)
{
t1.Suspend();
}
clientEnabled = value;
}
get
{
return clientEnabled;
}
}
}
}

You want more information see this url
Chat Application : Chat*«*Network*«*C# / C Sharp
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-24-2008, 04:50 AM
Manikandan.S Manikandan.S is offline
D-Web Trainee
 
Join Date: Feb 2008
Posts: 8
Manikandan.S is on a distinguished road
Wink Re: Chat Application

hi
It is good, but i need to chat options like in gmail.
if u have any examples pls tell to me
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/asp-asp-net-programming/5266-chat-application.html
Posted By For Type Date
DiscussWeb IT Community - Technical Support and Technology Discussions This thread Refback 03-24-2008 05:05 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Application has failed to start because the application configuration is incorrect kingmaker ASP and ASP.NET Programming 5 01-03-2008 03:18 AM
How to run a exe from a web application? a.deeban C# Programming 5 08-30-2007 02:54 AM
difference between client server application testing & web application testing vigneshgets Software Testing 1 07-27-2007 05:28 AM
PAT SERVER - Chat Application Karpagarajan PHP Programming 2 04-13-2007 03:07 AM
chat program pranky C and C++ Programming 0 02-24-2007 01:02 AM


All times are GMT -7. The time now is 06:47 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0