Переглянути джерело

Change the way nick/username/realname are set

Rather than have properties, setting which does nothing, we now
have readonly properties for nickname/username/realname, and a single
setter method, which may be called prior to the session connecting.
That way we won't have people setting the properties, and having the
properties then not reflecting the state of the connection!
master
achmizs 10 роки тому
джерело
коміт
06c7c487eb
2 змінених файлів з 30 додано та 10 видалено
  1. 13
    9
      IRCClient/IRCClientSession.h
  2. 17
    1
      IRCClient/IRCClientSession.m

+ 13
- 9
IRCClient/IRCClientSession.h Переглянути файл

@@ -102,22 +102,17 @@
/** Server password to provide on connect (may be left empty or nil) */
@property (copy) NSData *password;

/** Nickname of the connected client. Note that setting this after connection will
not result in the client renaming on IRC. You need to send a nick: message instead.
/** Nickname of the connected client.
*/
@property (copy) NSString *nickname;
@property (readonly) NSString *nickname;

/** Username of the connected client. Also known as the ident.
Setting this after connection does nothing.
*/
@property (copy) NSString *username;
@property (readonly) NSString *username;

/** Realname of the connected client.
Setting this after connection does nothing.
*/
@property (copy) NSString *realname;
@property (readonly) NSString *realname;

/** The default text encoding for messages on this server.
@@ -138,6 +133,15 @@
#pragma mark - Class methods
/***************************/

/** Set the nickname, username, and realname for the session.
Returns 1 if successfully set, 0 otherwise.
(0 is returned if you try to call this method after the session has
already connected; use the nick: method to attempt a nick change while
connected.)
*/
-(int)setNickname:(NSString *)nickname username:(NSString *)username realname:(NSString *)realname;

/** Connect to the IRC server.
Note that this performs the initial DNS lookup and the TCP connection, so if

+ 17
- 1
IRCClient/IRCClientSession.m Переглянути файл

@@ -19,7 +19,7 @@

#pragma mark Defines and includes

#define IRCCLIENTVERSION "2.0a1"
#define IRCCLIENTVERSION "2.0a2"

#import "IRCClientSession.h"
#import "IRCClientChannel.h"
@@ -190,6 +190,22 @@ static void onNumericEvent(irc_session_t *session, unsigned int event, const cha
[_thread start];
}

-(int)setNickname:(NSString *)nickname username:(NSString *)username realname:(NSString *)realname
{
if(self.isConnected)
{
return 0;
}
else
{
_nickname = nickname;
_username = username;
_realname = realname;
return 1;
}
}

/**************************/
#pragma mark - IRC commands
/**************************/

Завантаження…
Відмінити
Зберегти