aboutsummaryrefslogtreecommitdiff
path: root/weechat/tomsg.c
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-04-15 09:59:11 +0200
committertomsmeding <tom.smeding@gmail.com>2017-04-15 09:59:11 +0200
commit9800ecb1e93d398988a6904d5e4dc6c4e11aedb0 (patch)
treec7da366fb4c640bba0b205d0b44013883b772cef /weechat/tomsg.c
parentffda2b39b6fe070a3f5edb229dd7806c362cc9e1 (diff)
weechat: Support sending user pings
Diffstat (limited to 'weechat/tomsg.c')
-rw-r--r--weechat/tomsg.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/weechat/tomsg.c b/weechat/tomsg.c
index 2954a47..3b188ec 100644
--- a/weechat/tomsg.c
+++ b/weechat/tomsg.c
@@ -259,6 +259,18 @@ static void login_net_callback(int fd,struct net_response res,void *payload){
}
}
+static void pong_net_callback(int fd,struct net_response res,void *payload){
+ (void)payload;
+ fprintf(debugf,"pong_net_callback(fd=%d,res={.type=%d})\n",fd,res.type);
+ struct conndata *conn=weechat_hashtable_get(conntable,&fd);
+ assert(conn);
+ if(res.type==NET_PONG){
+ weechat_printf(conn->buffer,"pong");
+ } else {
+ fprintf(debugf,"pong_net_callback: res.type=%d\n",res.type);
+ }
+}
+
static void conn_destroy(struct conndata *conn){
fprintf(debugf,"conn_destroy(conn=%p (fd=%d))\n",conn,conn->fd);
weechat_unhook(conn->fd_hook);
@@ -335,6 +347,8 @@ static int conn_input_cb(const void *conn_vp,void *_d,struct t_gui_buffer *buffe
if(conn->pending_username)free(conn->pending_username);
conn->pending_username=strdup(username);
net_sendf(conn->fd,login_net_callback,NULL,"login %s %s",username,password);
+ } else if(strcmp(cmd,"ping")==0){
+ net_sendf(conn->fd,pong_net_callback,NULL,"ping");
} else {
weechat_printf(conn->buffer,"Unknown command '%s'",cmd);
}