本文整理汇总了Golang中github.com/tinode/chat/server/store/types.Subscription.Id方法的典型用法代码示例。如果您正苦于以下问题:Golang Subscription.Id方法的具体用法?Golang Subscription.Id怎么用?Golang Subscription.Id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tinode/chat/server/store/types.Subscription
的用法示例。
在下文中一共展示了Subscription.Id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TopicCreateP2P
// TopicCreateP2P given two users creates a p2p topic
func (a *RethinkDbAdapter) TopicCreateP2P(initiator, invited *t.Subscription) error {
initiator.Id = initiator.Topic + ":" + initiator.User
// Don't care if the initiator changes own subscription
_, err := rdb.DB(a.dbName).Table("subscriptions").Insert(initiator, rdb.InsertOpts{Conflict: "replace"}).
RunWrite(a.conn)
if err != nil {
return err
}
// Ensure this is a new subscription. If one already exist, don't overwrite it
invited.Id = invited.Topic + ":" + invited.User
_, err = rdb.DB(a.dbName).Table("subscriptions").Insert(invited, rdb.InsertOpts{Conflict: "error"}).
RunWrite(a.conn)
if err != nil {
// Is this a duplicate subscription? If so, ifnore it. Otherwise it's a genuine DB error
if !rdb.IsConflictErr(err) {
return err
}
}
topic := &t.Topic{
ObjHeader: t.ObjHeader{Id: initiator.Topic},
Access: t.DefaultAccess{Auth: t.ModeP2P, Anon: t.ModeBanned}}
topic.ObjHeader.MergeTimes(&initiator.ObjHeader)
return a.TopicCreate(topic)
}