Move all types in tcpserver to types.go
This commit is contained in:
parent
6e244be880
commit
ecb6e12425
|
@ -12,8 +12,6 @@ import (
|
|||
"git.qowevisa.me/Qowevisa/tcpmachine/tcpcommand"
|
||||
)
|
||||
|
||||
type ServerLoggingLevel int
|
||||
|
||||
const (
|
||||
LogLevel_Nothing = 0
|
||||
LogLevel_Connection = 1 << iota
|
||||
|
@ -24,15 +22,6 @@ const (
|
|||
LogLevel_ALL = LogLevel_Connection | LogLevel_Messages
|
||||
)
|
||||
|
||||
type ServerConfiguration struct {
|
||||
MessageEndRune rune
|
||||
MessageSplitRune rune
|
||||
HandleClientFunc func(client net.Conn)
|
||||
LogLevel ServerLoggingLevel
|
||||
//
|
||||
ErrorResolver func(chan error)
|
||||
}
|
||||
|
||||
func CreateHandleClientFuncFromCommands(bundle *tcpcommand.CommandBundle, conf ServerConfiguration) (func(client net.Conn), chan error) {
|
||||
clientErrors := make(chan error, 16)
|
||||
return func(client net.Conn) {
|
||||
|
@ -58,24 +47,6 @@ func CreateHandleClientFuncFromCommands(bundle *tcpcommand.CommandBundle, conf S
|
|||
}, clientErrors
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
addr string
|
||||
PreHandlerClientFunc func(client net.Conn)
|
||||
HandleClientFunc func(client net.Conn)
|
||||
// Use PostHandlerClientFunc in your HandleClientFunc if you
|
||||
// use custom HandleClientFunc
|
||||
PostHandlerClientFunc func(client net.Conn)
|
||||
Exit chan bool
|
||||
//
|
||||
MessageEndRune rune
|
||||
MessageSplitRune rune
|
||||
ErrorsChannel chan error
|
||||
ErrorResolver func(chan error)
|
||||
LogLevel ServerLoggingLevel
|
||||
//
|
||||
Commands []tcpcommand.Command
|
||||
}
|
||||
|
||||
func defaultHandleClientFunc(server *Server) func(net.Conn) {
|
||||
return func(client net.Conn) {
|
||||
if server.PostHandlerClientFunc != nil {
|
||||
|
|
36
tcpserver/types.go
Normal file
36
tcpserver/types.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package tcpserver
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"git.qowevisa.me/Qowevisa/tcpmachine/tcpcommand"
|
||||
)
|
||||
|
||||
type ServerLoggingLevel int
|
||||
|
||||
type ServerConfiguration struct {
|
||||
MessageEndRune rune
|
||||
MessageSplitRune rune
|
||||
HandleClientFunc func(client net.Conn)
|
||||
LogLevel ServerLoggingLevel
|
||||
//
|
||||
ErrorResolver func(chan error)
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
addr string
|
||||
PreHandlerClientFunc func(client net.Conn)
|
||||
HandleClientFunc func(client net.Conn)
|
||||
// Use PostHandlerClientFunc in your HandleClientFunc if you
|
||||
// use custom HandleClientFunc
|
||||
PostHandlerClientFunc func(client net.Conn)
|
||||
Exit chan bool
|
||||
//
|
||||
MessageEndRune rune
|
||||
MessageSplitRune rune
|
||||
ErrorsChannel chan error
|
||||
ErrorResolver func(chan error)
|
||||
LogLevel ServerLoggingLevel
|
||||
//
|
||||
Commands []tcpcommand.Command
|
||||
}
|
Loading…
Reference in New Issue
Block a user