95 lines
3.0 KiB
Go
95 lines
3.0 KiB
Go
package protocol
|
|
|
|
// 协议常量与默认上限(与 DEVELOPMENT 第 6、11 节示例一致)。
|
|
|
|
const (
|
|
Version = 1
|
|
|
|
TypeHello = "hello"
|
|
TypeResp = "resp"
|
|
TypeSend = "send"
|
|
TypeMsg = "msg"
|
|
TypeAck = "ack"
|
|
TypeRecall = "recall"
|
|
TypeStatus = "status"
|
|
TypeReceipt = "receipt"
|
|
TypeReceiptAck = "receipt_ack"
|
|
TypeRevoked = "revoked"
|
|
TypePresenceGet = "presence.get"
|
|
TypeDirectoryList = "directory.list"
|
|
TypePresenceWatch = "presence.watch"
|
|
TypePresence = "presence"
|
|
TypeUnlock = "unlock"
|
|
TypeSelfGet = "self.get"
|
|
TypeSelfUpdate = "self.update"
|
|
TypeSelfTalkPassword = "self.talk_password"
|
|
TypeSelfLoginPassword = "self.login_password"
|
|
TypeSelfLogout = "self.logout"
|
|
TypeGroupCreate = "group.create"
|
|
TypeGroupAdd = "group.add"
|
|
TypeGroupRemove = "group.remove"
|
|
TypeGroupLeave = "group.leave"
|
|
TypeGroupTransfer = "group.transfer"
|
|
TypeGroupRename = "group.rename"
|
|
TypeGroupDissolve = "group.dissolve"
|
|
TypeGroupList = "group.list"
|
|
TypeGroupGet = "group.get"
|
|
TypeGroupEvent = "group_event"
|
|
TypeFatal = "fatal"
|
|
|
|
TargetEndpoint = "endpoint"
|
|
TargetGroup = "group"
|
|
|
|
EncUTF8 = "utf8"
|
|
EncBase64 = "base64"
|
|
|
|
DefaultContentTypeUTF8 = "text/plain; charset=utf-8"
|
|
DefaultContentTypeBase64 = "application/octet-stream"
|
|
|
|
SessionTokenPrefix = "nst_"
|
|
|
|
MinIDLen = 1
|
|
MaxIDLen = 64
|
|
MaxContentTypeLen = 128
|
|
MaxNameChars = 64
|
|
MinLoginPasswordLen = 8
|
|
MaxLoginPasswordLen = 128
|
|
MinTalkPasswordLen = 4
|
|
MaxTalkPasswordLen = 64
|
|
MinMaxReceiveBytes = 1024
|
|
MaxPresenceGetIDs = 200
|
|
MaxPresenceWatchIDs = 1000
|
|
MaxPageLimit = 200
|
|
DefaultOfflineTTL = int64(86400)
|
|
DefaultMaxBodyBytes = 262144
|
|
DefaultMaxMetaBytes = 4096
|
|
DefaultMaxFrameBytes = 786432
|
|
)
|
|
|
|
// 第 6.10 节错误码。
|
|
const (
|
|
CodeBadRequest = "bad_request"
|
|
CodeNotReady = "not_ready"
|
|
CodeUnauthorized = "unauthorized"
|
|
CodeForbidden = "forbidden"
|
|
CodeNotFound = "not_found"
|
|
CodeInvalidTarget = "invalid_target"
|
|
CodeConflict = "conflict"
|
|
CodeIDTaken = "id_taken"
|
|
CodeBodyTooLarge = "body_too_large"
|
|
CodeMetaTooLarge = "meta_too_large"
|
|
CodeFrameTooLarge = "frame_too_large"
|
|
CodeResponseTooLarge = "response_too_large"
|
|
CodeTalkPasswordRequired = "talk_password_required"
|
|
CodeTalkPasswordInvalid = "talk_password_invalid"
|
|
CodeRateLimited = "rate_limited"
|
|
CodeNotMember = "not_member"
|
|
CodeOwnerCannotLeave = "owner_cannot_leave"
|
|
CodeGroupFull = "group_full"
|
|
CodeQuotaExceeded = "quota_exceeded"
|
|
CodeEndpointDisabled = "endpoint_disabled"
|
|
CodeRegistrationClosed = "registration_closed"
|
|
CodeRegistrationCodeInvalid = "registration_code_invalid"
|
|
CodeBusy = "busy"
|
|
)
|