• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
socket & refresh
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

socket & refresh


  • Subject: socket & refresh
  • From: Joe Maffia <email@hidden>
  • Date: Sat, 12 Feb 2005 10:35:50 +0100

Sorry for another message of the same argument...

My app is more similar to PictureSharing & PictureSharingBrowser that you can find on:

http://developer.apple.com/samplecode/PictureSharing/PictureSharing.html
http://developer.apple.com/samplecode/PictureSharingBrowser/PictureSharingBrowser.html

the difference is that my app don't share an images but the desktop of another user found on rendezvous...simply share a snapshot.

Now I want to render this snapshot dinamic... like a RemoteDesktop, a sort of refresh of the snapshot.

I implemented a NSTimer that call a refresh metod like this:

- (void)awakeFromNib
{
// Setup a three-second timer than calls 'refresh:'.
// The 'timer' should be an NSTimer instance variable.


timer = [[NSTimer scheduledTimerWithTimeInterval:3.0
target:self selector:@selector(refresh:)
userInfo:nil repeats:YES] retain];
}

- (void)dealloc
{
[timer invalidate]; // Stop the Timer
[timer release]; // Release the Timer
[super dealloc];
}

- (id)sender
{
socketToRemoteServer = socket(AF_INET, SOCK_STREAM, 0);

if(socketToRemoteServer > 0) {
NSFileHandle * remoteConnection = [[NSFileHandle alloc] initWithFileDescriptor:socketToRemoteServer closeOnDealloc:YES];

if(remoteConnection) {
NSLog( @"notifica" );
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(readAllTheData:) name:NSFileHandleReadToEndOfFileCompletionNotification object:remoteConnection];

if(connect(socketToRemoteServer, (struct sockaddr *)socketAddress, sizeof(*socketAddress)) == 0) {
[remoteConnection readToEndOfFileInBackgroundAndNotify];
}
} else {
close(socketToRemoteServer);
}
}
}


as you seen the problem is that refresh: always reconnect with socket etc. etc. (so my app take also the 70% of CPU) but this is the only way that I have found to obtain a new shot and view on my NSImageView.

I don't know how to resolve this... if anyone want I can send the code.

Thanks!

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: NSTextView scrolling behavior (follow up)
  • Next by Date: Re: Loading NIB file from forked process
  • Previous by thread: Re: NSTextView scrolling behavior (follow up)
  • Next by thread: accessing AddressBook.data
  • Index(es):
    • Date
    • Thread