本文整理汇总了Golang中github.com/tinode/chat/server/store/types.Subscription.GetPublic方法的典型用法代码示例。如果您正苦于以下问题:Golang Subscription.GetPublic方法的具体用法?Golang Subscription.GetPublic怎么用?Golang Subscription.GetPublic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tinode/chat/server/store/types.Subscription
的用法示例。
在下文中一共展示了Subscription.GetPublic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: topicInit
//.........这里部分代码省略.........
if len(subs) == 0 {
log.Println("hub: missing both subscriptions for '" + t.name + "' (SHOULD NEVER HAPPEN!)")
sreg.sess.queueOut(ErrUnknown(sreg.pkt.Id, t.name, timestamp))
return
}
t.created = stopic.CreatedAt
t.updated = stopic.UpdatedAt
t.lastId = stopic.SeqId
}
// t.owner is blank for p2p topics
// Ensure that other users are automatically rejected
t.accessAuth = types.ModeP2P
t.accessAnon = types.ModeBanned
// t.public is not used for p2p topics since each user get a different public
// Custom default access levels set in sreg.pkt.Init.DefaultAcs are ignored
if stopic != nil && len(subs) == 2 {
// Case 4.
log.Println("hub: existing p2p topic")
// t.clearId is not used in P2P topics, may change later
for i := 0; i < 2; i++ {
uid := types.ParseUid(subs[i].User)
t.perUser[uid] = perUserData{
// Adapter already swapped the public values
public: subs[i].GetPublic(),
private: subs[i].Private,
// lastSeenTag: subs[i].LastSeen,
modeWant: subs[i].ModeWant,
modeGiven: subs[i].ModeGiven}
}
} else {
// Cases 1, 2
log.Println("hub: p2p new topic or one of the subs missing")
var userData perUserData
// Fetching records for both users.
// Requester.
userId1 := sreg.sess.uid
// The other user.
userId2 := types.ParseUserId(t.original)
var u1, u2 int
users, err := store.Users.GetAll(userId1, userId2)
if err != nil {
log.Println("hub: failed to load users for '" + t.name + "' (" + err.Error() + ")")
sreg.sess.queueOut(ErrUnknown(sreg.pkt.Id, t.name, timestamp))
return
} else if len(users) != 2 {
// Invited user does not exist
log.Println("hub: missing user for '" + t.name + "'")
sreg.sess.queueOut(ErrUserNotFound(sreg.pkt.Id, t.name, timestamp))
return
} else {
// User records are unsorted, make sure we know who is who.
if users[0].Uid() == userId1 {