当前位置: 首页>>代码示例>>Golang>>正文


Golang types.RoomId类代码示例

本文整理汇总了Golang中github.com/matrix-org/bullettime/core/types.RoomId的典型用法代码示例。如果您正苦于以下问题:Golang RoomId类的具体用法?Golang RoomId怎么用?Golang RoomId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RoomId类的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
}
开发者ID:rezacute,项目名称:bullettime,代码行数:26,代码来源:rooms.go

示例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
}
开发者ID:Rugvip,项目名称:bullettime,代码行数:10,代码来源:rooms.go

示例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
}
开发者ID:rezacute,项目名称:bullettime,代码行数:12,代码来源:rooms.go

示例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
}
开发者ID:Rugvip,项目名称:bullettime,代码行数:14,代码来源:rooms.go

示例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
}
开发者ID:rezacute,项目名称:bullettime,代码行数:15,代码来源:rooms.go

示例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
}
开发者ID:Rugvip,项目名称:bullettime,代码行数:17,代码来源:rooms.go


注:本文中的github.com/matrix-org/bullettime/core/types.RoomId类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。