mirror of
https://github.com/originalmk/archat-server.git
synced 2024-11-20 09:38:50 +00:00
69 lines
1008 B
Go
69 lines
1008 B
Go
|
package common
|
||
|
|
||
|
type Request interface {
|
||
|
GetRID() byte
|
||
|
}
|
||
|
|
||
|
type Response Request
|
||
|
|
||
|
type PeerInfo struct {
|
||
|
ID int `json:"id"`
|
||
|
Addr string `json:"addr"`
|
||
|
HasNickaname bool `json:"hasNickname"`
|
||
|
Nickname string `json:"nickname"`
|
||
|
}
|
||
|
|
||
|
type EchoRequest struct {
|
||
|
EchoByte byte `json:"echoByte"`
|
||
|
}
|
||
|
|
||
|
type EchoResponse struct {
|
||
|
EchoByte byte `json:"echoByte"`
|
||
|
}
|
||
|
|
||
|
type ListPeersRequest struct {
|
||
|
}
|
||
|
|
||
|
type ListPeersResponse struct {
|
||
|
PeersInfo []PeerInfo `json:"peers"`
|
||
|
}
|
||
|
|
||
|
type AuthRequest struct {
|
||
|
Nickname string
|
||
|
Password string
|
||
|
}
|
||
|
|
||
|
type AuthResponse struct {
|
||
|
IsSuccess bool
|
||
|
}
|
||
|
|
||
|
const (
|
||
|
EchoRID = 1
|
||
|
ListPeersRID = 2
|
||
|
AuthRID = 3
|
||
|
)
|
||
|
|
||
|
func (EchoRequest) GetRID() byte {
|
||
|
return EchoRID
|
||
|
}
|
||
|
|
||
|
func (EchoResponse) GetRID() byte {
|
||
|
return EchoRID
|
||
|
}
|
||
|
|
||
|
func (AuthRequest) GetRID() byte {
|
||
|
return AuthRID
|
||
|
}
|
||
|
|
||
|
func (AuthResponse) GetRID() byte {
|
||
|
return AuthRID
|
||
|
}
|
||
|
|
||
|
func (ListPeersRequest) GetRID() byte {
|
||
|
return ListPeersRID
|
||
|
}
|
||
|
|
||
|
func (ListPeersResponse) GetRID() byte {
|
||
|
return ListPeersRID
|
||
|
}
|