本文整理汇总了Golang中kevlar/ircd/parser.Message.Prefix方法的典型用法代码示例。如果您正苦于以下问题:Golang Message.Prefix方法的具体用法?Golang Message.Prefix怎么用?Golang Message.Prefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kevlar/ircd/parser.Message
的用法示例。
在下文中一共展示了Message.Prefix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: manageClients
func (s *IRCd) manageClients() {
defer s.running.Done()
uid2conn := make(map[string]*conn.Conn)
var open bool = true
var msg *parser.Message
for open {
// anything to do here?
select {
//// Incoming and outgoing messages to and from clients
// Messages directly from connections
// TODO(kevlar): Collapse into one case (I don't like that server gets split)
case msg = <-s.fromClient:
u := user.Get(msg.SenderID)
uid := u.ID()
if msg.Command == parser.CMD_ERROR {
user.Delete(uid)
conn := uid2conn[uid]
if conn != nil {
log.Debug.Printf("[%s] ** Connection terminated remotely", uid)
user.Delete(uid)
uid2conn[uid] = nil, false
conn.UnsubscribeClose(s.clientClosing)
conn.Close()
}
continue
}
log.Debug.Printf("[%s] >> %s", uid, msg)
DispatchClient(msg, s)
// Messages from hooks
case msg, open = <-s.ToClient:
// Handle internal messages
switch msg.Command {
case parser.INT_DELUSER:
// This is sent over the channel to ensure that all user messages
// which may need to query these UIDs are sent before they are
// removed.
for _, uid := range msg.DestIDs {
log.Debug.Printf("[%s] Netsplit", uid)
user.Delete(uid)
}
continue
}
// Count the number of messages sent
sentcount := 0
// For simplicity, * in the prefix or as the first argument
// is replaced by the nick of the user the message is sent to
setnick := len(msg.Args) > 0 && msg.Args[0] == "*"
setprefix := msg.Prefix == "*"
closeafter := false
if msg.Command == parser.CMD_ERROR {
// Close the connection and remove the prefix if we are sending an ERROR
closeafter = true
msg.Prefix = ""
} else if len(msg.Prefix) == 0 {
// Make sure a prefix is specified (use the server name)
msg.Prefix = Config.Name
}
local := make([]string, 0, len(msg.DestIDs))
remote := make([]string, 0, len(msg.DestIDs))
for _, id := range msg.DestIDs {
if id[:3] != Config.SID {
remote = append(remote, id)
continue
}
local = append(local, id)
}
// Pass the message to the server goroutine
if len(remote) > 0 {
if closeafter {
for _, id := range remote {
user.Delete(id)
}
} else {
log.Warn.Printf("Dropping non-local: %s", len(remote), msg)
}
// Short circuit if there are no local recipients
if len(local) == 0 {
continue
}
}
// Examine all arguments for UIDs and replace them
if isuid(msg.Prefix) {
nick, user, _, _, ok := user.GetInfo(msg.Prefix)
if !ok {
log.Warn.Printf("Nonexistent ID %s as prefix", msg.Prefix)
} else {
//.........这里部分代码省略.........