|
-
Sep 1st, 2005, 11:44 PM
#1
Thread Starter
PowerPoster
serious problems! (protocols?)
Hmmmmmmm
Thought I would re-write my application since it was done entirely in 1 class file.. thought I would make it more OO and make it more maintainable than what it already was
The way my app works is:
Connect to destination
Recieve confirmation of connections (DataManager Class handles incoming comms)
Proceed with other stuff.
Now, when it is "receiving" data... it executes it in a different thread on its own.
New Class files created:
ConnectionManager (manages connections)
CommunicationManager (manages communication, outgoing and incoming)
IncomingDataManager (manages incoming data (decodes byte etc...))
I then have a main form from which the class(es) are instantiated.
Before having these 3 classes, it was all in 1 class file and worked fine
Problem I am having is that when the server sends a message back like "ok, your connected) .... the IncomingDataClass does not seem to "run", it instantiates it fine but when I put a breakpoint on the method that handles the incoming data, nothing happens.
When Recieving data in the new thread, it seems to go into that and execute. This is what my CommunicationManager class file has:
Code:
public void ListenToPort()
{
while (this.theConnectionManager.IsConnectedToServer)
{
if (this.theNetworkStream.DataAvailable)
{
byte[] theIncomingDataBuffer = new byte[this.theLengthOfBytesIncomingData];
int theData = this.theNetworkStream.Read(theIncomingDataBuffer, 0, theIncomingDataBuffer.Length);
this.theDataManager.HandleIncomingData(theIncomingDataBuffer);
}
//Thread.Sleep(4);
}
}
The Incoming Data Manager is instantiated when the Communication Class has been instantiated (through constructor) and both seem to instantiate fine.
I do not understand why, when incoming data is arriving, the Recieve() OR data manager do not pick it or handle with it.
anyone have any ideas? perhaps you need more info?
-
Sep 2nd, 2005, 12:05 AM
#2
Thread Starter
PowerPoster
Re: serious problems! (protocols?)
nevermind sorted it. stupid mistake.. forgot to set the bool value to true....
-
Sep 2nd, 2005, 12:15 AM
#3
Re: serious problems! (protocols?)
Who's not resolving their threads, 'ey?
-
Sep 2nd, 2005, 02:48 AM
#4
Thread Starter
PowerPoster
Re: serious problems! (protocols?)
ok heres an interesting one! 
for some reason when the server sends some data in a large amount, the entire app just freezes (this is on mobile development btw.. but should not be different)
however when I did this before making the code more maintainable/more OO'd - it worked perfect
Code:
while (this.theConnectionManager.IsConnectedToServer)
{
if (this.theNetworkStream.DataAvailable && this.theNetworkStream.CanRead)
{
byte[] theIncomingDataBuffer = new byte[this.theLengthOfBytesIncomingData];
int theData = this.theNetworkStream.Read(theIncomingDataBuffer, 0, theIncomingDataBuffer.Length);
this.theDataManager.HandleIncomingData(theIncomingDataBuffer);
}
Thread.Sleep(4);
}
it seems to pick up everything else but the last command the server sends...
[edit]INTERESTING! when I comment out the method to disable all controls on the form.... it works fine!! but when I put it back in, it hangs the app....why?[/edit]
Last edited by Techno; Sep 2nd, 2005 at 03:13 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|