Skip to content

Commit

Permalink
minor example tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsegev committed Dec 22, 2024
1 parent fe222a7 commit b12893a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/bstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int main(void) {
FIO_STRING_WRITE_STR1(". The answer is: "),
FIO_STRING_WRITE_UNUM(42));
printf("Original string: %s\n", org);
printf("Copied string: %s\n", copy);
printf("Edited string: %s\n", copy);
fio_bstr_free(org);
fio_bstr_free(copy);
}
11 changes: 10 additions & 1 deletion examples/chat.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ FIO_SFUNC void on_data_chat(fio_io_s *io);
FIO_SFUNC void on_shutdown(fio_io_s *io);
/** Called when the monitored IO is closed or has a fatal error. */
FIO_SFUNC void on_close(void *buf, void *udata);
/** Called when the monitored IO is closed or has a fatal error. */
FIO_SFUNC void on_close_unconnected(void *buf, void *udata);

static fio_io_protocol_s CHAT_PROTOCOL_LOGIN = {
.on_attach = on_login_start,
.on_data = on_data_login,
.on_close = on_close,
.on_close = on_close_unconnected,
};
static fio_io_protocol_s CHAT_PROTOCOL_CHAT = {
.on_data = on_data_chat,
Expand Down Expand Up @@ -98,6 +100,13 @@ FIO_SFUNC void on_close(void *buf, void *udata) {
(void)buf;
}

/** Called when the monitored IO is closed or has a fatal error. */
FIO_SFUNC void on_close_unconnected(void *buf, void *udata) {
client_s *c = udata;
client_free(c);
(void)buf;
}

/** Performs "login" logic (saves user handle) */
FIO_SFUNC void on_data_first_line(fio_io_s *io, char *name, size_t len) {
if (!len)
Expand Down
13 changes: 11 additions & 2 deletions examples/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,17 @@ int main(int argc, char const *argv[]) {
1,
"A simple TCP/IP, Unix or UDP client application. Requires a URL "
"type address. i.e.\n"
"\tNAME <url>\n\n"
"Unix socket examples:\n"
"\tNAME <url>\n"
"\nHTTP examples:\n"
"\tNAME http://google.com/\n"
"\tNAME https://google.com/\n"
"\nWebSocket examples:\n"
"\tNAME ws://localhost:3000/\n"
"\tNAME wss://localhost:3000/\n"
"\nSSE (Server Sent Events) examples:\n"
"\tNAME sse://localhost:3000/\n"
"\tNAME sses://localhost:3000/\n"
"\nUnix socket examples:\n"
"\tNAME unix://./my.sock\n"
"\tNAME /full/path/to/my.sock\n"
"\nTCP/IP socket examples:\n"
Expand Down

0 comments on commit b12893a

Please sign in to comment.