2022-10-25 12:07:56 +00:00
|
|
|
# teeworlds-client
|
2022-11-01 13:26:40 +00:00
|
|
|
A teeworlds 0.7 client library written in ruby
|
2022-11-01 13:25:56 +00:00
|
|
|
|
2022-11-04 15:57:50 +00:00
|
|
|
## Sample
|
|
|
|
|
|
|
|
Here a simple sample usage of the library.
|
|
|
|
Connecting a client to localhost on port 8303.
|
|
|
|
And printing out every chat message the server sends.
|
|
|
|
Also properly disconnect when the program is killed gracefully.
|
|
|
|
|
|
|
|
For more sample usages checkout the [examples/](examples/) folder.
|
2022-11-04 12:22:29 +00:00
|
|
|
|
2022-11-01 13:25:56 +00:00
|
|
|
```ruby
|
|
|
|
require_relative 'lib/teeworlds-client'
|
|
|
|
|
2022-11-04 15:26:24 +00:00
|
|
|
client = TeeworldsClient.new(verbose: false)
|
2022-11-01 13:25:56 +00:00
|
|
|
|
2022-11-05 08:39:16 +00:00
|
|
|
client.on_chat do |msg|
|
2022-11-04 15:26:24 +00:00
|
|
|
puts "[chat] #{msg}"
|
2022-11-01 13:25:56 +00:00
|
|
|
end
|
|
|
|
|
2022-11-04 12:07:34 +00:00
|
|
|
Signal.trap('INT') do
|
|
|
|
client.disconnect
|
|
|
|
end
|
|
|
|
|
2022-11-04 12:22:29 +00:00
|
|
|
client.connect('localhost', 8303, detach: false)
|
|
|
|
```
|
|
|
|
|
2022-11-04 15:57:50 +00:00
|
|
|
## Documentation
|
2022-11-04 12:22:29 +00:00
|
|
|
|
2022-11-04 15:57:50 +00:00
|
|
|
Checkout [docs/01.md](docs/01.md) for a full library documentation.
|