2024-10-10 07:32:41 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net"
|
|
|
|
"time"
|
|
|
|
|
2024-11-27 12:32:31 +01:00
|
|
|
"git.qowevisa.me/qowevisa/tcpmachine/tcpserver"
|
2024-10-10 07:32:41 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2024-10-11 08:24:32 +02:00
|
|
|
server := tcpserver.CreateServer("127.0.0.1:10000")
|
|
|
|
server.On("PING", func(args []string, client net.Conn) {
|
|
|
|
client.Write([]byte("PONG\n"))
|
2024-10-10 07:32:41 +02:00
|
|
|
})
|
2024-10-11 08:24:32 +02:00
|
|
|
time.Sleep(time.Second)
|
|
|
|
err := server.StartServer()
|
2024-10-10 07:32:41 +02:00
|
|
|
if err != nil {
|
2024-10-11 08:24:32 +02:00
|
|
|
fmt.Printf("Error: server.StartServer: %v\n", err)
|
2024-10-10 07:32:41 +02:00
|
|
|
}
|
|
|
|
}
|