本文整理汇总了Golang中github.com/twstrike/coyim/xmpp.RemoveResourceFromJid函数的典型用法代码示例。如果您正苦于以下问题:Golang RemoveResourceFromJid函数的具体用法?Golang RemoveResourceFromJid怎么用?Golang RemoveResourceFromJid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RemoveResourceFromJid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: receivedClientPresence
func (s *Session) receivedClientPresence(stanza *xmpp.ClientPresence) bool {
switch stanza.Type {
case "subscribe":
s.R.SubscribeRequest(stanza.From, either(stanza.ID, "0000"), s.GetConfig().ID())
s.publishPeerEvent(
SubscriptionRequest,
xmpp.RemoveResourceFromJid(stanza.From),
)
case "unavailable":
if !s.R.PeerBecameUnavailable(stanza.From) {
return true
}
s.publishEvent(PresenceEvent{
Session: s,
ClientPresence: stanza,
Gone: true,
})
case "":
if !s.R.PeerPresenceUpdate(stanza.From, stanza.Show, stanza.Status, s.GetConfig().ID()) {
return true
}
s.publishEvent(PresenceEvent{
Session: s,
ClientPresence: stanza,
Gone: false,
})
case "subscribed":
s.R.Subscribed(stanza.From)
s.publishPeerEvent(
Subscribed,
xmpp.RemoveResourceFromJid(stanza.From),
)
case "unsubscribe":
s.R.Unsubscribed(stanza.From)
s.publishPeerEvent(
Unsubscribe,
xmpp.RemoveResourceFromJid(stanza.From),
)
case "unsubscribed":
// Ignore
case "error":
s.warn(fmt.Sprintf("Got a presence error from %s: %#v\n", stanza.From, stanza.Error))
s.R.LatestError(stanza.From, stanza.Error.Code, stanza.Error.Type, stanza.Error.Any.Space+" "+stanza.Error.Any.Local)
default:
s.info(fmt.Sprintf("unrecognized presence: %#v", stanza))
}
return true
}
开发者ID:PMaynard,项目名称:coyim,代码行数:50,代码来源:session.go
示例2: handlePresenceEvent
func (c *cliUI) handlePresenceEvent(ev session.PresenceEvent) {
if ev.Session.GetConfig().HideStatusUpdates {
return
}
from := xmpp.RemoveResourceFromJid(ev.From)
var line []byte
line = append(line, []byte(fmt.Sprintf(" (%s) ", time.Now().Format(time.Kitchen)))...)
line = append(line, c.term.Escape.Magenta...)
line = append(line, []byte(from)...)
line = append(line, ':')
line = append(line, c.term.Escape.Reset...)
line = append(line, ' ')
if ev.Gone {
line = append(line, []byte("offline")...)
} else if len(ev.Show) > 0 {
line = append(line, []byte(ev.Show)...)
} else {
line = append(line, []byte("online")...)
}
line = append(line, ' ')
line = append(line, []byte(ev.Status)...)
line = append(line, '\n')
c.term.Write(line)
}
开发者ID:PMaynard,项目名称:coyim,代码行数:27,代码来源:session_events.go
示例3: processClientMessage
func (s *Session) processClientMessage(stanza *xmpp.ClientMessage) {
log.Printf("-> Stanza %#v\n", stanza)
from := xmpp.RemoveResourceFromJid(stanza.From)
//TODO: investigate which errors are recoverable
//https://xmpp.org/rfcs/rfc3920.html#stanzas-error
if stanza.Type == "error" && stanza.Error != nil {
s.alert(fmt.Sprintf("Error reported from %s: %#v", from, stanza.Error))
return
}
//TODO: Add a more general solution to XEP's
if len(stanza.Body) == 0 && len(stanza.Extensions) > 0 {
//Extension only stanza
return
}
var err error
var messageTime time.Time
if stanza.Delay != nil && len(stanza.Delay.Stamp) > 0 {
// An XEP-0203 Delayed Delivery <delay/> element exists for
// this message, meaning that someone sent it while we were
// offline. Let's show the timestamp for when the message was
// sent, rather than time.Now().
messageTime, err = time.Parse(time.RFC3339, stanza.Delay.Stamp)
if err != nil {
s.alert("Can not parse Delayed Delivery timestamp, using quoted string instead.")
}
} else {
messageTime = time.Now()
}
s.receiveClientMessage(from, messageTime, stanza.Body)
}
开发者ID:0x27,项目名称:coyim,代码行数:35,代码来源:session.go
示例4: peerWithPendingSubscribe
func peerWithPendingSubscribe(jid, id, belongsTo string) *Peer {
return &Peer{
Jid: xmpp.RemoveResourceFromJid(jid),
PendingSubscribeID: id,
BelongsTo: belongsTo,
}
}
开发者ID:0x27,项目名称:coyim,代码行数:7,代码来源:peer.go
示例5: PeerWithState
// PeerWithState returns a new Peer that contains the given state information
func PeerWithState(jid, status, statusMsg, belongsTo string) *Peer {
return &Peer{
Jid: xmpp.RemoveResourceFromJid(jid),
Status: status,
StatusMsg: statusMsg,
Online: true,
BelongsTo: belongsTo,
}
}
开发者ID:0x27,项目名称:coyim,代码行数:10,代码来源:peer.go
示例6: PeerFrom
// PeerFrom returns a new Peer that contains the same information as the RosterEntry given
func PeerFrom(e xmpp.RosterEntry, belongsTo string) *Peer {
return &Peer{
Jid: xmpp.RemoveResourceFromJid(e.Jid),
Subscription: e.Subscription,
Name: e.Name,
Groups: toSet(e.Group...),
BelongsTo: belongsTo,
}
}
开发者ID:0x27,项目名称:coyim,代码行数:10,代码来源:peer.go
示例7: Remove
// Remove returns the Peer with the jid from the List - it will first turn the jid into a bare jid.
// It returns true if it could remove the entry and false otherwise. It also returns the removed entry.
func (l *List) Remove(jid string) (*Peer, bool) {
j := xmpp.RemoveResourceFromJid(jid)
if v, ok := l.peers[j]; ok {
delete(l.peers, j)
return v, true
}
return nil, false
}
开发者ID:PMaynard,项目名称:coyim,代码行数:12,代码来源:list.go
示例8: importPeerPrefsPidginStyle
func importPeerPrefsPidginStyle(f string) (map[string]map[string]*pidginOTRSettings, bool) {
content, err := ioutil.ReadFile(f)
if err != nil {
return nil, false
}
var a pidginBlistXML
err = xml.Unmarshal(content, &a)
if err != nil {
return nil, false
}
res := make(map[string]map[string]*pidginOTRSettings)
for _, p := range a.Peers {
if p.Protocol == "prpl-jabber" {
haveOTR := false
settings := &pidginOTRSettings{}
for _, s := range p.Settings {
switch s.Name {
case "OTR/enabled":
haveOTR = true
settings.enabled = s.Value == "1"
case "OTR/automatic":
haveOTR = true
settings.automatic = s.Value == "1"
case "OTR/avoidloggingotr":
haveOTR = true
settings.avoidLoggingOTR = s.Value == "1"
case "OTR/onlyprivate":
haveOTR = true
settings.onlyPrivate = s.Value == "1"
}
}
if haveOTR {
getOrMake(res, xmpp.RemoveResourceFromJid(p.Account))[xmpp.RemoveResourceFromJid(p.Name)] = settings
}
}
}
return res, true
}
开发者ID:PMaynard,项目名称:coyim,代码行数:43,代码来源:pidgin_like.go
示例9: ShouldEncryptTo
// ShouldEncryptTo returns true if the connection with this peer should be encrypted
func (a *Account) ShouldEncryptTo(jid string) bool {
if a.AlwaysEncrypt {
return true
}
bareJid := xmpp.RemoveResourceFromJid(jid)
for _, contact := range a.AlwaysEncryptWith {
if contact == bareJid {
return true
}
}
return false
}
开发者ID:0x27,项目名称:coyim,代码行数:15,代码来源:account.go
示例10: handleMessageEvent
func (u *gtkUI) handleMessageEvent(ev session.MessageEvent) {
account := u.findAccountForSession(ev.Session)
if account == nil {
//TODO error
return
}
u.roster.messageReceived(
account,
xmpp.RemoveResourceFromJid(ev.From),
ev.When,
ev.Encrypted,
ev.Body,
)
}
开发者ID:PMaynard,项目名称:coyim,代码行数:15,代码来源:account_events.go
示例11: PeerFrom
// PeerFrom returns a new Peer that contains the same information as the RosterEntry given
func PeerFrom(e xmpp.RosterEntry, conf *config.Account) *Peer {
belongsTo := conf.ID()
var nickname string
p, ok := conf.GetPeer(e.Jid)
if ok {
nickname = p.Nickname
}
return &Peer{
Jid: xmpp.RemoveResourceFromJid(e.Jid),
Subscription: e.Subscription,
Name: e.Name,
Nickname: nickname,
Groups: toSet(e.Group...),
BelongsTo: belongsTo,
}
}
开发者ID:PMaynard,项目名称:coyim,代码行数:17,代码来源:peer.go
示例12: importAccountsPidginStyle
func importAccountsPidginStyle(f string) (map[string]*config.Account, bool) {
content, err := ioutil.ReadFile(f)
if err != nil {
return nil, false
}
var a pidginAccountsXML
err = xml.Unmarshal(content, &a)
if err != nil {
return nil, false
}
res := make(map[string]*config.Account)
for _, ac := range a.Accounts {
if ac.Protocol == "prpl-jabber" {
nm := xmpp.RemoveResourceFromJid(ac.Name)
a := &config.Account{}
a.Account = nm
a.Password = ac.Password
settings := ac.settingsAsMap()
a.Port = parseIntOr(settings["port"], 5222)
a.Proxies = make([]string, 0)
for _, px := range ac.Proxy {
if px.Type == "tor" {
a.RequireTor = true
}
a.Proxies = append(a.Proxies,
composeProxyString(px.Type, px.Username, px.Password, px.Host, strconv.Itoa(px.Port)),
)
}
if settings["connect_server"] != "" {
a.Server = settings["connect_server"]
}
if strings.HasSuffix(a.Server, ".onion") {
a.RequireTor = true
}
res[nm] = a
}
}
return res, true
}
开发者ID:PMaynard,项目名称:coyim,代码行数:46,代码来源:pidgin_like.go
示例13: handlePresenceEvent
func (u *gtkUI) handlePresenceEvent(ev session.PresenceEvent) {
if ev.Session.GetConfig().HideStatusUpdates {
return
}
log.Printf("[%s] Presence from %v: show: %v status: %v gone: %v\n", ev.To, ev.From, ev.Show, ev.Status, ev.Gone)
u.rosterUpdated()
account := u.findAccountForSession(ev.Session)
if account == nil {
return
}
u.roster.presenceUpdated(
account,
xmpp.RemoveResourceFromJid(ev.From),
ev.Show,
ev.Status,
ev.Gone,
)
}
开发者ID:PMaynard,项目名称:coyim,代码行数:21,代码来源:account_events.go
示例14: Is
// Is returns true if this account represents the same identity as the given JID
func (a *Account) Is(jid string) bool {
return a.Account == xmpp.RemoveResourceFromJid(jid)
}
开发者ID:0x27,项目名称:coyim,代码行数:4,代码来源:account.go
示例15: Get
// Get returns the peer if it's known and false otherwise
func (l *List) Get(jid string) (*Peer, bool) {
v, ok := l.peers[xmpp.RemoveResourceFromJid(jid)]
return v, ok
}
开发者ID:PMaynard,项目名称:coyim,代码行数:5,代码来源:list.go
注:本文中的github.com/twstrike/coyim/xmpp.RemoveResourceFromJid函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论