Преглед на файлове

Update documentation

master
achmizs преди 10 години
родител
ревизия
ba62ccdfc3
променени са 1 файла, в които са добавени 26 реда и са изтрити 11 реда
  1. 26
    11
      IRCClient/IRCClientSession.m

+ 26
- 11
IRCClient/IRCClientSession.m Целия файл

* License for more details. * License for more details.
*/ */


/********************************/
#pragma mark Defines and includes #pragma mark Defines and includes
/********************************/


#define IRCCLIENTVERSION "2.0a3" #define IRCCLIENTVERSION "2.0a3"


#import "IRCClientChannel_Private.h" #import "IRCClientChannel_Private.h"
#import "NSData+SA_NSDataExtensions.h" #import "NSData+SA_NSDataExtensions.h"


/********************************************/
#pragma mark - Callback function declarations #pragma mark - Callback function declarations
/********************************************/


static void onConnect(irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count); static void onConnect(irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count);
static void onNick(irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count); static void onNick(irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count);
static void onUnknownEvent(irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count); static void onUnknownEvent(irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count);
static void onNumericEvent(irc_session_t *session, unsigned int event, const char *origin, const char **params, unsigned int count); static void onNumericEvent(irc_session_t *session, unsigned int event, const char *origin, const char **params, unsigned int count);


/***********************************************************/
#pragma mark - IRCClientSession private category declaration #pragma mark - IRCClientSession private category declaration
/***********************************************************/


static NSDictionary* ircNumericCodeList; static NSDictionary* ircNumericCodeList;




@end @end


/***************************************************/
#pragma mark - IRCClientSession class implementation #pragma mark - IRCClientSession class implementation
/***************************************************/


@implementation IRCClientSession @implementation IRCClientSession


/********************************/
#pragma mark - Property synthesis #pragma mark - Property synthesis
/********************************/


@synthesize delegate = _delegate; @synthesize delegate = _delegate;
@synthesize sessionID = _sessionID; @synthesize sessionID = _sessionID;


@synthesize encoding = _encoding; @synthesize encoding = _encoding;


/******************************/
#pragma mark - Custom accessors #pragma mark - Custom accessors
/******************************/


-(NSDictionary*)channels
- (NSDictionary*)channels
{ {
NSDictionary* channelsCopy = [_channels copy]; NSDictionary* channelsCopy = [_channels copy];
return channelsCopy; return channelsCopy;
} }


-(void)setChannels:(NSDictionary *)channels
- (void)setChannels:(NSDictionary *)channels
{ {
_channels = [channels mutableCopy]; _channels = [channels mutableCopy];
} }
return irc_is_connected(_irc_session); return irc_is_connected(_irc_session);
} }


/************************************/
/***************************/
#pragma mark - Class methods #pragma mark - Class methods
/************************************/
/***************************/


-(instancetype)init
- (instancetype)init
{ {
if ((self = [super init])) {
if ((self = [super init]))
{
_callbacks.event_connect = onConnect; _callbacks.event_connect = onConnect;
_callbacks.event_nick = onNick; _callbacks.event_nick = onNick;
_callbacks.event_quit = onQuit; _callbacks.event_quit = onQuit;
return self; return self;
} }


-(void)dealloc
- (void)dealloc
{ {
if (irc_is_connected(_irc_session)) if (irc_is_connected(_irc_session))
{
NSLog(@"Warning: IRC Session is not disconnected on dealloc"); NSLog(@"Warning: IRC Session is not disconnected on dealloc");
}
irc_destroy_session(_irc_session); irc_destroy_session(_irc_session);
} }


+(NSDictionary *)ircNumericCodes
+ (NSDictionary *)ircNumericCodes
{ {
if(ircNumericCodeList == nil) if(ircNumericCodeList == nil)
{ {
return ircNumericCodeList; return ircNumericCodeList;
} }


+(void)loadNumericCodes
+ (void)loadNumericCodes
{ {
NSString* numericCodeListPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"IRC_Numerics" ofType:@"plist"]; NSString* numericCodeListPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"IRC_Numerics" ofType:@"plist"];
ircNumericCodeList = [NSDictionary dictionaryWithContentsOfFile:numericCodeListPath]; ircNumericCodeList = [NSDictionary dictionaryWithContentsOfFile:numericCodeListPath];
[_thread start]; [_thread start];
} }


-(int)setNickname:(NSData *)nickname username:(NSData *)username realname:(NSData *)realname
- (int)setNickname:(NSData *)nickname username:(NSData *)username realname:(NSData *)realname
{ {
if(self.isConnected) if(self.isConnected)
{ {

Loading…
Отказ
Запис