Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcceptMessage ¶
type AcceptMessage struct { Type MessageType `json:"type"` IceServers []*ICEServer `json:"iceServers"` IsExistClient bool `json:"isExistClient"` IsExistUser bool `json:"isExistUser"` // for compatibility }
AcceptMessage represents a register message. See https://github.com/OpenAyame/ayame-spec for details
type Authenticator ¶
type Authenticator interface { // Authenticate authenticates a client registration. Authenticate(ctx context.Context, req *AuthnRequest) (*AuthnResponse, error) }
Authenticator is a authentication logic for registration.
type AuthnRequest ¶
type AuthnRequest struct { RoomID RoomID ClientID ClientID ConnectionID connectionID AuthnMetadata map[string]interface{} }
AuthnRequest is a request for Authenticator.
type AuthnResponse ¶
type AuthnResponse struct { Allowed bool Reason string ICEServers []*ICEServer AuthzMetadata map[string]interface{} }
AuthnResponse is a response for Authenticator.
type ByeMessage ¶
type ByeMessage struct {
Type MessageType `json:"type"`
}
ByeMessage represents a bye message. See https://github.com/OpenAyame/ayame-spec for details
type CandidateMessage ¶
type CandidateMessage struct { Type MessageType `json:"type"` ICECandidate *ICECandidateInit `json:"ice,omitempty"` }
CandidateMessage represents a candidate message. See https://github.com/OpenAyame/ayame-spec for details
type ICECandidateInit ¶
type ICECandidateInit struct { Candidate string `json:"candidate"` SDPMid *string `json:"sdpMid"` SDPMLineIndex *uint16 `json:"sdpMLineIndex"` UsernameFragment *string `json:"usernameFragment"` }
ICECandidateInit is used to serialize ice candidates.
type ICEServer ¶
type ICEServer struct { URLs []string `json:"urls"` UserName string `json:"username,omitempty"` Credential string `json:"credential,omitempty"` }
ICEServer represents ICE server's information.
type Logger ¶
type Logger interface { Debugf(template string, args ...interface{}) Infof(template string, args ...interface{}) Warnf(template string, args ...interface{}) Errorf(template string, args ...interface{}) }
Logger is a logger interface
type MessageType ¶
type MessageType string
MessageType represents a type of messages in ayame protocol. See https://github.com/OpenAyame/ayame-spec for details.
const ( MessageTypeAccept MessageType = "accept" MessageTypeAnswer MessageType = "answer" MessageTypeBye MessageType = "bye" MessageTypeCandidate MessageType = "candidate" MessageTypeOffer MessageType = "offer" MessageTypePing MessageType = "ping" MessageTypePong MessageType = "pong" MessageTypeRegister MessageType = "register" MessageTypeReject MessageType = "reject" )
type PingPongMessage ¶
type PingPongMessage struct {
Type MessageType `json:"type"`
}
PingPongMessage represents a ping-pong message. See https://github.com/OpenAyame/ayame-spec for details
type RegisterMessage ¶
type RegisterMessage struct { Type MessageType `json:"type"` RoomID RoomID `json:"roomId"` ClientID ClientID `json:"clientId"` AuthnMetadata map[string]interface{} `json:"authnMetadata,omitempty"` }
RegisterMessage represents a register message. See https://github.com/OpenAyame/ayame-spec for details
type RejectMessage ¶
type RejectMessage struct { Type MessageType `json:"type"` Reason string `json:"reason"` }
RejectMessage represents a reject message. See https://github.com/OpenAyame/ayame-spec for details
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a server of ayu.
func NewServer ¶
func NewServer(redisClient *redis.Client, opts ...ServerOption) *Server
NewServer creates a new ayu server.
type ServerOption ¶
type ServerOption interface {
// contains filtered or unexported methods
}
ServerOption represents an option for Server.
func WithAuthenticator ¶
func WithAuthenticator(authn Authenticator) ServerOption
WithAuthenticator specifies the custom authentication for registration.
func WithLogger ¶
func WithLogger(logger Logger) ServerOption
WithLogger specifies the custom logger.
func WithPingInterval ¶
func WithPingInterval(interval time.Duration) ServerOption
WithPingInterval specifies the custom ping interval.
func WithRoomExpiration ¶
func WithRoomExpiration(expiration time.Duration) ServerOption
WithRoomExpiration specifies the custom room expiration in Redis.