1package protocol 2 3// Perspective determines if we're acting as a server or a client 4type Perspective int 5 6// the perspectives 7const ( 8 PerspectiveServer Perspective = 1 9 PerspectiveClient Perspective = 2 10) 11 12// Opposite returns the perspective of the peer 13func (p Perspective) Opposite() Perspective { 14 return 3 - p 15} 16 17func (p Perspective) String() string { 18 switch p { 19 case PerspectiveServer: 20 return "Server" 21 case PerspectiveClient: 22 return "Client" 23 default: 24 return "invalid perspective" 25 } 26} 27