I have a connection between iPod client and C server.
I can send the data of the slider as I move the slider, and get the data on the server correctly. Only problem is the blue point of the slider doesn’t move, nor does the label under it change the slider’s value. When I disconnect, the blue point moves to the point it should be and the label shows its value. Here are the codes:
-(void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent
{
switch (streamEvent)
{
case NSStreamEventHasSpaceAvailable:
event = @"NSStreamEventHasSpaceAvailable";
connectButton.enabled = NO;
disconnectButton.enabled = YES;
if (theStream == oStream)
{
//send data
const uint8_t *buffer = (const uint8_t *)[dataSlider UTF8String];
NSInteger err = [self writeToServer:buffer];
if ( err == -1)
NSLog(@"Error sending data.");
else
NSLog(@"Success sending data.");
}
break;
}
- (IBAction)sliderChanged:(id)sender
{
UISlider *slider = (UISlider *)sender;
progressAsInt = (int)(slider.value + 0.5f);
sliderValue = [[NSString alloc] initWithFormat:@"%d", progressAsInt];
sliderLabel.text = sliderValue;
dataSlider = sliderValue;
}
This is the way it should work: the server is always asking for something to printf. I move the slider and send its value, whenever the server calls read().
Problem: the slider doesn’t visually move, but its value changes (i can see it in the server’s printfs).
Any thoughts?
Seems that the constant “knowing that the stream had space available” was clogging the program and UI. I changed the flow of the program to wait for a message from the sever and only after that it would send the data. Here it is: