本文整理汇总了Golang中github.com/matrix-org/bullettime/core/types.RoomId.String方法的典型用法代码示例。如果您正苦于以下问题:Golang RoomId.String方法的具体用法?Golang RoomId.String怎么用?Golang RoomId.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/matrix-org/bullettime/core/types.RoomId
的用法示例。
在下文中一共展示了RoomId.String方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetRoomState
func (db *roomDb) SetRoomState(roomId types.RoomId, userId types.UserId, content types.TypedContent, stateKey string) (*matrixTypes.State, matrixTypes.Error) {
db.roomsLock.RLock()
defer db.roomsLock.RUnlock()
room := db.rooms[roomId]
if room == nil {
return nil, matrixTypes.NotFoundError("room '" + roomId.String() + "' doesn't exist")
}
var eventId = types.DeriveEventId(utils.RandomString(16), types.Id(userId))
stateId := stateId{content.GetEventType(), stateKey}
state := new(matrixTypes.State)
state.EventId = eventId
state.RoomId = roomId
state.UserId = userId
state.EventType = content.GetEventType()
state.StateKey = stateKey
state.Timestamp = types.Timestamp{time.Now()}
state.Content = content
state.OldState = (*matrixTypes.OldState)(room.states[stateId])
room.stateLock.Lock()
defer room.stateLock.Unlock()
room.states[stateId] = state
return state, nil
}
示例2: RoomExists
func (s roomService) RoomExists(id ct.RoomId, caller ct.UserId) types.Error {
exists, err := s.rooms.RoomExists(id)
if err != nil {
return err
}
if !exists {
return types.NotFoundError("room '" + id.String() + "' doesn't exist")
}
return nil
}
示例3: RoomState
func (db *roomDb) RoomState(roomId types.RoomId, eventType, stateKey string) (*matrixTypes.State, matrixTypes.Error) {
db.roomsLock.RLock()
defer db.roomsLock.RUnlock()
room := db.rooms[roomId]
if room == nil {
return nil, matrixTypes.NotFoundError("room '" + roomId.String() + "' doesn't exist")
}
room.stateLock.RLock()
defer room.stateLock.RUnlock()
state := room.states[stateId{eventType, stateKey}]
return state, nil
}
示例4: powerLevels
func (s roomService) powerLevels(room ct.RoomId) (*types.PowerLevelsEventContent, types.Error) {
state, err := s.rooms.RoomState(room, types.EventTypePowerLevels, "")
if err != nil {
return nil, err
}
if state == nil {
panic("room power levels are invalid or missing: " + room.String())
}
powerLevels, ok := state.Content.(*types.PowerLevelsEventContent)
if !ok {
panic("invalid power level content, was " + reflect.TypeOf(state.Content).String())
}
return powerLevels, nil
}
示例5: EntireRoomState
func (db *roomDb) EntireRoomState(roomId types.RoomId) ([]*matrixTypes.State, matrixTypes.Error) {
db.roomsLock.RLock()
defer db.roomsLock.RUnlock()
room := db.rooms[roomId]
if room == nil {
return nil, matrixTypes.NotFoundError("room '" + roomId.String() + "' doesn't exist")
}
room.stateLock.RLock()
defer room.stateLock.RUnlock()
states := make([]*matrixTypes.State, 0, len(room.states))
for _, state := range room.states {
states = append(states, state)
}
return states, nil
}
示例6: allowsJoinRule
func (s roomService) allowsJoinRule(room ct.RoomId, joinRule types.JoinRule) (bool, types.Error) {
state, err := s.rooms.RoomState(room, types.EventTypeJoinRules, "")
if err != nil {
return false, err
}
if state == nil {
panic("room power levels are invalid or missing: " + room.String())
}
joinRules, ok := state.Content.(*types.JoinRulesEventContent)
if !ok {
panic("invalid join rule content, was " + reflect.TypeOf(state.Content).String())
}
if joinRules.JoinRule != joinRule {
return false, types.ForbiddenError("room does not allow join rule: " + joinRule.String())
}
return true, nil
}