Skip to content

Commit

Permalink
add frame type
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia committed Oct 21, 2023
1 parent 7baf788 commit 846cddb
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions type.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,92 @@ const (
TypeProtobuf Type = "protobuf"
)

type FrameType uint8

const (
FrameTypeServerPing FrameType = iota + 1
FrameTypeClientPong

FrameTypePushConnect
FrameTypePushSubscribe
FrameTypePushPublication
FrameTypePushJoin
FrameTypePushLeave
FrameTypePushUnsubscribe
FrameTypePushMessage
FrameTypePushRefresh
FrameTypePushDisconnect

FrameTypeConnect
FrameTypeSubscribe
FrameTypePublish
FrameTypeUnsubscribe
FrameTypeRPC
FrameTypePresence
FrameTypePresenceStats
FrameTypeHistory
FrameTypeRefresh
FrameTypeSubRefresh
FrameTypePing
FrameTypeSend
)

func (f FrameType) String() string {
switch f {
case FrameTypeServerPing:
return "server_ping"
case FrameTypeClientPong:
return "client_pong"

case FrameTypePushConnect:
return "push_connect"
case FrameTypePushSubscribe:
return "push_subscribe"
case FrameTypePushPublication:
return "push_publication"
case FrameTypePushJoin:
return "push_join"
case FrameTypePushLeave:
return "push_leave"
case FrameTypePushUnsubscribe:
return "push_unsubscribe"
case FrameTypePushMessage:
return "push_message"
case FrameTypePushRefresh:
return "push_refresh"
case FrameTypePushDisconnect:
return "push_disconnect"

case FrameTypeConnect:
return "connect"
case FrameTypeSubscribe:
return "subscribe"
case FrameTypePublish:
return "publish"
case FrameTypeUnsubscribe:
return "unsubscribe"
case FrameTypeRPC:
return "rpc"
case FrameTypePresence:
return "presence"
case FrameTypePresenceStats:
return "presence_stats"
case FrameTypeHistory:
return "history"
case FrameTypeSubRefresh:
return "sub_refresh"
case FrameTypeRefresh:
return "refresh"
case FrameTypeSend:
return "send"
case FrameTypePing:
return "ping"

default:
return "unknown"
}
}

var (
DefaultJsonPushEncoder = NewJSONPushEncoder()
DefaultProtobufPushEncoder = NewProtobufPushEncoder()
Expand Down

0 comments on commit 846cddb

Please sign in to comment.