2024-06-22 05:59:27 +00:00
# go-teeworlds-protocol
2024-06-02 01:27:41 +00:00
2024-06-23 05:05:57 +00:00
## Early and active development! Still undergoing major refactors!
## WARNING! NOT READY TO BE USED YET!
## Apis might change. Packages and repository might be renamed!
2024-06-02 01:27:41 +00:00
A client side network protocol implementation of the game teeworlds.
2024-06-23 05:05:57 +00:00
## low level api for power users
2024-06-17 05:13:22 +00:00
2024-06-23 05:05:57 +00:00
The packages **chunk7, messages7, network7, packer, protocol7** Implement the low level 0.7 teeworlds protocol. Use them if you want to build something advanced such as a custom proxy.
## high level api for ease of use
The package **teeworlds7** implements a high level client library. Designed for ease of use.
```go
package main
import (
"fmt"
"os"
"time"
"github.com/teeworlds-go/go-teeworlds-protocol/messages7"
"github.com/teeworlds-go/go-teeworlds-protocol/teeworlds7"
)
func main() {
client := teeworlds7.Client{Name: "nameless tee"}
// Register your callback for incoming chat messages
// For a full list of all callbacks see: https://github.com/teeworlds-go/go-teeworlds-protocol/tree/master/teeworlds7/user_hooks.go
client.OnChat(func(msg *messages7.SvChat, defaultAction teeworlds7.DefaultAction) {
// the default action prints the chat message to the console
// if this is not called and you don't print it your self the chat will not be visible
defaultAction()
if msg.Message == "!ping" {
// Send reply in chat using the SendChat() action
// For a full list of all actions see: https://github.com/teeworlds-go/go-teeworlds-protocol/tree/master/teeworlds7/user_actions.go
client.SendChat("pong")
}
})
client.Connect("127.0.0.1", 8303)
}
2024-06-17 05:13:22 +00:00
```
2024-06-23 05:05:57 +00:00
Example usages:
- [client_verbose ](./examples/client_verbose/ ) a verbose client show casing the easy to use high level api
2024-06-02 01:41:00 +00:00
## tests
```
2024-06-17 05:13:22 +00:00
go test ./...
2024-06-02 01:41:00 +00:00
```
2024-06-22 05:59:27 +00:00
## projects using go-teeworlds-protocol
- [MITM teeworlds proxy ](https://github.com/teeworlds-go/proxy )