本文整理汇总了Golang中euphoria/io/heim/proto.MakeEvent函数的典型用法代码示例。如果您正苦于以下问题:Golang MakeEvent函数的具体用法?Golang MakeEvent怎么用?Golang MakeEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MakeEvent函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: sendPing
func (s *session) sendPing() error {
logger := Logger(s.ctx)
now := time.Now()
cmd, err := proto.MakeEvent(&proto.PingEvent{
UnixTime: proto.Time(now),
NextUnixTime: proto.Time(now.Add(3 * KeepAlive / 2)),
})
if err != nil {
logger.Printf("error: ping event: %s", err)
return err
}
data, err := cmd.Encode()
if err != nil {
logger.Printf("error: ping event encode: %s", err)
return err
}
if err := s.conn.WriteMessage(websocket.TextMessage, data); err != nil {
logger.Printf("error: write ping event: %s", err)
return err
}
s.expectedPingReply = now.Unix()
s.outstandingPings++
return nil
}
开发者ID:robot0x,项目名称:heim,代码行数:26,代码来源:session.go
示例2: sendSnapshot
func (s *session) sendSnapshot(msgs []proto.Message, listing proto.Listing) error {
for i, msg := range msgs {
if msg.EncryptionKeyID != "" {
dmsg, err := proto.DecryptMessage(msg, s.client.Authorization.MessageKeys)
if err != nil {
continue
}
msgs[i] = dmsg
}
}
snapshot := &proto.SnapshotEvent{
Identity: s.Identity().ID(),
SessionID: s.ID(),
Version: s.room.Version(),
Listing: listing,
Log: msgs,
}
event, err := proto.MakeEvent(snapshot)
if err != nil {
return err
}
s.outgoing <- event
return nil
}
开发者ID:robot0x,项目名称:heim,代码行数:26,代码来源:session.go
示例3: sendHello
func (s *session) sendHello(roomIsPrivate, accountHasAccess bool) error {
logger := Logger(s.ctx)
event := &proto.HelloEvent{
SessionView: s.View(),
AccountHasAccess: accountHasAccess,
RoomIsPrivate: roomIsPrivate,
Version: s.room.Version(),
}
if s.client.Account != nil {
event.AccountView = s.client.Account.View(s.roomName)
}
event.ID = event.SessionView.ID
cmd, err := proto.MakeEvent(event)
if err != nil {
logger.Printf("error: hello event: %s", err)
return err
}
data, err := cmd.Encode()
if err != nil {
logger.Printf("error: hello event encode: %s", err)
return err
}
if err := s.conn.WriteMessage(websocket.TextMessage, data); err != nil {
logger.Printf("error: write hello event: %s", err)
return err
}
return nil
}
开发者ID:NotAMoose,项目名称:heim,代码行数:30,代码来源:session.go
示例4: sendHello
func (s *session) sendHello(roomIsPrivate, accountHasAccess bool) error {
logger := logging.Logger(s.ctx)
event := &proto.HelloEvent{
SessionView: s.View(s.privilegeLevel()),
AccountHasAccess: accountHasAccess,
RoomIsPrivate: roomIsPrivate,
Version: s.room.Version(),
}
if s.client.Account != nil {
event.AccountView = &proto.PersonalAccountView{
AccountView: *s.client.Account.View(s.roomName),
}
event.AccountView.Email, event.AccountEmailVerified = s.client.Account.Email()
}
event.ID = event.SessionView.ID
cmd, err := proto.MakeEvent(event)
if err != nil {
logger.Printf("error: hello event: %s", err)
return err
}
data, err := cmd.Encode()
if err != nil {
logger.Printf("error: hello event encode: %s", err)
return err
}
if err := s.writeMessage(websocket.TextMessage, data); err != nil {
logger.Printf("error: write hello event: %s", err)
return err
}
return nil
}
开发者ID:logan,项目名称:heim,代码行数:33,代码来源:session.go
示例5: sendSnapshot
func (s *session) sendSnapshot() error {
snapshot, err := s.room.Snapshot(s.ctx, s, s.privilegeLevel(), 100)
if err != nil {
return err
}
s.identity.name = snapshot.Nick
for i, msg := range snapshot.Log {
if msg.EncryptionKeyID != "" {
dmsg, err := proto.DecryptMessage(msg, s.client.Authorization.MessageKeys, s.privilegeLevel())
if err != nil {
continue
}
snapshot.Log[i] = dmsg
}
}
s.identity.name = snapshot.Nick
event, err := proto.MakeEvent(snapshot)
if err != nil {
return err
}
s.outgoing <- event
return nil
}
开发者ID:logan,项目名称:heim,代码行数:28,代码来源:session.go
示例6: sendDisconnect
func (s *session) sendDisconnect(reason string) error {
event, err := proto.MakeEvent(&proto.DisconnectEvent{Reason: reason})
if err != nil {
return err
}
s.outgoing <- event
return nil
}
开发者ID:robot0x,项目名称:heim,代码行数:8,代码来源:session.go
示例7: sendBounce
func (s *session) sendBounce(reason string) error {
bounce := &proto.BounceEvent{
Reason: reason,
// TODO: fill in AuthOptions
}
event, err := proto.MakeEvent(bounce)
if err != nil {
return err
}
s.outgoing <- event
return nil
}
开发者ID:robot0x,项目名称:heim,代码行数:12,代码来源:session.go
示例8: invalidatePeer
// invalidatePeer must be called with lock held
func (b *Backend) invalidatePeer(ctx scope.Context, id, era string) {
logger := logging.Logger(ctx)
packet, err := proto.MakeEvent(&proto.NetworkEvent{
Type: "partition",
ServerID: id,
ServerEra: era,
})
if err != nil {
logger.Printf("cluster: make network event error: %s", err)
return
}
for _, lm := range b.listeners {
if err := lm.Broadcast(ctx, packet); err != nil {
logger.Printf("cluster: network event error: %s", err)
}
}
}
开发者ID:logan,项目名称:heim,代码行数:18,代码来源:backend.go
注:本文中的euphoria/io/heim/proto.MakeEvent函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论