• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang types.Id函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Id函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: AddAlias

func (s *aliasStore) AddAlias(alias ct.Alias, room ct.RoomId) types.Error {
	inserted, err := s.idMap.Insert(ct.Id(alias), ct.Id(room))
	if err != nil {
		return types.InternalError(err)
	}
	if !inserted {
		return types.RoomInUseError("room alias '" + alias.String() + "' already exists")
	}
	return nil
}
开发者ID:rezacute,项目名称:bullettime,代码行数:10,代码来源:aliases.go


示例2: RemoveAlias

func (s *aliasStore) RemoveAlias(alias ct.Alias, room ct.RoomId) types.Error {
	deleted, err := s.idMap.Delete(ct.Id(alias), ct.Id(room))
	if err != nil {
		return types.InternalError(err)
	}
	if !deleted {
		return types.NotFoundError("room alias '" + alias.String() + "' doesn't exist")
	}
	return nil
}
开发者ID:rezacute,项目名称:bullettime,代码行数:10,代码来源:aliases.go


示例3: AddMember

func (db *memberStore) AddMember(roomId ct.RoomId, userId ct.UserId) types.Error {
	inserted, err := db.idMap.Put(ct.Id(roomId), ct.Id(userId))
	if err != nil {
		return types.InternalError(err)
	}
	if !inserted {
		msg := fmt.Sprintf("user %s is already a member of the room %s", userId, roomId)
		return types.ServerError(msg)
	}
	return nil
}
开发者ID:rezacute,项目名称:bullettime,代码行数:11,代码来源:members.go


示例4: RemoveMember

func (db *memberStore) RemoveMember(roomId ct.RoomId, userId ct.UserId) types.Error {
	deleted, err := db.idMap.Delete(ct.Id(roomId), ct.Id(userId))
	if err != nil {
		return types.InternalError(err)
	}
	if !deleted {
		msg := fmt.Sprintf("user %s is not a member of the room %s", userId, roomId)
		return types.ServerError(msg)
	}
	return nil
}
开发者ID:rezacute,项目名称:bullettime,代码行数:11,代码来源:members.go


示例5: 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


示例6: Send

func (b *fanInTestBuffer) Send(id string, user string, expectedIndex uint64) {
	index, err := b.buffer.Send(types.EventInfo{
		EventId:   types.Id(types.NewEventId(id, "test")),
		Sender:    types.Id(types.NewUserId("tester", "test")),
		ContextId: types.Id(types.NewRoomId("room1", "test")),
		EventType: "m.test",
	}, types.Id(types.NewUserId(user, "test")))
	if err != nil {
		debug.PrintStack()
		b.t.Fatal("error pushing signal: ", err)
	}
	if index != expectedIndex {
		debug.PrintStack()
		b.t.Fatal("invalid index, expected %d but got %d", expectedIndex, index)
	}
}
开发者ID:Rugvip,项目名称:bullettime,代码行数:16,代码来源:faninstream_test.go


示例7: UserPasswordHash

func (db *userDb) UserPasswordHash(id ct.UserId) (string, types.Error) {
	value, err := db.State(ct.Id(id), passwordHashKey)
	if err != nil {
		return "", types.InternalError(err)
	}
	return string(value), nil
}
开发者ID:rezacute,项目名称:bullettime,代码行数:7,代码来源:users.go


示例8: Select

func (b *fanOutTestBuffer) Select(user string, from, to, expectedFromIndex, expectedToIndex uint64, expected ...string) {
	signals, fromIndex, toIndex, err := b.buffer.SelectForwards(types.Id(types.NewUserId(user, "test")), from, to)
	if err != nil {
		debug.PrintStack()
		b.t.Fatal("failed to get signal range: ", err)
	}
	if len(signals) != len(expected) {
		debug.PrintStack()
		b.t.Fatalf("invalid signal count, expected %d but got %d", len(expected), len(signals))
	}
	if expectedFromIndex != fromIndex {
		debug.PrintStack()
		b.t.Fatalf("invalid from index, expected %d but got %d", expectedFromIndex, fromIndex)
	}
	if expectedToIndex != toIndex {
		debug.PrintStack()
		b.t.Fatalf("invalid to index, expected %d but got %d", expectedToIndex, toIndex)
	}
	for i, signal := range signals {
		if signal.EventId.Id != expected[i] {
			debug.PrintStack()
			b.t.Fatalf("invalid event id: expected %s, got %s", expected[i], signal.EventId.Id)
		}
	}
}
开发者ID:Rugvip,项目名称:bullettime,代码行数:25,代码来源:fanoutstream_test.go


示例9: Room

func (s *aliasStore) Room(alias ct.Alias) (*ct.RoomId, types.Error) {
	room, err := s.idMap.Lookup(ct.Id(alias))
	if err != nil {
		return nil, types.InternalError(err)
	}
	return (*ct.RoomId)(room), nil
}
开发者ID:rezacute,项目名称:bullettime,代码行数:7,代码来源:aliases.go


示例10: Aliases

func (s *aliasStore) Aliases(room ct.RoomId) ([]ct.Alias, types.Error) {
	ids, err := s.idMap.ReverseLookup(ct.Id(room))
	if err != nil {
		return nil, types.InternalError(err)
	}
	aliases := *(*[]ct.Alias)(unsafe.Pointer(&ids))
	return aliases, nil
}
开发者ID:rezacute,项目名称:bullettime,代码行数:8,代码来源:aliases.go


示例11: Push

func (b *fanOutTestBuffer) Push(id string, expectedIndex uint64, users ...string) {
	userIds := make([]types.Id, len(users))
	for i, user := range users {
		userIds[i] = types.Id(types.NewUserId(user, "test"))
	}
	index, err := b.buffer.Send(types.EventInfo{
		EventId:   types.Id(types.NewEventId(id, "test")),
		Sender:    types.Id(types.NewUserId("tester", "test")),
		ContextId: types.Id(types.NewRoomId("room1", "test")),
		EventType: "m.test",
	}, userIds)
	if err != nil {
		b.t.Fatal("error pushing signal: ", err)
	}
	if index != expectedIndex {
		debug.PrintStack()
		b.t.Fatal("invalid index, expected %d but got %d", expectedIndex, index)
	}
}
开发者ID:Rugvip,项目名称:bullettime,代码行数:19,代码来源:fanoutstream_test.go


示例12: Peers

func (db *memberStore) Peers(userId ct.UserId) (map[ct.UserId]struct{}, types.Error) {
	peers := map[ct.UserId]struct{}{}
	rooms, err := db.idMap.ReverseLookup(ct.Id(userId))
	if err != nil {
		return nil, types.InternalError(err)
	}
	for _, room := range rooms {
		members, err := db.idMap.Lookup(room)
		if err != nil {
			return nil, types.InternalError(err)
		}
		for _, member := range members {
			peers[ct.UserId(member)] = struct{}{}
		}
	}
	return peers, nil
}
开发者ID:rezacute,项目名称:bullettime,代码行数:17,代码来源:members.go


示例13: sendMessage

func (s roomService) sendMessage(
	room ct.RoomId,
	user ct.UserId,
	content types.TypedContent,
) (*types.Message, types.Error) {
	log.Printf("Sending message: %#v, %#v, %#v, %#v", room, user, content)

	message := new(types.Message)
	message.EventId = ct.DeriveEventId(utils.RandomString(16), ct.Id(user))
	message.RoomId = room
	message.UserId = user
	message.EventType = content.GetEventType()
	message.Timestamp = ct.Timestamp{time.Now()}
	message.Content = content

	_, err := s.eventSink.Send(message)
	if err != nil {
		return nil, err
	}
	return message, nil
}
开发者ID:Rugvip,项目名称:bullettime,代码行数:21,代码来源:rooms.go


示例14: Event

func (s *messageStream) Event(
	user ct.UserId,
	eventId ct.EventId,
) (types.Event, types.Error) {
	s.lock.RLock()
	indexed := s.byId[ct.Id(eventId)]
	s.lock.RUnlock()
	extraUser := extraUserForEvent(indexed.event)
	if extraUser != nil && *extraUser == user {
		return indexed.event, nil
	}
	rooms, err := s.members.Rooms(user)
	if err != nil {
		return nil, err
	}
	for _, room := range rooms {
		if room == *indexed.event.GetRoomId() {
			return indexed.event, nil
		}
	}
	return nil, nil
}
开发者ID:Rugvip,项目名称:bullettime,代码行数:22,代码来源:messages.go


示例15: GetEventKey

func (e *TypingEvent) GetEventKey() ct.Id {
	return ct.Id(e.RoomId)
}
开发者ID:rezacute,项目名称:bullettime,代码行数:3,代码来源:events.go


示例16: SetUserPasswordHash

func (db *userDb) SetUserPasswordHash(id ct.UserId, hash string) types.Error {
	_, err := db.SetState(ct.Id(id), passwordHashKey, []byte(hash))
	return types.InternalError(err)
}
开发者ID:rezacute,项目名称:bullettime,代码行数:4,代码来源:users.go


示例17: UserExists

func (db *userDb) UserExists(id ct.UserId) (bool, types.Error) {
	exists, err := db.BucketExists(ct.Id(id))
	return exists, types.InternalError(err)
}
开发者ID:rezacute,项目名称:bullettime,代码行数:4,代码来源:users.go


示例18: CreateUser

func (db *userDb) CreateUser(id ct.UserId) (bool, types.Error) {
	exists, err := db.CreateBucket(ct.Id(id))
	return exists, types.InternalError(err)
}
开发者ID:rezacute,项目名称:bullettime,代码行数:4,代码来源:users.go


示例19: Users

func (db *memberStore) Users(roomId ct.RoomId) ([]ct.UserId, types.Error) {
	ids, err := db.idMap.Lookup(ct.Id(roomId))
	users := *(*[]ct.UserId)(unsafe.Pointer(&ids))
	return users, types.InternalError(err)
}
开发者ID:rezacute,项目名称:bullettime,代码行数:5,代码来源:members.go


示例20: Rooms

func (db *memberStore) Rooms(userId ct.UserId) ([]ct.RoomId, types.Error) {
	ids, err := db.idMap.ReverseLookup(ct.Id(userId))
	rooms := *(*[]ct.RoomId)(unsafe.Pointer(&ids))
	return rooms, types.InternalError(err)
}
开发者ID:rezacute,项目名称:bullettime,代码行数:5,代码来源:members.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang types.RoomId类代码示例发布时间:2022-05-23
下一篇:
Golang env.Backend类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap