diff --git a/tcpserver/server.go b/tcpserver/server.go index 57ca678..6cc86bd 100644 --- a/tcpserver/server.go +++ b/tcpserver/server.go @@ -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 { diff --git a/tcpserver/types.go b/tcpserver/types.go new file mode 100644 index 0000000..f01bcf4 --- /dev/null +++ b/tcpserver/types.go @@ -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 +}