2014-11-29 2 views
0

bitstamp.com에서 실시간 비트 동전 환율을위한 OS X (10.10) 클라이언트를 구현하려고합니다. 그들은 훌륭한 API를 제공합니다, 불행히도 OS X Objective C app에서 작동하는 websocket API (https://www.bitstamp.net/websocket/)를 얻을 수 없습니다.libPusher가 푸시를받지 못합니다 (obj c)

누구나 나를 libPusher Github 프로젝트 (https://github.com/lukeredpath/libPusher)로 가리키고 있지만 문자 그대로 생각할 수있는 모든 것을 시도했지만, 10.10에 영향을 미칠 수는 없습니다.

wiki page 다음에 미리 컴파일 된 정적 라이브러리를 다운로드하고 모든 파일을 내 프로젝트에 끌어 왔으며 ("복사"확인란을 선택했는지 확인) 샘플 응용 프로그램이 컴파일됩니다. 불행히도 콘솔에서 "블록을 통한 이벤트"또는 "대리인을 통한 이벤트"를 전혀 볼 수 없습니다. 그러나 나는 그 거래가 그 당시에 일어났기 때문에 그 문제가 될 수 없다는 것을 안다. 어떤 아이디어?

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 
// Insert code here to initialize your application 
PTPusher* client = [PTPusher pusherWithKey:@"de504dc5763aeef9ff52" delegate:self encrypted:YES]; 

[client connect]; 

PTPusherChannel *channel = [client subscribeToChannelNamed:@"live_trades"]; 

[channel bindToEventNamed:@"trade" handleWithBlock:^(PTPusherEvent *channelEvent) { 
    // channelEvent.data is a NSDictionary of the JSON object received 
    NSLog(@"event through block"); // <-- never called 
}]; 

[[NSNotificationCenter defaultCenter] 
addObserver:self 
selector:@selector(didReceiveEventNotification:) 
name:PTPusherEventReceivedNotification 
object:client]; 

[[NSNotificationCenter defaultCenter] 
addObserver:self 
selector:@selector(didReceiveChannelEventNotification:) 
name:PTPusherEventReceivedNotification 
object:channel]; 

} 

- (void)didReceiveEventNotification:(NSNotification *)notification // <-- never called 
{ 
    NSLog(@"event through delegate"); 
    PTPusherEvent *event = [notification.userInfo objectForKey:PTPusherEventUserInfoKey]; 
} 
+0

연결이 발생합니까? [확인 방법은이 예제]를 참조하십시오 (https://github.com/lukeredpath/libPusher/blob/master/Sample/Classes/PusherEventsAppDelegate.m#L75). – leggetter

답변

0

개발자에게 이야기 한 후 내가 문제가 발견 : 내 코드에서

을의 PTPusher 인스턴스가하는 .m 파일에 정의 된 지역 변수입니다. 는 그러나, .H 파일에 정의 된 강력한 변수가 될 필요가있다 (!을 합성하는 것을 잊지 마세요)

@property (strong) PTPusher* client; 

그런 다음하는 .m 파일에서 쉽게 사용할 수 있습니다 :

self.client = [PTPusher pusherWithKey:@"de504dc5763aeef9ff52" delegate:self encrypted:YES]; 

[self.client connect]; 

[[NSNotificationCenter defaultCenter] 
addObserver:self 
selector:@selector(didReceiveEventNotification:) 
name:PTPusherEventReceivedNotification 
object:self.client]; 

PTPusherChannel *channel = [client subscribeToChannelNamed:@"live_trades"];