2017-11-22 06:05:36 +00:00
|
|
|
package libnmdc
|
|
|
|
|
|
|
|
type Protocol interface {
|
|
|
|
ProcessCommand(msg string)
|
|
|
|
|
2018-06-04 04:27:34 +00:00
|
|
|
SayPublic(string) error
|
2017-11-22 06:05:36 +00:00
|
|
|
|
2018-06-04 04:27:34 +00:00
|
|
|
SayPrivate(user, message string) error
|
2017-11-22 06:05:36 +00:00
|
|
|
|
2018-06-04 04:27:34 +00:00
|
|
|
SayInfo() error
|
2018-03-24 00:21:49 +00:00
|
|
|
|
2017-11-22 06:05:36 +00:00
|
|
|
ProtoMessageSeparator() string
|
|
|
|
}
|
2017-11-22 07:02:11 +00:00
|
|
|
|
|
|
|
type HubProtocol int
|
|
|
|
|
|
|
|
const (
|
|
|
|
HubProtocolAutodetect HubProtocol = 0
|
|
|
|
HubProtocolNmdc HubProtocol = 1
|
|
|
|
HubProtocolAdc HubProtocol = 2
|
|
|
|
)
|
|
|
|
|
|
|
|
func (hp HubProtocol) Create(hc *HubConnection) Protocol {
|
|
|
|
if hp == HubProtocolNmdc {
|
|
|
|
return NewNmdcProtocol(hc)
|
|
|
|
|
|
|
|
} else if hp == HubProtocolAdc {
|
|
|
|
return NewAdcProtocol(hc)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return NewAutodetectProtocol(hc)
|
|
|
|
}
|
|
|
|
}
|