Add reconnect
This commit is contained in:
parent
1160ab4f58
commit
82d1050496
11
irc.go
11
irc.go
@ -201,9 +201,18 @@ func (irc *IRCConnection) Privmsg(target, message string) {
|
|||||||
irc.pwrite <- fmt.Sprintf("PRIVMSG %s :%s\r\n", target, message)
|
irc.pwrite <- fmt.Sprintf("PRIVMSG %s :%s\r\n", target, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Try to reconnect
|
||||||
|
func (irc *IRCConnection) Reconnect() os.Error {
|
||||||
|
irc.socket, irc.Error = net.Dial("tcp", "", irc.server);
|
||||||
|
if irc.Error != nil {
|
||||||
|
return irc.Error
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
func IRC(server string, nick string, user string, events chan *IRCEvent) (*IRCConnection, os.Error) {
|
func IRC(server string, nick string, user string, events chan *IRCEvent) (*IRCConnection, os.Error) {
|
||||||
irc := new(IRCConnection);
|
irc := new(IRCConnection);
|
||||||
|
irc.server = server;
|
||||||
irc.socket, irc.Error = net.Dial("tcp", "", server);
|
irc.socket, irc.Error = net.Dial("tcp", "", server);
|
||||||
if irc.Error != nil {
|
if irc.Error != nil {
|
||||||
return nil, irc.Error
|
return nil, irc.Error
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type IRCEventCode int
|
type IRCEventCode int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
IRC_NOTICE_AUTH IRCEventCode = 1 << iota;
|
IRC_NOTICE_AUTH IRCEventCode = 1 << iota;
|
||||||
IRC_PING;
|
IRC_PING;
|
||||||
@ -49,9 +50,10 @@ type IRCConnection struct {
|
|||||||
perror chan os.Error;
|
perror chan os.Error;
|
||||||
EventChan chan *IRCEvent;
|
EventChan chan *IRCEvent;
|
||||||
Error os.Error;
|
Error os.Error;
|
||||||
nick string;
|
nick string;
|
||||||
user string;
|
user string;
|
||||||
registered bool;
|
registered bool;
|
||||||
|
server string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type IRCEvent struct {
|
type IRCEvent struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user