Documentation ¶
Index ¶
- Constants
- func IsPublicMessageType(messageType string) bool
- func NewMessageContent(messageType string) interface{}
- func NotMessageType(messageType string) bool
- type BasicInfo
- type BasicRpcResponse
- type BasicRpcResponseInterface
- type BroadcastMessageContent
- type ConnectMessageContent
- type Connection
- type Error
- func NewClientError(msg string, a ...any) *Error
- func NewError(msg string) *Error
- func NewErrorWithCode(msg string, code ErrorCode) *Error
- func NewMessageContentError(msg string, a ...any) *Error
- func NewNetWorkTimeoutError(msg string, a ...any) *Error
- func NewRoomCloseError(msg string, a ...any) *Error
- func NewRoomNotFoundError(msg string, a ...any) *Error
- func NewServeError(msg string, a ...any) *Error
- type ErrorCode
- type ErrorMessageContent
- type Info
- type JoinOrLeaveMessageContent
- type ManagerRoom
- type Message
- func NewBroadcastMessage(data json.RawMessage, from *Connection) *Message
- func NewCloseMessage(roomAddress event.Address, reason string) *Message
- func NewConnectMessage(selfConnection *Connection, roomConnections []*Connection) *Message
- func NewJoinMessage(connection *Connection) *Message
- func NewLeaveMessage(connection *Connection) *Message
- func NewPingMessage(from event.Address) *Message
- func NewSendMessage(data json.RawMessage, from *Connection, to *Connection) *Message
- func NewStartMessage(roomAddress event.Address) *Message
- type MessageMessageContent
- type PingContent
- type RawMessage
- type RemoteRoom
- type Room
- type RpcRoom
- type StartOrCloseMessageContent
- type UpdateRoomInfoContent
Constants ¶
View Source
const ( UnknownError = "UnknownError" RoomNotFoundError = "RoomNotFoundError" RoomCloseError = "RoomCloseError" NetWorkTimeoutError = "NetWorkTimeoutError" MessageContentError = "MessageContentError" ServeError = "ServeError" ClientError = "ClientError" )
View Source
const ( BroadcastType = "broadcast" ConnectType = "connect" StartType = "start" CloseType = "close" PingType = "ping" PongType = "pong" UpdateRoomInfoType = "updateRoomInfo" MessageType = "message" JoinType = "join" ErrorType = "error" LeaveType = "leave" UnknownType = "unknown" )
Variables ¶
This section is empty.
Functions ¶
func IsPublicMessageType ¶
func NewMessageContent ¶
func NewMessageContent(messageType string) interface{}
func NotMessageType ¶
Types ¶
type BasicRpcResponse ¶
type BasicRpcResponse struct {
Error *Error `json:"error"`
}
func (*BasicRpcResponse) GetError ¶
func (b *BasicRpcResponse) GetError() error
func (*BasicRpcResponse) SetError ¶
func (b *BasicRpcResponse) SetError(err error) error
type BasicRpcResponseInterface ¶
type BasicRpcResponseInterface interface {
GetError() error
}
type BroadcastMessageContent ¶
type BroadcastMessageContent struct { Data json.RawMessage `json:"data"` From *Connection `json:"from"` IncludeSelf bool `json:"includeSelf"` }
type ConnectMessageContent ¶
type ConnectMessageContent struct { SelfConnection *Connection `json:"selfConnection"` RoomConnections []*Connection `json:"roomConnections"` }
type Connection ¶
type Error ¶
func NewClientError ¶
func NewErrorWithCode ¶
func NewMessageContentError ¶
func NewNetWorkTimeoutError ¶
func NewRoomCloseError ¶
func NewRoomNotFoundError ¶
func NewServeError ¶
type ErrorMessageContent ¶
type Info ¶
type Info struct { BasicInfo Address *event.Address `json:"address"` Secret string `json:"secret"` UseSecret bool `json:"useSecret"` CreatedAt time.Time `json:"createdAt"` ActiveAt time.Time `json:"activeAt"` Connections []*Connection `json:"connections"` }
func NewRoomInfo ¶
type JoinOrLeaveMessageContent ¶
type JoinOrLeaveMessageContent struct {
Connection *Connection `json:"connection"`
}
type ManagerRoom ¶
type Message ¶
type Message struct { Type string `json:"type"` CreatedAt int64 `json:"createdAt"` RequestId string `json:"requestId"` Content interface{} `json:"content"` }
func NewBroadcastMessage ¶
func NewBroadcastMessage(data json.RawMessage, from *Connection) *Message
func NewConnectMessage ¶
func NewConnectMessage(selfConnection *Connection, roomConnections []*Connection) *Message
func NewJoinMessage ¶
func NewJoinMessage(connection *Connection) *Message
func NewLeaveMessage ¶
func NewLeaveMessage(connection *Connection) *Message
func NewPingMessage ¶
func NewSendMessage ¶
func NewSendMessage(data json.RawMessage, from *Connection, to *Connection) *Message
func NewStartMessage ¶
type MessageMessageContent ¶
type MessageMessageContent struct { Data json.RawMessage `json:"data"` From *Connection `json:"from"` To *Connection `json:"to"` }
type PingContent ¶
type RawMessage ¶
type RawMessage struct { Type string `json:"type"` CreatedAt int64 `json:"createdAt"` RequestId string `json:"requestId"` Content json.RawMessage `json:"content"` }
func (*RawMessage) ToMessage ¶
func (rm *RawMessage) ToMessage() (*Message, error)
type RemoteRoom ¶
type Room ¶
type Room interface { RemoteRoom Ping() GetRoomUsers() []*Connection Join(ctx context.Context, connection *Connection, opt *Info) error Leave(ctx context.Context, connection *Connection, opt *Info) error }
type UpdateRoomInfoContent ¶
type UpdateRoomInfoContent struct {
Info *Info `json:"info"`
}
Click to show internal directories.
Click to hide internal directories.