sever is not displaying the content that " you have left the chat room"....
-
I'm just attempting to form a mind meld with your source code... Nope, it's not working. Please go to Visual Studio menu: "Tools...Options...Source Control...Plug In selection" and enable "Vulcan SCMM" module. Oh, and don't close VS or turn your computer off! Alternatively, post a relevant code fragment here, and save us all that mental effort.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
OriginalGriff wrote:
Alternatively, post a relevant code fragment here, and save us all that mental effort.
here is the code for server.
using System;
using System.Threading;
using System.Net.Sockets;
using System.Text;
using System.Collections;namespace ConsoleApplication1
{
class Program
{
public static Hashtable clientsList = new Hashtable();static void Main(string\[\] args) { TcpListener serverSocket = new TcpListener(6050); TcpClient clientSocket = default(TcpClient); int counter = 0; serverSocket.Start(); Console.WriteLine("Chat Server Started ...."); DateTime currentSystemTime = DateTime.Now; Console.WriteLine(currentSystemTime); DateTime startTime = DateTime.Now; counter = 0; while ((true)) { counter += 1; clientSocket = serverSocket.AcceptTcpClient(); byte\[\] bytesFrom = new byte\[10025\]; string dataFromClient = null; string dataToClient=null; string temp = null; ; NetworkStream networkStream = clientSocket.GetStream(); networkStream.Read(bytesFrom, 0, (int)clientSocket.ReceiveBufferSize); temp = System.Text.Encoding.ASCII.GetString(bytesFrom); dataToClient = temp.Substring(temp.IndexOf("$") + 1, (temp.IndexOf("%") - temp.IndexOf("$") - 1)); dataFromClient = temp.Substring(0, temp.IndexOf("$")); clientsList.Add(dataFromClient, clientSocket); //broadcast(dataFromClient + " Joined ", dataFromClient, false,dataToClient,dataFromClient); Console.WriteLine(dataFromClient + " Joined chat room "); DateTime currentSystemTime1 = DateTime.Now; Console.WriteLine(currentSystemTime1); handleClinet client = new handleClinet(); client.startClient(clientSocket, dataFromClient, clientsList); } //clientSocket.Close(); //serverSocket.Stop(); //Console.WriteLine("exit"); //DateTime stopTime = DateTime.Now; //Console.WriteLine(stopTime); /\* Compute the duration between the initial and the end time. \*/ //TimeSpan duration = stopTime - startT
-
OriginalGriff wrote:
Alternatively, post a relevant code fragment here, and save us all that mental effort.
here is the code for server.
using System;
using System.Threading;
using System.Net.Sockets;
using System.Text;
using System.Collections;namespace ConsoleApplication1
{
class Program
{
public static Hashtable clientsList = new Hashtable();static void Main(string\[\] args) { TcpListener serverSocket = new TcpListener(6050); TcpClient clientSocket = default(TcpClient); int counter = 0; serverSocket.Start(); Console.WriteLine("Chat Server Started ...."); DateTime currentSystemTime = DateTime.Now; Console.WriteLine(currentSystemTime); DateTime startTime = DateTime.Now; counter = 0; while ((true)) { counter += 1; clientSocket = serverSocket.AcceptTcpClient(); byte\[\] bytesFrom = new byte\[10025\]; string dataFromClient = null; string dataToClient=null; string temp = null; ; NetworkStream networkStream = clientSocket.GetStream(); networkStream.Read(bytesFrom, 0, (int)clientSocket.ReceiveBufferSize); temp = System.Text.Encoding.ASCII.GetString(bytesFrom); dataToClient = temp.Substring(temp.IndexOf("$") + 1, (temp.IndexOf("%") - temp.IndexOf("$") - 1)); dataFromClient = temp.Substring(0, temp.IndexOf("$")); clientsList.Add(dataFromClient, clientSocket); //broadcast(dataFromClient + " Joined ", dataFromClient, false,dataToClient,dataFromClient); Console.WriteLine(dataFromClient + " Joined chat room "); DateTime currentSystemTime1 = DateTime.Now; Console.WriteLine(currentSystemTime1); handleClinet client = new handleClinet(); client.startClient(clientSocket, dataFromClient, clientsList); } //clientSocket.Close(); //serverSocket.Stop(); //Console.WriteLine("exit"); //DateTime stopTime = DateTime.Now; //Console.WriteLine(stopTime); /\* Compute the duration between the initial and the end time. \*/ //TimeSpan duration = stopTime - startT
No - not going to look at that either! Try changing the "inline code" to "code block" it preserves the formatting. Inline code:
if (dataFromClient == "listClients") { dataFromClient = ""; foreach (DictionaryEntry Item in clientsList) { dataFromClient += Item.Key + "---" + ((TcpClient)Item.Value).Client.RemoteEndPoint.ToString() + "+++"; } dataToClient = clNo; }
Code block:if (dataFromClient == "listClients")
{
dataFromClient = "";foreach (DictionaryEntry Item in clientsList)
{
dataFromClient += Item.Key + "---" + ((TcpClient)Item.Value).Client.RemoteEndPoint.ToString() + "+++";
}dataToClient = clNo;
}See what I mean? You can get away with it for a couple of lines, but with a whole class it is way too much effort to read!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
No - not going to look at that either! Try changing the "inline code" to "code block" it preserves the formatting. Inline code:
if (dataFromClient == "listClients") { dataFromClient = ""; foreach (DictionaryEntry Item in clientsList) { dataFromClient += Item.Key + "---" + ((TcpClient)Item.Value).Client.RemoteEndPoint.ToString() + "+++"; } dataToClient = clNo; }
Code block:if (dataFromClient == "listClients")
{
dataFromClient = "";foreach (DictionaryEntry Item in clientsList)
{
dataFromClient += Item.Key + "---" + ((TcpClient)Item.Value).Client.RemoteEndPoint.ToString() + "+++";
}dataToClient = clNo;
}See what I mean? You can get away with it for a couple of lines, but with a whole class it is way too much effort to read!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
No - not going to look at that either! Try changing the "inline code" to "code block" it preserves the formatting. Inline code:
if (dataFromClient == "listClients") { dataFromClient = ""; foreach (DictionaryEntry Item in clientsList) { dataFromClient += Item.Key + "---" + ((TcpClient)Item.Value).Client.RemoteEndPoint.ToString() + "+++"; } dataToClient = clNo; }
Code block:if (dataFromClient == "listClients")
{
dataFromClient = "";foreach (DictionaryEntry Item in clientsList)
{
dataFromClient += Item.Key + "---" + ((TcpClient)Item.Value).Client.RemoteEndPoint.ToString() + "+++";
}dataToClient = clNo;
}See what I mean? You can get away with it for a couple of lines, but with a whole class it is way too much effort to read!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
Ok, well done! It is now readable. Did you mean you don't get the "You have left the session" message in the Disconnect method? If so, then it would probably help to reference it at some point. At present, it just sits there, feeling lonely and unwanted as nobody calls it. All you do is sit in a pair of loops - one in main where you try top start threads like crazy, and the other in doChat where you loop until an error occurs, print the error, and then loop some more. I think you need to sit down and look at what you are trying to achieve in a lot more detail, and then try to start again from scratch. BTW: Look at your errors listing when you compile this - you are getting a warning that TcpLister(int) is obsolete - take note of warnings, there aren't there for fun!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
Ok, well done! It is now readable. Did you mean you don't get the "You have left the session" message in the Disconnect method? If so, then it would probably help to reference it at some point. At present, it just sits there, feeling lonely and unwanted as nobody calls it. All you do is sit in a pair of loops - one in main where you try top start threads like crazy, and the other in doChat where you loop until an error occurs, print the error, and then loop some more. I think you need to sit down and look at what you are trying to achieve in a lot more detail, and then try to start again from scratch. BTW: Look at your errors listing when you compile this - you are getting a warning that TcpLister(int) is obsolete - take note of warnings, there aren't there for fun!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
OriginalGriff wrote:
you are getting a warning that TcpLister(int) is obsolete
OriginalGriff wrote:
it just sits there, feeling lonely and unwanted as nobody calls it.
Maybe some of the code has fled before, while you were practicing your mind melting voodoo. :laugh:
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
OriginalGriff wrote:
you are getting a warning that TcpLister(int) is obsolete
OriginalGriff wrote:
it just sits there, feeling lonely and unwanted as nobody calls it.
Maybe some of the code has fled before, while you were practicing your mind melting voodoo. :laugh:
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
I thought I was safe - aren't you off playing chess? :laugh:
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
I thought I was safe - aren't you off playing chess? :laugh:
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
No one is ever safe from my bot brothers and sisters, and no, you won't be able to tell us apart. But you're right, Luc is at the tournament as we speak. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
No one is ever safe from my bot brothers and sisters, and no, you won't be able to tell us apart. But you're right, Luc is at the tournament as we speak. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
If I can't tell the difference between the brothers and the sisters, I do not want to meet the family!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
Ok, well done! It is now readable. Did you mean you don't get the "You have left the session" message in the Disconnect method? If so, then it would probably help to reference it at some point. At present, it just sits there, feeling lonely and unwanted as nobody calls it. All you do is sit in a pair of loops - one in main where you try top start threads like crazy, and the other in doChat where you loop until an error occurs, print the error, and then loop some more. I think you need to sit down and look at what you are trying to achieve in a lot more detail, and then try to start again from scratch. BTW: Look at your errors listing when you compile this - you are getting a warning that TcpLister(int) is obsolete - take note of warnings, there aren't there for fun!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.