浏览代码

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
/**************************/

正在加载...
取消
保存