Primus-Emitter-Objc 是用于 Primus 实时框架的 Primus-Emitter 插件的实现。
该库完全使用 Specta、Expecta 和 OCMockito 进行单元测试。
pod 'PrimusEmitter'
#import <PrimusEmitter/PrimusEmitter.h>
- (void)start
{
// By emitting an event on the server-side, the following listener will fire
[primus on:@"custom:event:here", ^{
NSLog(@"Received custom event");
}];
// The last parameter is a block that you can execute to acknowlege the event
[primus on:@"another:example", ^(AckBlock ack) {
NSLog(@"Received another event. Calling callback...");
ack();
}];
}
非常感谢 Jonathan Brumley,原始 primus-emitter 插件的创建者。