From 481062838693369ec5b3f2e035dc436b2f54de6e Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sun, 17 Sep 2023 13:09:03 +0200 Subject: [PATCH] Document on_connected hook --- docs/v0.0.1/classes/Context.md | 15 --------------- docs/v0.0.1/classes/TeeworldsClient.md | 12 +++++++++++- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/docs/v0.0.1/classes/Context.md b/docs/v0.0.1/classes/Context.md index 5da680f..4c61e59 100644 --- a/docs/v0.0.1/classes/Context.md +++ b/docs/v0.0.1/classes/Context.md @@ -17,21 +17,6 @@ client.on_map_change do |context| end ``` -### @client [[TeeworldsClient](../classes/TeeworldsClient.md)] - -Access the network client to send packets. - -**Example:** - -Reimplement your on on_connected logic and cancel the default one - -```ruby -client.on_connected do |ctx| - ctx.client.send_msg_start_info - ctx.cancel -end -``` - ### @data [Hash] This hash holds all the current data. They keys might vary depending on the current context. diff --git a/docs/v0.0.1/classes/TeeworldsClient.md b/docs/v0.0.1/classes/TeeworldsClient.md index bba35b4..765c391 100644 --- a/docs/v0.0.1/classes/TeeworldsClient.md +++ b/docs/v0.0.1/classes/TeeworldsClient.md @@ -23,12 +23,22 @@ client.connect('localhost', 8303, detach: false) context.message is nil because there is no message payload. +By default the client will respond with the startinfo message. +This is crucial to establish a healthy connection to the server. +If you know what you are doing and do not want to send this message call `context.cancel` + **Example:** ```ruby client = TeeworldsClient.new client.on_connected do |context| - # TODO: generated documentation + puts "we got NETMSG_CON_READY from server" + + # skip default behavior + context.cancel + + # send start info manually + client.send_msg_start_info end client.connect('localhost', 8303, detach: false)